From RAG to fabric: Lessons learned from building real-world RAGs at GenAIIC – Part 2

Aude Genevay15 Nov 2024

Problem

A Q&A assistant often has to cover more than text: reports and FAQs sit next to product tables, time series and diagrams. One text-only RAG pipeline fails on this mix. It retrieves from the wrong source, and an LLM that reads a big table as raw text computes wrong numbers.

Example from the article: an oil and gas analyst asks "What well produced the most oil in June 2024?" over a table of daily production. The LLM must compute monthly sums and take the maximum, which it cannot do reliably from a table pasted into the prompt.

Solution in brief

A small LLM router reads the query and picks a data source. For large tables, the LLM writes Pandas or SQL code and the application runs it. For images, use a multimodal embedding model, or caption images with a multimodal LLM and embed the captions.

Questions this case answers
  • How to answer questions over a knowledge base that mixes free text, large tables and images when each type needs a different retrieval or computation path
  • How to get reliable numeric answers from an LLM over tabular data that is too large or too quantitative to place in the prompt
  • How to retrieve images from text or image queries when the index must support either coarse similarity or fine-grained detail
  • How to build a Q&A assistant over a mix of documents, tables and images when one retrieval pipeline cannot serve them all?

Tools and methods

  • LLM router — one cheap LLM call picks the data source from short source descriptions and examples.
  • Text-to-Pandas / text-to-SQL — the LLM writes code for analysis of tables, which the application executes.
  • Multimodal embeddings — images and text share one vector space for direct similarity search.
  • Image captioning with a multimodal LLM — captions are embedded as text and the image is stored with them.
Continue reading — it's free

Google or a one-time email code. No password.