Skip to main content

Overview

The RAG System (Retrieval-Augmented Generation) provides natural language intelligence over ML Defender’s security events. Using TinyLlama for language understanding and FAISS for vector search, it enables forensic queries like β€œShow me all ransomware detections from 10.0.0.50 last week” without SQL or log parsing.

Components

  • RAG Ingester: Log parsing + vector embeddings
  • RAG Server: TinyLlama + FAISS query engine
  • 4 FAISS Indices: Temporal, semantic, benign, malicious
  • etcd Integration: Service discovery

Capabilities

  • Natural Language Queries: Ask questions in English
  • Temporal Analysis: β€œLast week”, β€œYesterday morning”
  • Pattern Recognition: β€œSimilar to this attack”
  • ML Retraining Data: Export feature vectors

Architecture

The RAG System consists of two symbiotic services that work together:

RAG Ingester

Multi-Index Strategy

The Ingester maintains 4 specialized FAISS indices for different query patterns:
Dimensions: 128Purpose: Time-series queriesOptimized For:
  • β€œShow me attacks from last week”
  • β€œWhat happened on Monday between 2-4 PM?”
  • β€œHourly attack trends”
Embedding Model: Chronos temporal encoder (ONNX)PCA: 512d β†’ 128d reduction for efficient storage

Eventual Consistency

The Ingester uses best-effort commits for high availability:
Design Philosophy: Availability over Consistency. Better to have 3/4 indices working than to block and have 0/4.

Configuration

Threading Modes

Memory: ~310MBUse Case: Resource-constrained environments

RAG Server (TinyLlama)

Natural Language Query Processing

The RAG Server uses TinyLlama (1.1B parameters) for query understanding:
1

Query Understanding

User Query: β€œShow me all ransomware detections from 10.0.0.50 last week”TinyLlama Extracts:
2

Vector Search

FAISS Queries (parallel):
  • Entity Malicious Index: Find all events from 10.0.0.50
  • Chronos Index: Filter by time range (last week)
Results: 47 matching events
3

Result Aggregation

TinyLlama Summarizes:

Example Queries


ML Retraining Data Export

The RAG System can export feature vectors for ML model retraining:
Use Cases:
  • Model drift detection: Compare new data distribution vs training data
  • Incremental training: Retrain RandomForest on recent attacks
  • False positive analysis: Identify mislabeled events

Deployment

Prerequisites

Build RAG Ingester

1

Navigate

2

Configure

3

Compile

Run RAG Ingester

Real-time Output:

Run RAG Server


Troubleshooting

Symptom: OOM error during query processingSolution: Use 4-bit quantization:
Memory: 2GB β†’ 600MB

Roadmap

Priority 1.1: Firewall Log Parsing

Goal: Ingest firewall-agent logs for ground truth linking
1

Detection ↔ Block Linking

Link ML Detector events to Firewall Agent blocks:
2

Cross-component Queries

β€œShow me all detections that were NOT blockedβ€β€œWhat’s the latency between detection and blocking?”

Priority 1.2: Temporal Queries

Goal: Natural language time expressions

Priority 1.3: Aggregation & Statistics

Goal: Summary queries

Next Steps

Sniffer

Configure network packet capture

ML Detector

Set up ML inference pipeline

Firewall Agent

Deploy autonomous blocking

Model Training

Retrain models with RAG-exported data