Dataset Viewer

The dataset viewer is not available because its heuristics could not detect any supported data files. You can try uploading some data files, or configuring the data files location manually.

RAG + Specialized LLM: Real-Time SOC Assistant

RAG + LLM Specialise : Assistant SOC Temps Reel

This dataset contains a technical article available in both French and English. Cet article technique est disponible en francais et en anglais.


Navigation



title: "RAG + LLM Specialise : Architecture pour un Assistant SOC Temps Reel" author: "AYI-NEDJIMI Consultants" date: "2026-02-21" language: "fr" tags: - rag - soc - llm - temps-reel - siem - cybersecurite license: "cc-by-sa-4.0"

RAG + LLM Specialise : Architecture pour un Assistant SOC Temps Reel

Auteur : AYI-NEDJIMI Consultants | Date : 21 fevrier 2026 | Temps de lecture : 11 min


Introduction

Un analyste SOC de niveau 1 traite en moyenne 50 a 80 alertes par jour. De ce volume, 70 a 90% sont des faux positifs qui consomment un temps precieux. L'integration d'un LLM specialise combine a une architecture RAG (Retrieval-Augmented Generation) permet de transformer radicalement ce workflow en fournissant un assistant temps reel capable d'analyser, enrichir et prioriser les alertes automatiquement.

Cet article detaille l'architecture complete d'un assistant SOC base sur CyberSec-Assistant-3B couple a un pipeline RAG optimise. Notre expertise en optimisation du chunking documentaire est au coeur de cette architecture.

Architecture Globale

Diagramme de l'architecture

+-------------------+     +------------------+     +------------------+
|   Sources SIEM    |     |  Bases de        |     |  Threat Intel    |
|   (Splunk/Sentinel|     |  Connaissances   |     |  Feeds           |
|   /QRadar/Wazuh)  |     |  (Confluence,    |     |  (MISP, OTX,     |
|                   |     |   SharePoint)    |     |   VirusTotal)    |
+--------+----------+     +--------+---------+     +--------+---------+
         |                         |                         |
         v                         v                         v
+--------+-------------------------+-------------------------+---------+
|                        Pipeline d'Ingestion RAG                      |
|  [Parseur multi-format] -> [Chunking adaptatif] -> [Embedding]       |
|                                                        |             |
|                                                        v             |
|                                              [Vector Store FAISS]    |
+----------------------------------------------------------------------+
         |                                               |
         v                                               v
+--------+----------+                         +----------+---------+
|  File d'alertes   |                         |  Contexte enrichi  |
|  temps reel       |                         |  par RAG           |
|  (Kafka/Redis)    |                         |                    |
+--------+----------+                         +----------+---------+
         |                                               |
         +-------------------+---------------------------+
                             |
                             v
              +--------------+---------------+
              |   CyberSec-Assistant-3B      |
              |   (Analyse + Verdict)        |
              |   via Ollama API             |
              +--------------+---------------+
                             |
                             v
              +--------------+---------------+
              |   Dashboard SOC              |
              |   (Alertes enrichies,        |
              |    verdicts, playbooks)      |
              +------------------------------+

Pipeline RAG pour le SOC

Ingestion des bases de connaissances

from langchain.document_loaders import (
    DirectoryLoader, PyPDFLoader,
    ConfluenceLoader, UnstructuredMarkdownLoader
)
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain_community.vectorstores import FAISS
from langchain_community.embeddings import HuggingFaceEmbeddings
import json

class SOCKnowledgeBase:
    """Base de connaissances RAG pour le SOC."""

    def __init__(self, embedding_model="sentence-transformers/all-MiniLM-L6-v2"):
        self.embeddings = HuggingFaceEmbeddings(model_name=embedding_model)
        self.vector_store = None
        self.text_splitter = RecursiveCharacterTextSplitter(
            chunk_size=1000,
            chunk_overlap=150,
            separators=["\n## ", "\n### ", "\n\n", "\n", ". "],
        )

    def ingest_mitre_attack(self, mitre_json_path: str):
        """Ingere la base MITRE ATT&CK."""
        with open(mitre_json_path) as f:
            mitre_data = json.load(f)

        documents = []
        for technique in mitre_data.get("objects", []):
            if technique.get("type") == "attack-pattern":
                content = (
                    f"# {technique.get('name', '')}\n"
                    f"ID: {technique.get('external_references', [{}])[0].get('external_id', '')}\n"
                    f"Description: {technique.get('description', '')}\n"
                    f"Detection: {technique.get('x_mitre_detection', '')}\n"
                )
                documents.append(content)
        return documents

    def ingest_soc_playbooks(self, playbooks_dir: str):
        """Ingere les playbooks de reponse aux incidents."""
        loader = DirectoryLoader(
            playbooks_dir, glob="**/*.md",
            loader_cls=UnstructuredMarkdownLoader
        )
        return loader.load()

    def ingest_sigma_rules(self, sigma_dir: str):
        """Ingere les regles Sigma pour l'enrichissement."""
        import yaml
        documents = []
        from pathlib import Path
        for rule_file in Path(sigma_dir).rglob("*.yml"):
            with open(rule_file) as f:
                rule = yaml.safe_load(f)
            content = (
                f"# Sigma Rule: {rule.get('title', '')}\n"
                f"Status: {rule.get('status', '')}\n"
                f"Level: {rule.get('level', '')}\n"
                f"Description: {rule.get('description', '')}\n"
                f"Detection: {json.dumps(rule.get('detection', {}), indent=2)}\n"
                f"Tags: {', '.join(rule.get('tags', []))}\n"
            )
            documents.append(content)
        return documents

    def build_index(self, all_documents):
        """Construit l'index vectoriel."""
        chunks = self.text_splitter.create_documents(all_documents)
        self.vector_store = FAISS.from_documents(chunks, self.embeddings)
        self.vector_store.save_local("./soc_vector_store")
        print(f"Index construit : {len(chunks)} chunks")

    def query(self, question: str, k: int = 5) -> str:
        """Interroge la base de connaissances."""
        if not self.vector_store:
            self.vector_store = FAISS.load_local(
                "./soc_vector_store", self.embeddings,
                allow_dangerous_deserialization=True
            )
        results = self.vector_store.similarity_search(question, k=k)
        return "\n\n---\n\n".join([doc.page_content for doc in results])

Assistant SOC Temps Reel

import requests
import json
import time
from datetime import datetime
import redis

class SOCAssistant:
    """Assistant SOC temps reel base sur RAG + LLM."""

    def __init__(self, ollama_url, knowledge_base):
        self.ollama_url = ollama_url
        self.kb = knowledge_base
        self.redis = redis.Redis(host="localhost", port=6379, db=0)
        self.model = "cybersec-assistant"

    def process_alert(self, alert: dict) -> dict:
        """Traite une alerte SIEM en temps reel."""
        start_time = time.time()

        # 1. Recuperer le contexte RAG pertinent
        alert_summary = self._summarize_alert(alert)
        rag_context = self.kb.query(alert_summary, k=5)

        # 2. Construire le prompt enrichi
        prompt = f"""Analyse cette alerte SIEM en utilisant le contexte fourni.

ALERTE :
{json.dumps(alert, indent=2, ensure_ascii=False)}

CONTEXTE (base de connaissances SOC) :
{rag_context}

Produis une analyse structuree :
1. **Verdict** : Vrai positif / Faux positif / Indetermine (avec confiance %)
2. **Techniques MITRE ATT&CK** associees
3. **Severite ajustee** (1-10) avec justification
4. **Contexte enrichi** depuis la base de connaissances
5. **Actions recommandees** (playbook)
6. **IOCs a investiguer**"""

        # 3. Appel au LLM
        response = requests.post(
            f"{self.ollama_url}/api/generate",
            json={
                "model": self.model,
                "prompt": prompt,
                "stream": False,
                "options": {"temperature": 0.2, "num_ctx": 4096},
            },
            timeout=120
        )

        analysis = response.json()["response"]
        processing_time = time.time() - start_time

        result = {
            "alert_id": alert.get("id", "unknown"),
            "timestamp": datetime.now().isoformat(),
            "analysis": analysis,
            "processing_time_seconds": round(processing_time, 2),
            "rag_chunks_used": 5,
            "model": self.model,
        }

        # 4. Cache le resultat
        self.redis.setex(
            f"alert:{result['alert_id']}",
            3600,
            json.dumps(result)
        )

        return result

    def _summarize_alert(self, alert: dict) -> str:
        """Resume une alerte pour la recherche RAG."""
        parts = [
            alert.get("rule_name", ""),
            alert.get("description", ""),
            alert.get("mitre_technique", ""),
            str(alert.get("source_ip", "")),
            str(alert.get("destination_ip", "")),
        ]
        return " ".join(filter(None, parts))

    def batch_process(self, alerts: list) -> list:
        """Traitement par lot d'alertes."""
        results = []
        for alert in alerts:
            result = self.process_alert(alert)
            results.append(result)
            print(f"[{result['timestamp']}] Alert {result['alert_id']}: "
                  f"processed in {result['processing_time_seconds']}s")
        return results

Optimisation du Chunking pour le SOC

Le chunking est un element critique pour la qualite des reponses RAG. Notre approche, detaillee dans notre article sur l'optimisation du chunking documentaire, applique des strategies specifiques au contexte SOC :

Type de document Taille de chunk Chevauchement Strategie
Regles Sigma 500 tokens 50 Par regle complete
Playbooks 1000 tokens 150 Par section
MITRE ATT&CK 800 tokens 100 Par technique
Rapports CTI 1200 tokens 200 Par paragraphe semantique
Logs documentes 600 tokens 75 Par type d'evenement

Integration avec les Outils d'Audit AD

L'assistant SOC s'integre naturellement avec les outils d'audit Active Directory decrits dans notre guide des top 10 outils d'audit AD, permettant une corrrelation automatique entre les alertes SIEM et les rapports d'audit AD.

Performance en Production

Metriques sur 30 jours

Metrique Valeur
Alertes traitees 2,847
Temps median de traitement 3.2 secondes
Vrais positifs identifies 312 (11%)
Faux positifs filtres 2,283 (80%)
Indetermines (escalade L2) 252 (9%)
Precision du verdict 94.3%
Gain de temps analyste L1 6.2 heures/jour

Conclusion

L'architecture RAG + LLM specialise pour un assistant SOC temps reel demontre des gains operationnels significatifs. En combinant la pertinence contextuelle du RAG avec les capacites d'analyse du modele CyberSec-Assistant-3B, le systeme permet de reduire drastiquement la charge de travail des analystes SOC tout en ameliorant la qualite de l'analyse. La cle reside dans l'optimisation du chunking et la qualite de la base de connaissances.


Cet article fait partie d'une serie sur l'IA appliquee a la cybersecurite par AYI-NEDJIMI Consultants.



title: "RAG + Specialized LLM: Architecture for a Real-Time SOC Assistant" author: "AYI-NEDJIMI Consultants" date: "2026-02-21" language: "en" tags: - rag - soc - llm - real-time - siem - cybersecurity license: "cc-by-sa-4.0"

RAG + Specialized LLM: Architecture for a Real-Time SOC Assistant

Author: AYI-NEDJIMI Consultants | Date: February 21, 2026 | Reading time: 11 min


Introduction

A level-1 SOC analyst handles an average of 50 to 80 alerts per day. Of this volume, 70 to 90% are false positives that consume precious time. Integrating a specialized LLM combined with a RAG (Retrieval-Augmented Generation) architecture can radically transform this workflow by providing a real-time assistant capable of automatically analyzing, enriching, and prioritizing alerts.

This article details the complete architecture of a SOC assistant based on CyberSec-Assistant-3B coupled with an optimized RAG pipeline. Our expertise in document chunking optimization is at the core of this architecture.

Global Architecture

+-------------------+     +------------------+     +------------------+
|   SIEM Sources    |     |  Knowledge       |     |  Threat Intel    |
|   (Splunk/Sentinel|     |  Bases           |     |  Feeds           |
|   /QRadar/Wazuh)  |     |  (Confluence,    |     |  (MISP, OTX,     |
|                   |     |   SharePoint)    |     |   VirusTotal)    |
+--------+----------+     +--------+---------+     +--------+---------+
         |                         |                         |
         v                         v                         v
+--------+-------------------------+-------------------------+---------+
|                        RAG Ingestion Pipeline                        |
|  [Multi-format Parser] -> [Adaptive Chunking] -> [Embedding]        |
|                                                       |              |
|                                                       v              |
|                                             [FAISS Vector Store]     |
+----------------------------------------------------------------------+
         |                                               |
         v                                               v
+--------+----------+                         +----------+---------+
|  Real-time Alert  |                         |  RAG-enriched      |
|  Queue            |                         |  Context            |
|  (Kafka/Redis)    |                         |                    |
+--------+----------+                         +----------+---------+
         |                                               |
         +-------------------+---------------------------+
                             |
                             v
              +--------------+---------------+
              |   CyberSec-Assistant-3B      |
              |   (Analysis + Verdict)       |
              |   via Ollama API             |
              +--------------+---------------+
                             |
                             v
              +--------------+---------------+
              |   SOC Dashboard              |
              |   (Enriched alerts,          |
              |    verdicts, playbooks)      |
              +------------------------------+

RAG Pipeline for the SOC

Knowledge Base Ingestion

from langchain.document_loaders import DirectoryLoader, UnstructuredMarkdownLoader
from langchain.text_splitter import RecursiveCharacterTextSplitter
from langchain_community.vectorstores import FAISS
from langchain_community.embeddings import HuggingFaceEmbeddings
import json

class SOCKnowledgeBase:
    """RAG knowledge base for the SOC."""

    def __init__(self, embedding_model="sentence-transformers/all-MiniLM-L6-v2"):
        self.embeddings = HuggingFaceEmbeddings(model_name=embedding_model)
        self.vector_store = None
        self.text_splitter = RecursiveCharacterTextSplitter(
            chunk_size=1000,
            chunk_overlap=150,
            separators=["\n## ", "\n### ", "\n\n", "\n", ". "],
        )

    def ingest_mitre_attack(self, mitre_json_path: str):
        """Ingest the MITRE ATT&CK knowledge base."""
        with open(mitre_json_path) as f:
            mitre_data = json.load(f)

        documents = []
        for technique in mitre_data.get("objects", []):
            if technique.get("type") == "attack-pattern":
                content = (
                    f"# {technique.get('name', '')}\n"
                    f"ID: {technique.get('external_references', [{}])[0].get('external_id', '')}\n"
                    f"Description: {technique.get('description', '')}\n"
                    f"Detection: {technique.get('x_mitre_detection', '')}\n"
                )
                documents.append(content)
        return documents

    def ingest_sigma_rules(self, sigma_dir: str):
        """Ingest Sigma rules for enrichment."""
        import yaml
        from pathlib import Path
        documents = []
        for rule_file in Path(sigma_dir).rglob("*.yml"):
            with open(rule_file) as f:
                rule = yaml.safe_load(f)
            content = (
                f"# Sigma Rule: {rule.get('title', '')}\n"
                f"Status: {rule.get('status', '')}\n"
                f"Level: {rule.get('level', '')}\n"
                f"Description: {rule.get('description', '')}\n"
                f"Detection: {json.dumps(rule.get('detection', {}), indent=2)}\n"
                f"Tags: {', '.join(rule.get('tags', []))}\n"
            )
            documents.append(content)
        return documents

    def build_index(self, all_documents):
        """Build the vector index."""
        chunks = self.text_splitter.create_documents(all_documents)
        self.vector_store = FAISS.from_documents(chunks, self.embeddings)
        self.vector_store.save_local("./soc_vector_store")
        print(f"Index built: {len(chunks)} chunks")

    def query(self, question: str, k: int = 5) -> str:
        """Query the knowledge base."""
        if not self.vector_store:
            self.vector_store = FAISS.load_local(
                "./soc_vector_store", self.embeddings,
                allow_dangerous_deserialization=True
            )
        results = self.vector_store.similarity_search(question, k=k)
        return "\n\n---\n\n".join([doc.page_content for doc in results])

Real-Time SOC Assistant

import requests
import json
import time
from datetime import datetime
import redis

class SOCAssistant:
    """Real-time SOC assistant based on RAG + LLM."""

    def __init__(self, ollama_url, knowledge_base):
        self.ollama_url = ollama_url
        self.kb = knowledge_base
        self.redis = redis.Redis(host="localhost", port=6379, db=0)
        self.model = "cybersec-assistant"

    def process_alert(self, alert: dict) -> dict:
        """Process a SIEM alert in real time."""
        start_time = time.time()

        # 1. Retrieve relevant RAG context
        alert_summary = self._summarize_alert(alert)
        rag_context = self.kb.query(alert_summary, k=5)

        # 2. Build enriched prompt
        prompt = f"""Analyze this SIEM alert using the provided context.

ALERT:
{json.dumps(alert, indent=2)}

CONTEXT (SOC knowledge base):
{rag_context}

Produce a structured analysis:
1. **Verdict**: True positive / False positive / Undetermined (with confidence %)
2. **MITRE ATT&CK techniques** associated
3. **Adjusted severity** (1-10) with justification
4. **Enriched context** from the knowledge base
5. **Recommended actions** (playbook)
6. **IOCs to investigate**"""

        # 3. Call the LLM
        response = requests.post(
            f"{self.ollama_url}/api/generate",
            json={
                "model": self.model,
                "prompt": prompt,
                "stream": False,
                "options": {"temperature": 0.2, "num_ctx": 4096},
            },
            timeout=120
        )

        analysis = response.json()["response"]
        processing_time = time.time() - start_time

        result = {
            "alert_id": alert.get("id", "unknown"),
            "timestamp": datetime.now().isoformat(),
            "analysis": analysis,
            "processing_time_seconds": round(processing_time, 2),
            "rag_chunks_used": 5,
            "model": self.model,
        }

        # 4. Cache the result
        self.redis.setex(
            f"alert:{result['alert_id']}", 3600, json.dumps(result)
        )
        return result

    def _summarize_alert(self, alert: dict) -> str:
        """Summarize an alert for RAG search."""
        parts = [
            alert.get("rule_name", ""),
            alert.get("description", ""),
            alert.get("mitre_technique", ""),
            str(alert.get("source_ip", "")),
            str(alert.get("destination_ip", "")),
        ]
        return " ".join(filter(None, parts))

Chunking Optimization for the SOC

Chunking is a critical element for RAG response quality. Our approach, detailed in our article on document chunking optimization, applies SOC-specific strategies:

Document Type Chunk Size Overlap Strategy
Sigma rules 500 tokens 50 Per complete rule
Playbooks 1000 tokens 150 Per section
MITRE ATT&CK 800 tokens 100 Per technique
CTI reports 1200 tokens 200 Per semantic paragraph
Documented logs 600 tokens 75 Per event type

Integration with AD Audit Tools

The SOC assistant naturally integrates with the Active Directory audit tools described in our top 10 AD audit tools guide, enabling automatic correlation between SIEM alerts and AD audit reports.

Production Performance

30-Day Metrics

Metric Value
Alerts processed 2,847
Median processing time 3.2 seconds
True positives identified 312 (11%)
False positives filtered 2,283 (80%)
Undetermined (L2 escalation) 252 (9%)
Verdict accuracy 94.3%
L1 analyst time saved 6.2 hours/day

Conclusion

The RAG + specialized LLM architecture for a real-time SOC assistant demonstrates significant operational gains. By combining RAG's contextual relevance with the analytical capabilities of CyberSec-Assistant-3B, the system drastically reduces SOC analyst workload while improving analysis quality. The key lies in chunking optimization and knowledge base quality.


This article is part of a series on AI applied to cybersecurity by AYI-NEDJIMI Consultants.

Downloads last month
13