Last Updated: May 1, 2025
Data Ingestion
SimpleDirectoryReader('data/').load_data()Load all supported files from directory
LlamaParse (premium)Parse complex PDFs — tables, charts, handwriting. Better than open-source.
documents = reader.load_data()Returns list of Document nodes
Settings.chunk_size = 1024Token count per chunk — smaller = more precise, larger = more context
Settings.chunk_overlap = 200Overlap between chunks — preserves context at boundaries
Indexing & Storage
| Item | Description |
|---|---|
VectorStoreIndex | Default — creates embeddings, stores in vector DB. Best for semantic search. |
SummaryIndex | Stores summaries — good for document-level Q&A, not granular retrieval. |
KeywordTableIndex | Keyword extraction + lookup — good for definitional queries. |
KnowledgeGraphIndex | Entity relationship extraction — graph-based reasoning. |
TreeIndex | Hierarchical summarization — answer broad questions about large docs. |
Query Engines
| Item | Description |
|---|---|
RetrieverQueryEngine | Standard: retrieve → synthesize → answer. Works for most use cases. |
SubQuestionQueryEngine | Decompose query into sub-questions → answer each → combine. For complex queries. |
RouterQueryEngine | Route query to best index/retriever — summary vs vector vs keyword. |
TransformQueryEngine | Modify query before retrieval: HyDE (generate hypothetical answer → search with it). |
FLARE Query Engine | Retrieve incrementally — use LLM to predict next sentence, retrieve to verify. |
Advanced Retrieval
| Item | Description |
|---|---|
Auto-Merging Retriever | Hierarchical chunks — retrieve small chunks, auto-merge into larger parent chunks. |
Sentence Window Retriever | Retrieve by sentence, expand window for context before sending to LLM. |
Re-ranking | Cohere Rerank or cross-encoder — re-rank top-K results for precision. |
Hybrid Search | Combine sparse (BM25) + dense (embeddings) — better for keyword-heavy queries. |
Recursive Retrieval | Retrieve → use as query for deeper retrieval — multi-hop reasoning. |
Pro Tip: Start with the default ingestion pipeline, then iterate on chunk size and retrieval strategy. The biggest gains come from chunking strategy and retrieval method — not from the LLM.