Overview
Twig AI offers three distinct RAG (Retrieval-Augmented Generation) strategies, each optimized for different use cases and performance requirements.
Strategy Comparison
Redwood
~1-2 sec
❌ No
Direct vector search
❌ No
Clear, simple questions
Cedar
~2-3 sec
✅ Context-aware
Memory-enhanced search
❌ No
Conversational queries
Cypress
~3-4 sec
✅ Advanced
Tier-based + expansion
✅ Yes
Complex, high-accuracy needs
Feature Matrix
Vector Search
✅
✅
✅
Chunking
✅
✅
✅
Memory
✅
✅
✅
Privacy Controls
✅
✅
✅
Memory-Enhanced Prompt
❌
✅
✅
Context-Aware Query Rewriting
❌
✅
✅
Vector Retrieval Optimization
❌
❌
✅
Tier-Based Source Retrieval
❌
❌
✅
Automatic Reranking
❌
❌
✅
Higher Retrieval Volume
❌
❌
✅
Query Expansion
❌
❌
✅
Redwood Strategy

Overview
The simplest and fastest RAG approach. Uses the original user query directly for vector search without any prompt rewriting.
How It Works
User asks a question
Original query is converted to embedding
Vector database returns top matching documents
Context is built from retrieved documents
LLM generates response with context
Performance
Speed: ~1-2 seconds
Token Usage: Minimal (single LLM call)
Cost: Lowest
When to Use Redwood
✅ Use when:
Questions are clear and well-formed
No ambiguity in user queries
Speed is the top priority
Simple, direct questions
High query volume with cost sensitivity
❌ Avoid when:
Questions are ambiguous or context-dependent
Follow-up questions that reference previous context
Complex or multi-part queries
Highest accuracy is critical
Example Use Cases
FAQ chatbots
Simple help desk queries
Product information lookup
Quick reference tools
Cedar Strategy

Overview
Enhances retrieval by rewriting the user's query based on conversation context and memory before searching the vector database.
How It Works
User asks a question
System analyzes conversation history (memory)
Query is rewritten to be more explicit and searchable
Rewritten query is used for vector search
Context is built from retrieved documents
LLM generates response with full context
Performance
Speed: ~2-3 seconds
Token Usage: Moderate (additional rewriting call)
Cost: Medium
When to Use Cedar
✅ Use when:
Conversational queries are common
Questions reference previous context
Users ask follow-up questions
Ambiguous phrasing is frequent
Balance of speed and accuracy needed
❌ Avoid when:
Maximum speed is required
Queries are always self-contained
Budget is extremely tight
Ultra-high accuracy is critical
Example Use Cases
Customer support chatbots
Interactive help systems
Multi-turn conversations
General Q&A assistants
Cypress Strategy

Overview
The most sophisticated RAG strategy combining query expansion, tier-based retrieval, and automatic reranking for maximum accuracy.
How It Works
User asks a question
Query is enhanced with memory (if available)
Query Expansion: Prompt is rewritten to include synonyms, related terms, and alternative phrasings
Tier 1 Retrieval: Search high-priority data sources (topK=50)
Tier 2 Retrieval: Search supplementary data sources (topK=50)
Reranking: All results are reranked using
bge-reranker-v2-m3modelTop 10 most relevant documents are selected
Context is built with highest quality results
Final query rewriting for LLM (context-aware)
LLM generates response with optimized context
Unique Features
Query Expansion for Retrieval:
Tier-Based Retrieval:
Tier 1: Official documentation, primary knowledge bases
Tier 2: Community content, secondary sources
Both tiers treated equally in reranking
Automatic Reranking:
Cross-encoder model (more accurate than vector similarity)
Considers full query-document relationship
Improves precision significantly
Performance
Speed: ~3-4 seconds
Token Usage: Higher (multiple rewriting + reranking)
Cost: Highest
When to Use Cypress
✅ Use when:
Accuracy is the top priority
Questions involve diverse terminology
Multiple data source tiers exist
Query ambiguity is common
Latency trade-off is acceptable
High-stakes decisions depend on answers
❌ Avoid when:
Speed is critical
Budget is constrained
Simple, clear questions only
Low query volume
Example Use Cases
Medical or legal Q&A (high accuracy required)
Complex technical documentation
Multi-domain knowledge bases
Enterprise knowledge management
Compliance-sensitive applications
Performance Comparison
Latency
Accuracy
Cost
Choosing the Right Strategy
Decision Tree
By Use Case
FAQ Bot
Redwood
Clear questions, speed matters
Customer Support Chat
Cedar
Conversational, follow-ups common
Medical Q&A
Cypress
Accuracy is critical
Legal Research
Cypress
High-stakes, must be accurate
Product Documentation
Cedar
Balance of speed and accuracy
Internal Wiki
Cedar
Conversational queries
API Reference
Redwood
Technical, clear queries
Troubleshooting Guide
Cedar
Multi-step, contextual
Compliance Questions
Cypress
Cannot afford mistakes
Switching Strategies
You can change an agent's strategy at any time:
Open agent settings
Navigate to RAG Strategy
Select new strategy
Save changes
Test in Playground
Note: Changes take effect immediately. Test thoroughly before deploying to production.
A/B Testing Strategies
To compare strategies objectively:
Duplicate your agent
Assign different strategies to each copy
Use the same test questions
Compare responses, speed, and citations
Check analytics for quality metrics
Next Steps
Last updated

