n8n-nodes-ollama-reranker 1.4.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -175,7 +175,7 @@ class OllamaReranker {
175
175
  maxValue: 1,
176
176
  numberPrecision: 2,
177
177
  },
178
- description: 'Minimum relevance score (0-1) required to include document in results',
178
+ description: 'Minimum relevance score (0-1). Scores are auto-normalized across all models. Use 0.0 for no filtering.',
179
179
  },
180
180
  {
181
181
  displayName: 'Task Instruction',
@@ -255,7 +255,7 @@ class OllamaRerankerWorkflow {
255
255
  maxValue: 1,
256
256
  numberPrecision: 2,
257
257
  },
258
- description: 'Minimum relevance score (0-1)',
258
+ description: 'Minimum relevance score (0-1). Scores are auto-normalized across all models. Use 0.0 for no filtering.',
259
259
  },
260
260
  // Instruction
261
261
  {
@@ -89,14 +89,29 @@ async function rerankWithCustomAPI(context, config) {
89
89
  description: `Expected {results: [...]} but got: ${JSON.stringify(response)}`,
90
90
  });
91
91
  }
92
+ // Normalize scores to 0-1 range for consistent thresholding
93
+ // V1 (DeBERTa) returns 0-1 probabilities, V2 (Qwen2) returns logits
94
+ const normalizedResults = response.results.map((r) => {
95
+ const score = r.relevance_score;
96
+ // Detect logit scores (outside 0-1 range) and apply sigmoid
97
+ const normalizedScore = (score > 1 || score < 0)
98
+ ? 1 / (1 + Math.exp(-score)) // sigmoid normalization
99
+ : score;
100
+ return {
101
+ ...r,
102
+ relevance_score: normalizedScore,
103
+ _rawScore: score, // Keep original score for debugging
104
+ };
105
+ });
92
106
  // Filter by threshold and map to our format
93
- const filteredResults = response.results
107
+ const filteredResults = normalizedResults
94
108
  .filter((r) => r.relevance_score >= threshold)
95
109
  .map((result) => {
96
110
  const originalDoc = documents[result.index];
97
111
  const rerankedDoc = {
98
112
  ...originalDoc,
99
113
  _rerankScore: result.relevance_score,
114
+ _rawScore: result._rawScore, // Include raw score for debugging
100
115
  _originalIndex: result.index,
101
116
  };
102
117
  if (includeOriginalScores && originalDoc._originalScore !== undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-ollama-reranker",
3
- "version": "1.4.1",
3
+ "version": "1.5.0",
4
4
  "description": "Ollama Reranker for n8n - VL Classifier integration + Auto-detect + Dynamic model loading (Vector Store provider + workflow node)",
5
5
  "main": "index.js",
6
6
  "author": "Gabriel BRUMENT",
@@ -60,8 +60,10 @@
60
60
  "ts-jest": "^29.0.0",
61
61
  "typescript": "^5.0.0"
62
62
  },
63
+ "peerDependencies": {
64
+ "n8n-workflow": "^1.0.0"
65
+ },
63
66
  "dependencies": {
64
- "n8n-workflow": "^1.0.0",
65
67
  "form-data": "^4.0.4"
66
68
  },
67
69
  "lint-staged": {