A Retrieval-Augmented Generation (RAG) system designed for efficiently querying a structured handbook.
what to expect next:
- Expanding "Knowledge base" to include 42-related informations and overall general facts and rules any 42/1337 student need to be aware of.
- A dockerized environment for ease of deployment.
- Web app UI for ease of use with intra account login.
- Possibility of choosing your own embedding and LLM models.
handbook_assistant is a local Retrieval-Augmented Generation (RAG) system built to answer questions related to 1337 coding school using its official handbook and internal documentation. The system combines:
- Structured document chunking
- Dense vector embeddings
- Semantic search with FAISS
- Local LLM inference via Ollama
It is designed to only answer questions related to 1337, while rejecting unrelated queries or instructions.
- β Hierarchical markdown chunking (H1 / H2 aware)
- β Token-aware chunk splitting for embeddings
- β Local embeddings using nomic-embed-text
- β Vector search with FAISS
- β Query routing (retrieval vs chat)
- β Ollama-based local LLM inference
- β Strict scope enforcement (1337-only answers)
- β Modular and extensible design
User Query
β
βΌ
Query Router (Embedding Similarity / LLM fallback)
βββ Chat β Generic LLM (scope-limited)
βββ Retrieval
βββ Embed query
βββ FAISS similarity search
βββ Retrieve top-k chunks
βββ LLM answers using retrieved context
Click to expand
.
βββ data/
β βββ cleaned/
β β βββ handbook_clean.md
β βββ chunked/
β β βββ handbook_chunked.jsonl
β βββ index/
β β βββ handbook.faiss
β β βββ metadata.json
β βββ processed/
β β βββ images/
β β βββ handbook.md
β βββ raw/
β βββ handbook.pdf
βββ src/
β βββ chat_retrieve.py
β βββ cli_app.py
β βββ prep_data.py
β βββ scripts/
β βββ chunker.py
β βββ answer.py
β βββ clean_md.py
β βββ memory.py
β βββ pdf_to_md.py
β βββ prompt.py
β βββ trim_history.py
β βββ embedding.py
β βββ retrieval.py
β βββ decision.py
β βββ token_length.py
βββ README.md
βββ requirements.txt
- Clone the repository
git clone https://github.com/Sfeso13/handbook_assistant.git
cd handbook_assistant- Create and activate a virtual environment
python3 -m venv venv
source venv/bin/activate- Install dependencies
pip install -r requirements.txtMake sure ollama is installed and running locally.
- Pull required models
ollama pull qwen3:4b-instruct-2507-q4_K_M
ollama pull sanruss/qwen3-2b-rag
ollama pull nomic-embed-text-v2-moe- Start the assistant
python3 src/cli_app.py #for general use
python3 src/cli_app.py --debug #for printing debug messages- Query to your heart contents