ChatGPT SearchOct 4, 2026
Data as of Oct 13, 2026A topic in LLM Agent Frameworks and Tooling.
Reviewed by Dimitry Apollonsky
AI summary
LlamaIndex holds a narrow lead over LangChain for built-in query transformation and sophisticated indexing tailored to complex retrieval pipelines. LangChain closely competes when teams require flexible architectures, extensive integrations, and broader multi-step workflows.
plug-and-play query rewriting and deep indexing for complex data structures
flexible, modular architectures supporting extensive integrations and advanced reasoning workflows
orchestrating cyclical, agentic retrieval flows alongside core framework components
programmatic optimization of retrieval prompts and language model pipelines
customizable document search pipelines with native retrieval and ranking modules
Mentioned in · Jul 5 – Oct 13, 2026
ChatGPT SearchOct 4, 2026
The strongest production architecture is adaptive multi-stage retrieval, not one “advanced” technique.
Recommended agent pipeline:
Query → classify → rewrite/decompose if needed → hybrid retrieve → RRF → rerank → contextual/parent expansion → sufficiency check → retrieve again if needed → generate + citations
For most systems, I'd implement hybrid + contextual retrieval + reranking + adaptive decomposition first; add GraphRAG only when your evaluation shows genuine multi-hop/entity-relation failures.
Google AI ModeOct 4, 2026
Moving beyond naive "retrieve-then-generate" pipelines, production-grade LLM agent frameworks utilize Agentic RAG and advanced orchestration strategies . Instead of a single blind lookup, retrieval is treated as a dynamic, iterative tool loop managed by the agent's planner.[](https://medium.com/@basukori8463/rag-systems-the-complete-zero-to-hero-guide-2025-edition-a92d0a529925)[[2](https://medium.com/@noumannawaz/rag-in-2026-why-we-finally-killed-the-retrieve-then-generate-monolith-dffad4cadc29)](https://medium.com/@noumannawaz/rag-in-2026-why-we-finally-killed-the-retrieve-then-generate-monolith-dffad4cadc29)
The most effective advanced retrieval strategies to implement in an agent framework include:
ChatGPT SearchOct 13, 2026
For advanced RAG (retrieval-augmented generation) techniques like sentence-window retrieval, my top recommendation is LlamaIndex. It is particularly well suited to detail-oriented questions where retrieving the exact sentence matters, but the language model also needs the surrounding context to answer accurately.
The key is to distinguish between frameworks that provide specialized retrieval components out of the box and frameworks that give you more flexibility to build a custom retrieval pipeline.
(Best overall for sentence-window retrieval)
LlamaIndex provides a dedicated SentenceWindowNodeParser and MetadataReplacementNodePostProcessor. It embeds individual sentences for precise matching, then expands retrieved sentences to include neighboring context before generation.
Google AI ModeOct 13, 2026
When handling specific, detail-oriented questions using advanced retrieval techniques like sentence-window retrieval (where you embed individual sentences for precise matching, but feed a wider surrounding context window to the LLM), choosing the right framework comes down to data-centric indexing versus general-purpose orchestration.[](https://www.tredence.com/blog/top-rag-frameworks)
The top frameworks best suited for this technique are ranked and compared below:
If you'd like, let me know:
I can share a tailored code snippet or architectural layout for setting up your sentence-window pipeline.
I need a RAG framework that handles query re-writing out of the box. Which options have the best built-in tools for this?
ChatGPT SearchOct 3, 2026
If your primary goal is query rewriting/transformation for RAG retrieval, I’d put LlamaIndex at the top of the shortlist.
| Framework | Built-in query transformation | Breadth | Best fit |
|---|---|---|---|
| LlamaIndex | Query rewriting, HyDE, sub-question decomposition, routing, query fusion | ⭐⭐⭐⭐⭐ | Retrieval-heavy RAG |
Google AI ModeOct 3, 2026
My RAG system struggles with very specific, detail-oriented questions. What's the best framework for advanced retrieval strategies like sentence-window retrieval?
To help narrow down what fits your architecture best, tell me:
I can provide a reference architecture implementation or code pattern tailored to your stack.
Best for: Technical documentation, lengthy PDFs, policy documents, research papers, and questions about specific facts or exceptions.
Best for flexible, customized RAG pipelines
LangChain is a strong option when retrieval is one part of a larger application involving agents, tools, custom retrievers, and multiple data sources. You can implement sentence-window retrieval with custom indexing and retrieval logic, although the exact LlamaIndex workflow is not its primary out-of-the-box approach.
Best for: Agentic RAG, complex application workflows, and teams already using the LangChain ecosystem.
Best for explicit, production-oriented pipelines
Haystack uses modular components connected into defined pipelines. This makes it attractive when you want to control document preprocessing, retrieval, reranking, and answer generation as distinct stages. Sentence-window behavior can be implemented through custom components or preprocessing and metadata logic.
Best for: Production search, inspectable pipelines, and systems requiring explicit control over each retrieval stage.
The strongest direct evidence for sentence-window retrieval is LlamaIndex's own implementation and example, which specifically targets more fine-grained retrieval in large documents.
Consider a user asking: “What exception applies to the 30-day retention policy?”
A conventional RAG system might retrieve a large chunk that discusses retention generally, while the exact exception is buried elsewhere in that chunk. Sentence-window retrieval makes the matching sentence the retrieval target, then restores neighboring sentences so the answer retains its meaning.
1. Index individual sentences
Create embeddings for small, precise units of text rather than only large chunks.
2. Retrieve the matching sentence
“The standard retention period is 30 days, except where a legal hold applies.”
3. Expand the context window
Include adjacent sentences explaining legal holds, scope, and related conditions.
4. Generate a grounded answer
Answer the question using the precise match and its surrounding context.
LlamaIndex implements this pattern with its sentence-window parser and metadata replacement postprocessor. Its documentation also describes using a window of neighboring sentences around each retrieved sentence.
For genuinely detail-oriented questions, I would evaluate more than sentence windows alone.
| Technique | What it adds | When to use it |
|---|---|---|
| Sentence-window retrieval | Precise matching plus local context | Exact facts, exceptions, definitions |
| Parent-child retrieval | Searches small child chunks but returns a larger parent section | Long documents with related explanations |
| Hybrid search | Combines semantic vector search and keyword/BM25 search | Exact terminology, IDs, names, clause numbers |
| Reranking | Reorders retrieved passages by relevance to the question | Similar passages or subtle distinctions |
| Metadata filtering | Restricts search by document, date, section, or category | Large, structured knowledge bases |
These techniques are complementary. For example, hybrid retrieval can locate a clause containing a specific identifier, while reranking and sentence-window expansion help select and interpret the relevant passage.
For a system where correctness on specific questions matters more than keeping the implementation minimal, I would start with:
Document ingestion
Parse PDFs, preserve headings, tables and metadata
Fine-grained indexing
Sentence embeddings + parent/section relationships
Hybrid retrieval
Vector similarity + keyword search + metadata filters
Rerank and expand
Rerank candidates, then restore sentence-window or parent context
Grounded answer with citations
Answer from retrieved evidence and identify source passages
Bottom line: Choose LlamaIndex if advanced document retrieval is your primary concern. Choose LangChain if the retrieval system is part of a broader agent application. Choose Haystack if explicit, modular pipelines are a priority.
Whichever you choose, benchmark it on your actual questions using retrieval recall, answer correctness, citation accuracy, latency, and cost. A framework's built-in features are useful, but the quality of document parsing, retrieval configuration, and evaluation will ultimately determine how well it handles fine-grained questions.
| Query expansion, multi-query retrieval, HyDE, query decomposition |
| ⭐⭐⭐⭐ |
| Explicit pipeline architecture |
| LangChain | Multi-query, query rewriting/transformation patterns, retriever composition | ⭐⭐⭐⭐ | General-purpose chains/agents |
| DSPy | General programmable LM modules + optimizers; transformations are more DIY | ⭐⭐⭐ | Learning/optimizing your own rewrite strategy |
LlamaIndex has an explicit query transformation abstraction, rather than requiring you to assemble every technique yourself. Its query-transformation docs cover:
Its docs specifically describe rewriting as a modular transformation that can feed ensemble/fusion retrieval.
For example, conceptually your pipeline becomes:
User query
↓
Query Transform
├── rewrite #1
├── rewrite #2
├── rewrite #3
└── original
↓
Multi-query retrieval
↓
Fusion/rerank
↓
Context
↓
LLMHaystack has become particularly clean here. Its current QueryExpander generates semantically similar queries and plugs directly into MultiQueryTextRetriever or MultiQueryEmbeddingRetriever.
It also documents HyDE and query decomposition as advanced RAG techniques.
So if you want a strongly componentized pipeline like:
QueryExpander
→ MultiQueryEmbeddingRetriever
→ ranker
→ generatorHaystack may actually be the cleaner engineering choice.
DSPy is interesting if your real objective is not merely "rewrite this query" but:
"Learn which query transformation strategy and prompt works best for my retrieval dataset."
DSPy lets you define the transformation as a module/signature and optimize the resulting program against a metric. Its optimizers include GEPA, MIPROv2, etc.
That's potentially more powerful than a fixed collection of query-rewriting utilities, but it requires more design work.
If you're starting from scratch: LlamaIndex.
If you want explicit, production-oriented pipeline components: Haystack.
If you have an evaluation dataset and want the system to learn/optimize the rewriting behavior: DSPy.
If you're already heavily invested in LangChain: there's little reason to migrate solely for query rewriting.
One important distinction: query rewriting isn't automatically beneficial. For many RAG systems, generating 3–5 queries increases recall but also increases retrieval cost and can introduce query drift. I'd evaluate original query vs. rewrite vs. multi-query + fusion on your actual retrieval benchmark rather than assuming more transformations = better retrieval.
If you tell me whether you're using vector search, BM25/hybrid search, or both, I can give you a concrete architecture and benchmark setup for query rewriting.
LlamaIndex provides the best out-of-the-box, specialized query transformation modules specifically built for RAG architecture, whereas LangChain requires you to compose them manually using lower-level primitives via LangChain Expression Language (LCEL).[](https://developers.llamaindex.ai/python/framework/optimizing/advanced_retrieval/query_transformations/)[[2](https://www.youtube.com/watch?v=xEgUC4bd_qI&t=972)](https://www.youtube.com/watch?v=xEgUC4bd_qI&t=972)
LlamaIndex treats query transformations as native first-class components (supporting both single-step and multi-step pipelines out of the box), while LangChain offers maximum flexibility and explicit control if you prefer writing custom prompts and composition chains.[](https://www.youtube.com/watch?v=xEgUC4bd_qI&t=972)[[2](https://www.youtube.com/watch?v=xEgUC4bd_qI&t=972)](https://developers.llamaindex.ai/python/framework/optimizing/advanced_retrieval/query_transformations/)
| Feature / Attribute | LlamaIndex | LangChain |
|---|---|---|
| Abstraction Level | High-level, purpose-built RAG modules | Low-level, highly explicit composition blocks |
| HyDE Support | Native HyDEQueryTransform module | Manual prompt/chain implementation required |
| Multi-Step & Decomposition | Built-in sequential query transformation engines |
HyDEQueryTransform to automatically prompt an LLM to generate a fake answer to the user's query, then embeds that synthetic document to match the document embedding space rather than the short query space.[](https://developers.llamaindex.ai/python/framework/optimizing/advanced_retrieval/query_transformations/)If you can share which specific rewrite strategy you want to use (such as HyDE, Multi-Query expansion, or Step-Back questioning) and your preferred framework ecosystem , I can provide the exact boilerplate implementation code for your pipeline.
| Requires custom LCEL sequential routing graphs |
| Setup Complexity | Minimal (plugs straight into retrievers/engines) | Higher (requires custom runnable configuration) |