A local Retrieval-Augmented Generation (RAG) system for querying 3GPP technical specifications. It combines BM25 sparse retrieval and ChromaDB vector search, fused with Reciprocal Rank Fusion (RRF), and answered by a local LLM via Ollama.
3GPP .docx/.pdf files
│
▼
ingest.py ──► ChromaDB (vector index)
──► BM25 index (pickle)
│
▼
query.py ──► Hybrid retrieval (BM25 + vector, RRF fusion)
──► Ollama LLM (llama3.2:3b)
──► Answer
- Python 3.10+
- Ollama installed and running locally
- Pull the required models:
ollama pull nomic-embed-text ollama pull llama3.2:3b
# Clone the repo
git clone https://github.com/waveweaver/3gpp-rag.git
cd 3gpp-rag
# Create and activate a virtual environment
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txtPlace your 3GPP specification files (.docx or .pdf) in data/specs/.
Specs can be downloaded from the 3GPP FTP server.
Files should follow the standard 3GPP naming convention, e.g.:
38331-j20 NR Radio Resource Control (RRC); Protocol specification.docx
python ingest.pyThis parses all files in data/specs/, chunks the text, embeds each chunk with nomic-embed-text, and stores everything in chroma_db/ and index/.
python query.pyType a question at the prompt and the system will retrieve the most relevant chunks and generate an answer using the local LLM.
Ask a question (or 'exit'): What are the RRC states in NR?
3gpp-rag/
├── ingest.py # Parses specs and builds the hybrid index
├── query.py # Interactive Q&A interface
├── requirements.txt
├── parsers/
│ ├── docx_parser.py # DOCX chunker with metadata extraction
│ └── pdf_parser.py # PDF chunker using LangChain text splitter
├── data/
│ └── specs/ # Place 3GPP .docx/.pdf files here (git-ignored)
├── chroma_db/ # ChromaDB vector store (generated, git-ignored)
└── index/ # BM25 pickle files (generated, git-ignored)
Key constants at the top of each script:
| Constant | Default | Description |
|---|---|---|
EMBED_MODEL |
nomic-embed-text |
Ollama embedding model |
LLM_MODEL |
llama3.2:3b |
Ollama LLM for answer generation |
CHUNK_SIZE |
1000 |
Characters per chunk |
CHUNK_OVERLAP |
200 |
Overlap between consecutive chunks |
K_EACH |
6 |
Candidates fetched per retriever |
FINAL_K |
5 |
Chunks sent to the LLM after RRF fusion |