Skip to content

Platformatory/rag_app_debugging

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Mini RAG (Retrieval-Augmented Generation) App

Welcome! This is a hands-on interview task to assess your ability to build and debug a basic Retrieval-Augmented Generation (RAG) system using Python, FAISS, and language model embeddings.

🧠 Objective

You are given a minimal RAG system that allows users to query a small set of technical documents. The system uses a FastAPI backend with a FAISS index and sentence-transformer-based embeddings.

πŸ”§ However, the current system is returning irrelevant or inaccurate results. Your task is to identify and fix the retrieval logic to improve the quality of answers.


πŸ“‚ Project Structure


rag_app_debugging/
β”‚
β”œβ”€β”€ app.py              # FastAPI app with /ask endpoint
β”œβ”€β”€ rag_utils.py        # FAISS + embedding logic (this is your main focus)
β”œβ”€β”€ client.py           # Sends test query to the app
β”œβ”€β”€ data/
β”‚   └── docs.txt        # Text corpus (technical content)
β”œβ”€β”€ requirements.txt    # Python dependencies
└── README.md           # This file


πŸ› οΈ Setup Instructions

  1. Clone the project and create a virtual environment

    python3 -m venv .venv
    source .venv/bin/activate  # or `.venv\Scripts\activate` on Windows
  2. Install dependencies

    pip install -r requirements.txt
  3. Start the FastAPI server

    uvicorn app:app --reload
  4. Run the client to send a query

    python client.py

🎯 Your Task

The current system does a basic embedding + FAISS L2 search. You need to improve the context retrieval quality using any of the following techniques (feel free to implement one or more):

Suggested Improvements

  • πŸ”Ή Improve document chunking (e.g., use sentence/paragraph-based or sliding window)
  • πŸ”Ή Replace IndexFlatL2 with IndexFlatIP (cosine similarity)
  • πŸ”Ή Normalize embeddings before indexing/search
  • πŸ”Ή Return top-k matches (k > 1) and optionally re-rank them
  • πŸ”Ή Use a better embedding model (e.g., all-MiniLM-L12-v2, intfloat/e5-base-v2)
  • πŸ”Ή Add cross-encoder re-ranking if time permits

βœ… Success Criteria

  • The /ask endpoint returns relevant and meaningful results for typical technical queries.
  • You explain the changes you made and why they improve the results.
  • Your code is clean, modular, and well-commented.

πŸ§ͺ Example Queries

Try asking the system:

  • "What is the name of the war operation by Israel?"
  • "What is the reason for the war?"
  • "What is President Trump's stance on the war?"
  • "What could end the war?"

🀝 Good Luck!

We’re not expecting a production-grade solution β€” just a thoughtful and focused approach to improving retrieval quality with clear reasoning. Feel free to leave comments in the code or discuss trade-offs.

If you have any questions during the session, just ask.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages