PROJECT TEMPLATE: RAG System¶
Build a Retrieval-Augmented Generation system from scratch.
Project Structure¶
rag-system/
├── README.md
├── pyproject.toml
├── uv.lock
├── config/
│ ├── embedding_config.yaml
│ ├── vectorstore_config.yaml
│ └── llm_config.yaml
├── src/
│ ├── __init__.py
│ ├── embeddings.py # Embedding models
│ ├── vectorstore.py # Vector database
│ ├── retriever.py # Retrieval logic
│ ├── generator.py # LLM generation
│ └── pipeline.py # RAG pipeline
├── data/
│ └── documents/
│ ├── doc1.txt
│ └── doc2.txt
├── api/
│ └── main.py # FastAPI server
└── tests/
└── test_rag.py
Features¶
- Document ingestion
- Embedding generation
- Vector storage (Qdrant/ChromaDB/Milvus)
- Hybrid retrieval (dense + sparse)
- Context-aware generation
- REST API
Quick Start¶
-
Add documents to
data/documents/ -
Configure vector store in
config/vectorstore_config.yaml:type: "qdrant" # or "chroma", "milvus" collection_name: "documents" embedding_model: "all-MiniLM-L6-v2" -
Build index:
python -m src.pipeline build-index -
Run API:
uvicorn api.main:app --reload -
Query:
curl -X POST "http://localhost:8000/query" \ -H "Content-Type: application/json" \ -d '{"query": "What is machine learning?"}'
Components¶
Embeddings¶
- SentenceTransformers
- OpenAI embeddings
- Custom models
Vector Stores¶
- Qdrant
- ChromaDB
- Milvus
- FAISS (local)
Retrieval¶
- Dense search
- Sparse search
- Hybrid search
- Re-ranking
Generation¶
- OpenAI GPT
- Local LLMs
- Context injection
Advanced Features¶
- Multi-document retrieval
- Metadata filtering
- Query expansion
- Citation generation
Difficulty: ⭐⭐ Intermediate
Estimated Time: 6-10 hours
Skills: Vector databases, Embeddings, RAG