← Projects

PDF querying Faiss

RAGLangGraphFAISSGitHub ↗

Overview

This project ingests PDF files from a local docs/ directory, splits them into overlapping text chunks, and stores their vector embeddings in a FAISS index saved to disk. At query time, the user's question is embedded and matched against the index to retrieve the most relevant chunks. Those chunks are passed as context to an OpenAI GPT-4o model, which generates an answer constrained to the retrieved material.

Key capabilities:

Architecture

            +-------------------+
            |   PDFs in docs/   |
            +-------------------+
                     |
                     v
        +-----------------------------+
        |  DirectoryLoader (PyPDF)    |   load PDF pages
        +-----------------------------+
                     |
                     v
        +-----------------------------+
        | RecursiveCharacterText      |   chunk_size=1200
        | Splitter -> text chunks     |   overlap=200
        +-----------------------------+
                     |
                     v
        +-----------------------------+
        | HuggingFace Embeddings      |   all-mpnet-base-v2
        | (sentence-transformers)     |
        +-----------------------------+
                     |
                     v
        +-----------------------------+
        |   FAISS IndexFlatL2         |   save_local("faiss_index")
        |   vector store on disk      |
        +-----------------------------+
                     |
        =============|=============  (build phase above / query phase below)
                     |
   user question     |
        |            v
        |   +-----------------------------+
        +-->|  similarity_search(k=2)     |   retrieve top chunks
            +-----------------------------+
                     |
                     v
        +-----------------------------+
        |  Prompt = question + chunks |
        +-----------------------------+
                     |
                     v
        +-----------------------------+
        |   ChatOpenAI (GPT-4o)       |   temperature=0
        +-----------------------------+
                     |
                     v
            +-------------------+
            |  Grounded answer  |
            +-------------------+

Tech Stack

LayerTechnologyPurpose
LanguagePython 3.10+Core runtime
OrchestrationLangChainLoaders, splitters, vector-store integration
Document loadingPyPDFLoader / DirectoryLoaderRead and parse PDF files
Text splittingRecursiveCharacterTextSplitterChunk documents (1200 chars, 200 overlap)
Embeddingssentence-transformers (all-mpnet-base-v2)Convert text chunks to vectors
Vector storeFAISS (faiss-cpu, IndexFlatL2)Index and similarity search
LLMOpenAI GPT-4o (langchain-openai)Generate grounded answers
ComputePyTorchBackend for the embedding model
API (optional)FastAPI + UvicornServe the pipeline over HTTP
Read the full README on GitHub ↗← Projects