n8n-nodes-ollama-reranker
v1.4.0
Published
Ollama Reranker for n8n - VL Classifier integration + Auto-detect + Dynamic model loading (Vector Store provider + workflow node)
Downloads
137
Maintainers
Readme
n8n-nodes-ollama-reranker
Advanced Reranker Provider for n8n - Supporting Ollama-compatible APIs, Custom Rerank servers, and VL Classifiers.
⚠️ Important Note: Sorry folks, Ollama doesn't natively support reranker models! We're developing our own solution to bring powerful reranking capabilities to n8n. This package works with Ollama-compatible APIs that implement reranking through prompt-based scoring, custom rerank endpoints, and now Vision-Language classification servers.
Features
- 🎯 Integrates seamlessly with n8n Vector Store nodes
- 🚀 Multiple API types: Ollama Generate, Custom Rerank, VL Classifier
- 🤖 Auto-detection of server capabilities
- 🔧 Multiple models supported (BGE Reranker, Qwen3 family)
- 🎨 VL Classification for document complexity analysis (v1.4.0+)
- ⚡ Concurrent processing with configurable batch sizes
- 🔄 Automatic retries with exponential backoff
- 📊 Flexible scoring with threshold and topK parameters
Installation
Via npm (Recommended)
npm install n8n-nodes-ollama-rerankerVia n8n Community Nodes UI
- Go to Settings → Community Nodes
- Select Install
- Enter
n8n-nodes-ollama-reranker - Click Install
From Docker
Add to your n8n Dockerfile:
FROM n8nio/n8n:latest
USER root
RUN cd /usr/local/lib/node_modules/n8n && \
npm install n8n-nodes-ollama-reranker
USER nodePrerequisites
Choose your server type:
Option 1: Ollama (Prompt-based reranking)
- Ollama must be running and accessible
- Pull a reranker model:
# Recommended - BGE Reranker v2-M3
ollama pull bge-reranker-v2-m3
# Or Qwen3 models
ollama pull dengcao/Qwen3-Reranker-4B:Q5_K_MOption 2: Custom Rerank API
Use any service implementing /api/rerank endpoint (like deposium-embeddings-turbov2)
Option 3: VL Classifier Server (NEW in v1.4.0)
Deploy a Vision-Language classifier server with:
/api/status- Server health and capabilities/api/classify- Document complexity classification- Optional
/api/rerank- Direct reranking support
Example: deposium_embeddings-turbov2 with ResNet18 ONNX INT8 model
Usage
Basic Setup
- Add an Ollama Reranker node to your workflow
- Connect it to a Vector Store node (e.g., Pinecone, Qdrant, Supabase)
- Configure:
- API Type: Choose between:
Ollama Generate API- Standard Ollama prompt-basedCustom Rerank API- Direct reranking endpointVL Classifier + Reranker- Vision-Language classificationAuto-Detect- Automatically detect server type
- Model: Select a reranker model
- Top K: Number of documents to return
- Threshold: Minimum relevance score (0-1)
- Base URL: URL to your server
- API Type: Choose between:
VL Classifier Options (v1.4.0+)
When using VL Classifier:
- Enable VL Classification: Use complexity analysis
- Classification Strategy:
Metadata- Add complexity as document metadataFilter- Filter by complexity before rerankingBoth- Combine filtering and metadata
- Filter Complexity: Keep LOW, HIGH, or both complexity documents
Example Workflow
User Query → Vector Store (retrieve 50 docs)
→ Ollama Reranker (rerank to top 10)
→ Continue with top-ranked documentsSupported Configurations
Reranker Models (Ollama/Custom API)
| Model | Size | Speed | Accuracy | Best For |
|-------|------|-------|----------|----------|
| bge-reranker-v2-m3 | ~600MB | ⚡⚡⚡ | ⭐⭐⭐⭐ | General purpose (Recommended) |
| Qwen3-Reranker-0.6B | ~400MB | ⚡⚡⚡⚡ | ⭐⭐⭐ | Low resource environments |
| Qwen3-Reranker-4B | ~2.5GB | ⚡⚡ | ⭐⭐⭐⭐ | Balanced performance |
| Qwen3-Reranker-8B | ~5GB | ⚡ | ⭐⭐⭐⭐⭐ | Maximum accuracy |
VL Classifier Models
| Model | Size | Speed | Use Case |
|-------|------|-------|----------|
| ResNet18-ONNX-INT8 | 11MB | ⚡⚡⚡⚡ | Document complexity classification |
| Custom VL models | Varies | Varies | Vision-Language tasks |
Development
Setup
cd custom-nodes
npm installBuild
npm run buildLint & Format
npm run lint # Check linting
npm run lint:fix # Auto-fix issues
npm run format # Format codeTest
npm testLocal Testing
Use the included docker-compose.yml:
docker-compose up -dAccess n8n at http://localhost:5678 (admin/admin)
Git Hooks
Pre-commit hooks are configured with Husky to:
- Run lint-staged (ESLint + Prettier)
- Run qlty quality checks
Publishing
Publishing to npm is automated via GitHub Actions:
- Update version in
custom-nodes/package.json - Commit changes
- Create and push a tag:
git tag v1.0.1
git push origin v1.0.1GitHub Actions will automatically:
- Build the package
- Run tests
- Publish to npm
Project Structure
n8n_reranker/
├── custom-nodes/ # Main npm package
│ ├── src/
│ │ └── nodes/
│ │ └── OllamaReranker/
│ │ ├── OllamaReranker.node.ts
│ │ ├── OllamaReranker.node.test.ts
│ │ └── ollama.svg
│ ├── .eslintrc.js
│ ├── .husky/ # Git hooks
│ ├── .prettierrc.json
│ ├── package.json # Main package.json
│ ├── tsconfig.json
│ └── jest.config.js
├── Dockerfile # For local development
├── docker-compose.yml # Complete dev environment
└── .github/
└── workflows/
└── npm-publish.yml # Automated publishingHow It Works
The Reranking Challenge
Ollama doesn't natively support reranker models that output relevance scores. Instead, we implement three approaches:
- Prompt-based Scoring: Use Ollama's
/api/generatewith specially formatted prompts - Custom Rerank API: Connect to servers with dedicated
/api/rerankendpoints - VL Classification: Pre-process with Vision-Language models for intelligent filtering
API Type Detection
The node automatically detects your server type by checking:
/api/status→ VL Classifier server/api/tags→ Ollama server/api/rerank→ Custom rerank server- Fallback → Ollama (default)
Architecture
This node implements two n8n patterns:
Provider Node (OllamaReranker)
- No inputs - Provider nodes don't receive workflow data
- AiReranker output - Connects to Vector Store nodes
- supplyData() - Returns a reranker provider object
- Standard interfaces:
rerank()- Main reranking methodcompressDocuments()- LangChain compatibility
Workflow Node (OllamaRerankerWorkflow)
- Main inputs/outputs - Processes workflow items
- execute() - Transforms documents in the workflow
- usableAsTool - Can be used as AI Agent tool
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting
- Submit a pull request
Security
- ✅ No vulnerabilities in dependencies
- ✅ form-data updated to 4.0.4 (fixes CVE-2025-7783)
- ✅ Code quality validated with qlty
License
MIT © Gabriel BRUMENT
Links
Support
For issues and feature requests, please use the GitHub Issues.
