Introduction
Knowledge Filters
Knowledge filters allow you to restrict and refine searches within your knowledge base using metadata such as user IDs, document types, years, and more. This feature is especially useful when you have a large collection of documents and want to retrieve information relevant to specific users or contexts.
Why Use Knowledge Filters?
- Personalization: Retrieve information for a specific user or group.
- Security: Restrict access to sensitive documents.
- Efficiency: Reduce noise by narrowing down search results.
How Do Knowledge Filters Work?
When you load documents into your knowledge base, you can attach metadata (like user ID, document type, year, etc.). Later, when querying, you can specify filters to only search documents matching certain criteria.
Example Metadata:
Ways to Apply Filters
You can apply knowledge filters in two main ways:
- Manual Filters: Explicitly pass filters when querying.
- Agentic Filters: Let the Agent automatically extract filters from your query.
Tip: You can combine multiple filters for more precise results!
Filters in Traditional RAG vs. Agentic RAG
When configuring your Agent it is important to choose the right approach for your use case. There are two broad approaches to RAG with Agno agents: traditional RAG and agentic RAG. With a traditional RAG approach you set add_references=True
to ensure that references are included in the system message sent to the LLM. For Agentic RAG, you set search_knowledge=True
to leverage the agent’s ability search the knowledge base directly.
Example:
Remember to use only one of these configurations at a time, setting the other to false. By default, search_knowledge=True
is preferred as it offers a more dynamic and interactive experience.
Checkout an example here of how to set up knowledge filters in a Traditional RAG system
Best Practices
- Make your prompts descriptive (e.g., include user names, document types, years).
- Use agentic filtering for interactive applications or chatbots.
Manual vs. Agentic Filtering
Manual Filtering | Agentic Filtering |
---|---|
Explicit filters in code | Filters inferred from query text |
Full control | More natural, less code |
Good for automation | Good for user-facing apps |
🚦 Currently, knowledge filtering is supported on the following vector databases:
- Qdrant
- LanceDB
- PgVector
- MongoDB
- Pinecone
- Weaviate
- ChromaDB
- Milvus