Knowledge Base
RAG-enabled document retrieval with vector embeddings and semantic search for intelligent context enrichment.
Enables Retrieval-Augmented Generation (RAG) by connecting document collections to AI agents through semantic search, vector embeddings, and intelligent chunk retrieval for contextual information enhancement.
Configuration
Connections
| Direction | Link Types |
|---|---|
| Incoming | KNOWLEDGEBASE |
| Outgoing | (none) |
Knowledge Base nodes are connected to AI Agents via the KNOWLEDGEBASE link type, enabling seamless context integration through the {{ctx.knowledge_base}} template variable.
RAG Architecture
The Knowledge Base implements a sophisticated retrieval system that enhances agent responses with relevant contextual information:
Vector Embedding Process
- Document Processing - Documents are chunked into manageable segments
- Embedding Generation - Text chunks are converted to high-dimensional vectors
- Index Storage - Vectors are stored with metadata for efficient retrieval
- Query Processing - User queries are embedded using the same model
- Similarity Matching - Cosine similarity identifies relevant chunks
- Context Integration - Retrieved chunks are formatted for agent consumption
Input Parameters
Retrieval Optimization
Score Threshold Guidelines
Fine-tune retrieval quality by adjusting the similarity threshold:
| Threshold | Use Case | Result Quality | Result Quantity |
|---|---|---|---|
| 0.95+ | High-precision factual queries | Excellent | Very few |
| 0.8-0.95 | Balanced retrieval (recommended) | High | Moderate |
| 0.6-0.8 | Exploratory or broad topics | Good | Many |
| 0.5-0.6 | Fallback for sparse content | Variable | Maximum |
Chunk Limit Optimization
Balance context richness with token efficiency:
| Limit | Context Size | Token Usage | Best For |
|---|---|---|---|
| 3-5 | Focused | Low | Specific questions |
| 5-8 | Comprehensive | Medium | General inquiries |
| 8-12 | Extensive | High | Complex analysis |
| 12+ | Maximum | Very High | Research tasks |
Token Management
Higher chunk limits increase context quality but may exceed model token limits. Monitor total context size including conversation history and system prompts.
Configuration Examples
Integration Workflow
Agent-Knowledge Base Connection
Context Integration Process
- Query Analysis - User input is analyzed and embedded using vector models
- Vector Search - Similarity search identifies relevant document chunks
- Score Filtering - Chunks below threshold are excluded based on relevance
- Context Assembly - Retrieved chunks are formatted and concatenated
- Template Injection - Context is injected into
{{ctx.knowledge_base}}variable - Agent Processing - Agent uses context for informed responses
- Tool Enhancement - Agent can use additional tools to process, validate, or enhance the retrieved knowledge
Advanced RAG Implementation Patterns
Semantic Search Optimization Strategies
Enhance retrieval quality through advanced semantic search techniques:
Multi-Knowledge Base Orchestration
Coordinate multiple knowledge bases for comprehensive context coverage:
Adaptive Retrieval Configuration
Dynamic threshold and limit adjustment based on query characteristics:
Query Complexity-Based Adaptation:
{
"kbId": "adaptive-knowledge-base",
"limit": "{{ctx.query_length > 50 ? 8 : 5}}",
"scoreThreshold": "{{ctx.query_complexity >= 0.8 ? 0.9 : 0.75}}"
}Domain-Specific Optimization:
{
"kbId": "{{ctx.domain === 'legal' ? 'legal-kb' : 'general-kb'}}",
"limit": "{{ctx.domain === 'legal' ? 4 : 6}}",
"scoreThreshold": "{{ctx.domain === 'legal' ? 0.95 : 0.75}}"
}RAG-Tool Integration Patterns
Combine knowledge retrieval with tool execution for enhanced capabilities:
Performance Optimization
Content Optimization
Document Structure
- Use clear headings and structured formatting
- Include relevant keywords and synonyms
- Maintain consistent terminology across documents
- Structure content in logical, self-contained chunks
Retrieval Tuning
- Embedding Quality: Use domain-specific embedding models when available
- Chunk Overlap: Implement overlapping chunks for continuity
- Metadata Filtering: Use document metadata for pre-filtering
- Index Optimization: Regular reindexing for updated content
Monitoring Metrics
Track these performance indicators:
- Retrieval Rate: Percentage of queries returning results
- Relevance Score Distribution: Average similarity scores
- Context Usage: How often retrieved context influences responses
- Response Quality: User satisfaction with KB-enhanced responses
Troubleshooting
Common Issues
No Results Retrieved
- Lower the
scoreThresholdto increase coverage - Verify knowledge base contains relevant content
- Check query embedding compatibility
Irrelevant Results
- Increase
scoreThresholdfor better precision - Review document chunking strategy
- Improve document structure and keyword usage
Token Limit Exceeded
- Reduce
limitto fewer chunks - Optimize chunk sizes in knowledge base
- Implement context compression techniques
Quality Assessment
Evaluating Retrieval Quality:
- Manual review of retrieved chunks for sample queries
- A/B testing with different threshold values
- User feedback on response relevance
- Automated similarity scoring validation
Best Practices
Content Curation
- Regularly update knowledge base content
- Remove outdated or contradictory information
- Maintain consistent formatting and style
- Use clear, descriptive document titles
Security Considerations
- Ensure knowledge base content is appropriate for all users
- Implement access controls for sensitive information
- Regular audit of knowledge base contents
- Monitor for potential information leakage
Scalability
- Design knowledge bases with growth in mind
- Implement efficient indexing strategies
- Consider load balancing for high-traffic scenarios
- Plan for content versioning and updates
Related Concepts
Within AI & Knowledge Ecosystem
- AI Agent - Core agent architecture that consumes knowledge base context via template variables
- AI Sub-Agent - Multi-agent orchestration with specialized knowledge distribution
- AI & Knowledge Overview - Ecosystem architecture and RAG integration strategies
Supporting Tools
- File Storage Nodes - Document processing and content management
- HTTP Request Nodes - Real-time data enhancement for retrieved context
- JavaScript Nodes - Custom logic for knowledge processing and validation
Next Steps:
- Core Integration: AI Agent for implementing knowledge-enhanced agents
- Multi-Agent RAG: AI Sub-Agent for distributed knowledge architectures
- Ecosystem Planning: AI & Knowledge Overview for comprehensive workflow design