This project is a question-answering application that uses a Retrieval Augmented Generation (RAG) pipeline to answer questions based on a collection of PDF documents. The application is built with FastAPI and uses a FAISS vector store for efficient retrieval.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
-
Clone the repository:
git clone https://github.com/hadywalied/AskAttentionAI cd AskAttentionAI -
Create a
.envfile:Copy the
.env.examplefile to a new file named.envand fill in your environment variables:cp .env.example .env
LLM_PROVIDER: The name of the provider (e.g.,local,openai,huggingface).LLM_ENDPOINT: The URL of the LLM endpoint (for providers that have one, like a local LLM).LLM_API_KEY: The API key for the LLM provider.LLM_MODEL_ID: The ID of the model to use (for providers that have multiple models, like Hugging Face).VECTOR_DB_DIR: The directory where the vector store is saved.DATA_DIR: The directory where your PDF files are located.
-
Build and run the application:
docker-compose up --build
The application will be available at
http://localhost:8000.
To ask a question, send a POST request to the /ask endpoint with a JSON payload containing the question.
Example using curl:
curl -X POST "http://localhost:8000/ask" -H "Content-Type: application/json" -d '{
"question": "What is attention?"
}'sample output:
{
"answer": " Attention is a mechanism that helps in understanding long-distance dependencies in sequences. It is used to focus on different parts of the input sequence when generating an output. The attention mechanism allows the model to capture relationships between words in a sentence, even if they are far apart."
}app/main.py: The main FastAPI application file.rag_logic.py: The core RAG pipeline logic.models.py: The Pydantic models for the API.
data/: Contains the PDF documents.Dockerfile: The Dockerfile for building the application image.docker-compose.yml: The Docker Compose file for managing the application.requirements.txt: The Python dependencies.