This project builds a Retrieval-Augmented Generation (RAG) system that can answer multi-hop questions. It reads a set of documents, converts them into embeddings, stores them in FAISS, retrieves relevant chunks for a query, and generates final answers using an LLM.
It can answer questions that require combining multiple documents, for example:
- “Which airline had the highest cancellations and what caused them?”
- “Which carrier improved on-time performance despite rising delays?”
- Reads raw text files
- Splits them into clean chunks
- Prepares text for embedding
- Uses OpenAI embedding model to convert text into numeric vectors
- Build a FAISS index
- Save metadata (chunk text + source file)
- For a given question, retrieve top K relevant text chunks
- Combine information from multiple sources
- Send to an LLM with a structured prompt
- The LLM performs reasoning using only retrieved data
- LLM outputs a clear answer
- Supports complex multi-step or cross-document questions
- Python
- FAISS (vector search)
- OpenAI Embeddings (text embedding)
- OpenAI GPT Models (answer generation)
- Text preprocessing tools (NLTK / regex)
The system outputs:
- Retrieved relevant text chunks
- Final combined answer produced by the LLM
- Uses multi-hop reasoning to connect facts
- No hallucination — answers come only from retrieved context
Example output:
Answer:
Spirit Airlines had the most cancellations in 2024 due to fleet grounding
and operational disruptions. Alaska Airlines and Frontier followed due to
weather-related issues.