RAG
Retrieval-Augmented Generation — from knowledge base setup to production pipelines.
Where RAG lives in the framework
RAG is intentionally split across three modules so each layer can evolve independently:
| Layer | Module | Provides |
|---|---|---|
| Primitives | tnsai-core (com.tnsai.knowledge, com.tnsai.memory.advanced) | KnowledgeBase, Document, EmbeddingFunction, BM25Index, VectorMemoryStore, HybridMemoryRetriever |
| Strategies | tnsai-intelligence (com.tnsai.intelligence.rag) | RAGPipeline, RAGStrategy (Vector, Keyword, Hybrid), RetrievedDocument, RAGContext |
| Service / HTTP | tnsai-server (com.tnsai.server.rag) | RagService, FileIndexer, CodeChunker, HybridRetriever, retrieval streams |
If you are building an embedded agent, you typically use Core primitives + Intelligence strategies. If you are running TnsAI.Server, you also get the Service layer with HTTP endpoints, indexing, and stream-based retrieval.
Pages
- Knowledge Base — Create, populate, query a
KnowledgeBase. - Strategies — Swap retrieval algorithms via the RAG SPI.
- Pipeline — Chunk storage, embedding, hybrid search, production deployment.
Advanced Intelligence Patterns
Advanced cognitive capabilities in TnsAI.Intelligence for reasoning, memory consolidation, output validation, and iterative refinement.
Knowledge Base & RAG
TnsAI provides a built-in Retrieval-Augmented Generation (RAG) system through the KnowledgeBase interface, Document model, and @KnowledgeSource annotation. Agents can retrieve relevant context from vector databases, files, URLs, or in-memory stores before making LLM calls.