Skip to content

Privacy-focused RAG chatbot for network documentation. Chat with your PDFs locally using Ollama, Chroma & LangChain. CPU-only, fully offline.

License

Notifications You must be signed in to change notification settings

lahcenkh/rag-network-docs

Repository files navigation

Network Docs RAG Chatbot

This project is a Retrieval-Augmented Generation (RAG) chatbot for network engineering documentation.

Features

  • Runs entirely on CPU – no GPU required (This makes it lightweight and portable, but responses may be slower compared to GPU setups.)
  • 🔒 Privacy-focused – everything is processed locally on your machine:
    • Documents are never uploaded to the cloud
    • Embeddings are stored in a local Chroma database
    • LLM inference is done through Ollama, fully offline

This makes the chatbot lightweight, portable, and secure for use with sensitive networking documentation.

Tech Stack

  • Ollama for running local LLMs (e.g., llama3.2:3b)
  • Chroma as the vector database
  • HuggingFace embeddings for semantic search
  • Unstructured for PDF/Doc parsing
  • LangChain Text Splitters for clean chunking
  • Rich for colored terminal UI

The chatbot retrieves context from your networking documentation (PDFs) and answers queries with proper citations.

Project Structure

.
├── .env                     # Environment variables
├── chat.py                  # Interactive chatbot loop
├── RAG_network_documents.py # Script to process docs & build vector DB
├── tools.py                 # Utilities (embedding, retriever, logging, checks)
├── docs/                    # Place your PDF docs here
│   ├── CISCO - XR
│   │   └── Cisco XR 12000 Series Router.pdf
│   │
│   ├── HUAWEI - NE40e
│   │   └── NE40E Product Description.pdf
│   │
│   └── NOKIA - SR-7750
│       └── nokia-7750-service-router-datasheet-en.pdf
│
├── chromadb/                # Chroma persistence directory (auto-created)
├── chat_logs/               # Saved chat logs (JSON + Markdown, auto-created)

Setup

1. Install dependencies

pip install -r requirements.txt

2. Install & run Ollama

Start the Ollama server:

ollama serve

3. Configure environment

Edit the .env file:

MODEL_NAME="llama3.2:3b"
CHROMA_DB_PATH="./chromadb"
COLLECTION_NAME="network_docs"
DOCS_PATH="./docs"
EMBEDDING_MODEL_NAME="intfloat/multilingual-e5-large-instruct"
TOP_K=5

Usage

Index Documentation

To process your networking PDFs into embeddings and store them in Chroma:

python RAG_network_documents.py

This will:

  1. Parse PDFs from ./docs using unstructured
  2. Chunk the text using LangChain text splitters
  3. Generate embeddings
  4. Store them in the Chroma DB

Run the Chatbot

Start an interactive chat:

python chat.py

Chat Features

  • Colored terminal UI
  • Context-aware answers with citations
  • /exit, /quit, /q to exit
  • Empty queries are ignored
  • Chat logs saved as JSON + Markdown on exit

Screenshots:

chat screenshot 1 chat screenshot 2

Credits

This project was inspired by and adapted from: Ray End-to-End RAG Tutorial

Contact

LinkedIn: Lahcen Khouchane WebSite : NetOpsAutomation.com

About

Privacy-focused RAG chatbot for network documentation. Chat with your PDFs locally using Ollama, Chroma & LangChain. CPU-only, fully offline.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages