Retrieval QA Agent
The Retrieval QA Agent combines document retrieval with question answering capabilities. It efficiently searches through a knowledge base to find relevant information and generates accurate, context-aware responses while maintaining source traceability.

Retrieval QA Agent workflow and architecture
Configuration Parameters
Required Input Parameters
- input: The question or query to be answered
- retriever: Document retrieval configuration
- type: Vector store type (e.g., 'faiss', 'pinecone', 'elasticsearch')
- search_type: Search methodology ('similarity', 'mmr', 'hybrid')
- top_k: Number of documents to retrieve
Optional Configuration
- llm: Language model configuration (default: GPT-4)
- model_name: Name of the language model
- temperature: Response creativity (0-1)
- max_tokens: Maximum response length
- memory: Memory configuration for conversation context
- type: Memory type ('buffer', 'summary', 'conversation')
- max_tokens: Memory context window size
- persistence: Memory storage configuration
- return_source_documents: Include source documents in output (default: false)
Output Format
{ "text": string, // The generated answer "source_documents": [ // Optional, if return_source_documents is true { "content": string, "metadata": { "source": string, "page": number, "relevance_score": number } } ], "metadata": { "retrieval_time": number, "processing_time": number, "confidence_score": number } }
Features
- Semantic search capabilities
- Multi-document reasoning
- Context-aware responses
- Source attribution
- Conversation memory
- Configurable retrieval strategies
- Answer confidence scoring
- Document relevance ranking
Note: The quality of responses depends significantly on the quality and organization of your document store. Regular maintenance and updates of the knowledge base are recommended for optimal performance.
Tip: Use the MMR (Maximal Marginal Relevance) search type when you need to balance relevance with diversity in retrieved documents. Adjust the top_k parameter based on your specific use case and required response comprehensiveness.
Example Usage
const retrievalQA = new RetrievalQA({ llm: { model_name: "gpt-4", temperature: 0.7, max_tokens: 500 }, retriever: { type: "faiss", search_type: "mmr", top_k: 5 }, memory: { type: "conversation", max_tokens: 2000 }, return_source_documents: true }); const response = await retrievalQA.query({ input: "What are the key features of our product?", });