WhoBuilt

Building Production-Ready RAG Applications

Nov 15, 2023· 19 min· 412K views·Watch on YouTube

Speaker

Jerry Liu, co-founder and CEO of LlamaIndex, explains how to build production-ready RAG applications at an AI Engineer talk.

Why basic RAG falls short

A basic RAG system ingests data, retrieves relevant material, and uses an LLM to synthesize an answer. Liu says production systems often struggle with low retrieval precision or recall, outdated information, and LLM issues such as hallucinations and irrelevant responses.

Measure quality before optimizing

Liu recommends defining a task-specific benchmark before trying new techniques. Evaluate both the end-to-end answer and individual components: retrieval can use metrics such as hit rate, MRR, and NDCG, while synthesis can be assessed against human feedback, reference answers, or synthetic examples.

Improve the retrieval basics

Start with better parsing, chunk-size tuning, hybrid search, and metadata filters. Liu notes that more retrieved tokens or reranking do not always improve answers, partly because models can miss relevant information in the middle of a long context. For an SEC 10-K question about 2021 risk factors, combining a year filter with semantic search can avoid results from other years.

Retrieve small pieces, then expand context

Small-to-big retrieval embeds granular text, such as sentences, then expands the retrieved passage for answer generation. This can make relevant details easier to find while giving the LLM more context to synthesize. Liu also describes embedding a summary or questions a chunk answers instead of embedding the full chunk.

Extend RAG with agents and fine-tuning

For questions requiring multiple reasoning steps, Liu describes treating documents as tools that can summarize or answer questions, then retrieving among those tools before using them. He also discusses fine-tuning embeddings with synthetic queries and distilling capabilities from a larger model such as GPT-4 into a smaller one to improve synthesis and structured outputs.

Takeaways

  • Build a task-specific evaluation set before changing a RAG pipeline.
  • Measure retrieval separately from end-to-end answer quality to locate the source of errors.
  • Tune chunk size and test metadata filters; adding more context does not guarantee better answers.
  • Try retrieving small, precise chunks and expanding context for synthesis.
  • Use agents or fine-tuning when measured needs justify their added complexity, latency, or cost.

Mentioned in this talk

Search inside this talk

What was claimed 7

Related talks