CyberRAG is a Retrieval-Augmented Generation (RAG) application designed to provide intelligent answers to cyber threat intelligence questions. It ingests cybersecurity advisories (PDFs), indexes them using vector embeddings, and uses a Large Language Model (LLM) to generate comprehensive, citation-backed briefings for security analysts.
-
IOC-Aware Hybrid Search: Detects whether a query contains Indicators of Compromise (IOCs) such as IPs, hashes, domains, or CVEs. If IOCs are present, the system follows an IOC-driven retrieval path; otherwise, it falls back to semantic vector search using Weaviate and Ollama embeddings.
-
AI-Powered Answers: Generates professional threat briefings using Google Gemini (Flash 2.5).
-
Citation Tracking: Every claim in the generated answer is cited with the source document.
-
Dark Mode UI: A professional, "Spotlight Search" style interface built with Streamlit.
-
Progress Tracking: Real-time visibility into the search and generation pipeline.
-
PDF Ingestion: Automated pipeline to parse, chunk, and index PDF advisories.
- Ingestion: PDFs are parsed using
pypdf, chunked, and embedded usingOllama(model:embeddinggemma). - Storage: Embeddings and text chunks are stored in a local
Weaviatevector database. - Retrieval: The system first analyzes the user query to detect the presence of Indicators of Compromise (IOCs). Queries containing IOCs are routed through an IOC-specific retrieval path, while non-IOC queries are embedded and processed using semantic vector similarity search.
- Generation: Retrieved context is sent to
Google Gemini, which acts as a Senior Threat Intelligence Analyst to answer the user's question.
Before running the project, ensure you have the following installed:
- Python 3.12+
- Docker (for running Weaviate)
- Ollama (for local embeddings)
- Install Ollama from ollama.com.
- Pull the embedding model:
ollama pull embeddinggemma
-
Clone the repository:
git clone <repository-url> cd CyberRAG
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Start Weaviate: You need a running Weaviate instance. If you have a
docker-compose.ymlfile (typical for Weaviate), run:docker-compose up -d
Note: Ensure Weaviate is accessible at
localhost:8080(GRPC on 50051).
Create a .env file in the root directory with the following variables:
# LLM & Embedding
OLLAMA_HOST=http://localhost:11434
EMBEDDING_MODEL=embeddinggemma
SUMMARIZE_MODEL=gemini-2.5-flash
GEMMA_API_KEY=your_google_gemini_api_key_here
# Vector Database (Weaviate)
WEAVIATE_HOST=localhost
WEAVIATE_API_KEY=supersecret_api_key_123
WEAVIATE_COLLECTION=Advisory
TOP_K_DEFAULT=25Note: You can get a Google Gemini API key from Google AI Studio.
Place your PDF files in the data/cisa_pdfs/ directory. Then run the ingestion script to parse and index them:
python ingestion_process.pyThis will read PDFs, generate embeddings, and populate the Weaviate database.
Start the Streamlit web interface:
streamlit run app.pyOpen your browser to http://localhost:8501.
CyberRAG/
├── app.py # Main Streamlit application entry point
├── ingestion_process.py # Script to ingest PDFs into Weaviate
├── requirements.txt # Python dependencies
├── .env # Environment variables (not committed)
├── data/
│ └── cisa_pdfs/ # Directory for input PDF files
├── logs/ # Application logs
└── src/ # Source code modules
├── answerer.py # LLM generation logic (Google Gemini)
├── config.py # Configuration management
├── embedder.py # Embedding generation (Ollama)
├── logger.py # Logging and progress tracking
└── search.py # Weaviate search logic
This project is licensed under the Apache License 2.0.
See the LICENSE file for details.
© 2025 Mohan Kumar Manivannan