kazakiakayami/ai-document-assistant
0
๐ AI Document Assistant
An intelligent document assistant powered by RAG (Retrieval-Augmented Generation) that allows you to upload PDF documents and ask questions about their content in natural language.
๐ Live Demo
๐ค Try it on HuggingFace Spaces
โจ Features
- ๐ Upload any PDF document
- ๐ฌ Chat with your document in natural language
- ๐ Accurate answers based strictly on document content
- ๐ Source page references for every answer
- ๐ Supports both English and Indonesian questions
- ๐ Switch documents anytime without refreshing
๐ ๏ธ Tech Stack
๐ RAG Pipeline
๐ PDF Upload
โ
๐ฅ Document Loader (PyPDF)
โ
โ๏ธ Text Chunking (chunk_size=1000, overlap=100)
โ
๐ข Embedding (HuggingFace sentence-transformers)
โ
๐๏ธ Vector Store (ChromaDB)
โ
โ User Query โ Similarity Search โ Top 3 Chunks
โ
๐ค LLM (Groq/Llama3.1) โ Answer + Sources๐ Project Structure
ai-document-assistant/
โ
โโโ app.py # Main Streamlit UI
โโโ requirements.txt # Dependencies
โโโ .env # API Keys (not committed)
โโโ .gitignore
โ
โโโ src/
โโโ document_loader.py # PDF loading
โโโ chunker.py # Text chunking
โโโ embedder.py # Embedding + VectorDB
โโโ rag_chain.py # RAG pipeline + LLMโ๏ธ Installation & Setup
1. Clone the repository
git clone https://github.com/YOUR_USERNAME/ai-document-assistant.git
cd ai-document-assistant2. Create virtual environment
conda create -n rag_env python=3.11
conda activate rag_env3. Install dependencies
pip install -r requirements.txt4. Setup environment variables
Create a .env file in the root directory:
GROQ_API_KEY=your_groq_api_key_hereGet your free Groq API key at groq.com
5. Run the app
streamlit run app.py๐งช Testing Results
๐ Key Design Decisions
- Chunk size 1000, overlap 100 โ optimal for legal/rule documents
- k=3 retrieval โ balance between context and token efficiency
- Temperature 0.2 โ low temperature for factual accuracy
- In-memory VectorDB โ no persistence needed for demo deployment
- Prompt engineering โ strict instruction to not hallucinate beyond context
๐ Lessons Learned
- RAG accuracy heavily depends on chunk size and overlap configuration
- PDF parsing can introduce artifacts (headers, footers) that affect chunk quality
- Filtering chunks shorter than 50 characters significantly improves retrieval quality
- LLM temperature should be low (0.1-0.3) for document Q&A tasks
๐จโ๐ป Author
Ahmad Mustofa Z Hacktiv8 Data Science Bootcamp - Phase 1 Project
