Building a RAG System for Cybersecurity Research and Reporting

trainingracademy · Tech · 2024 · source Agentic: no · promotional bias: low · source-backed · extracted with prompt 0.5.4 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Cybersecurity research and reporting RAG

Trainingracademy built Stinkbait.io to support cybersecurity research and reporting in a domain where knowledge is fragmented, mainstream LLMs may censor security topics, and source data arrives as messy PDFs, HTML pages, and other difficult formats.

Constraints:

Architecture

Trainingracademy described Stinkbait.io as a cybersecurity RAG application whose most important engineering work happens before generation: ingest heterogeneous security sources, rescue invalid PDFs through Textract and image conversion, manually inspect HTML structure for useful content, choose vector database/index technology based on recall-latency tradeoffs, select embedding models based on context length and training data, chunk using formatting as a proxy for conceptual boundaries, and store vectors externally to survive future database or model changes.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  cybersecurity-researcher[Cybersecurity Researcher] --> stinkbait[Stinkbait]
  stinkbait[Stinkbait] --> data-processing-pipeline[Data Processing Pipeline]
  data-processing-pipeline[Data Processing Pipeline] --> amazon-textract[Amazon Textract]
  data-processing-pipeline[Data Processing Pipeline] --> html-scraper[HTML Scraper]
  data-processing-pipeline[Data Processing Pipeline] --> chunker[Chunker]
  chunker[Chunker] --> embedding-model[Embedding Model]
  embedding-model[Embedding Model] --> vector-store[Vector Store]
  vector-store[Vector Store] --> blob-storage[Blob Storage]
  stinkbait[Stinkbait] --> generation-layer[Generation Layer]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Cybersecurity Researcher User researching and reporting on cybersecurity topics. Stinkbait
Stinkbait RAG application for cybersecurity research and reporting. Cybersecurity Researcher, Data Processing Pipeline, Vector Store, Generation Layer
Data Processing Pipeline Preprocesses PDFs, web content, and other source types before embedding. Amazon Textract, HTML Scraper, Chunker, Embedding Model
Amazon Textract OCR path for extracting text from PDFs and JPEG-converted PDFs. Data Processing Pipeline
HTML Scraper Site-specific extraction path for relevant website elements. Data Processing Pipeline
Chunker Splits content into retrieval chunks, often using formatting as a proxy for conceptual boundaries. Data Processing Pipeline, Embedding Model
Embedding Model Converts chunks into vectors with model choice based on context length, data style, and evaluation metric. Chunker, Vector Store
Vector Store Search layer whose index choice controls recall, accuracy, and latency behavior. Stinkbait, Embedding Model, Blob Storage
Blob Storage Durable external storage for vectors so model or database changes do not force recomputation. Vector Store
Generation Layer LLM-backed response path using retrieved cybersecurity context. Stinkbait

Data flow

Security documents and websites enter a preprocessing pipeline. PDFs go through Textract, with invalid PDFs converted to JPEGs for a backup OCR path. Web pages require manual inspection of relevant HTML elements. Cleaned text is chunked, embedded with a chosen embedding model, stored in a vector database or blob-backed vector store, and retrieved later for cybersecurity research and report generation.

4 supporting quotes
“our platform we decided to build stinkbait doio which is a application focused on cyber security research and Reporting uh in the cyber security domain in specific uh the knowledge base is very fra fragmented amongst different sub communities and even subub communities”transcript, stated
“extract the text from a PDF and we use Amazon textract for this particular particular use case um however even with a proven solution like textract you're often going to encounter an error saying that this isn't actually a PDF well how do you address that you can actually”transcript, stated
“manual inspection of various websites and understanding the HTML elements that are most relevant for that particular website”transcript, stated
“maybe you should store your vectors on dis or in Blob storage because if you store those vector on disc or and blob storage you don't have to recompute them later”transcript, stated

Why this architecture

The architecture centers on retrieval and preprocessing because cybersecurity knowledge is fragmented and LLM safety filters make direct generation unreliable. The talk repeatedly argues that RAG quality depends on input data quality, index latency/recall decisions, embedding model fit, chunking boundaries, and future-proof vector storage.

3 supporting quotes
“uh the knowledge base is very fra fragmented amongst different sub communities and even subub communities so that soled approach to information sharing has really created a scenario where in cyber security collecting a knowledge bases is fairly challenging uh”transcript, stated
“cyber security topics are often censored you'll potentially hear chat GPT say oh I'm sorry I can't do that for ethical safety reasons”transcript, stated
“garbage in garbage out right so like I mean I know it's a cliche and everybody says it but the reality is so much of the work”transcript, stated

Models used: OpenAI Ada embeddings · Sentence Transformers · multi QA models · MS MARCO passage models · multilingual models · multimodal models

Scale

Alternatives considered (roads not taken)

Use PostgreSQL with pgvector and IVF-flat

Rejected because: The team saw IVF-flat latency results and concluded it might need a different vector database route.

“request anecdotally we started out thinking hey we'll use postr SQL and PG VOR which at the time only supported ibf flat we thought that using an open-source database technology would have uh real benefits as we grew and and changed as an organization but when we”transcript, stated
“when we started to see the latency results for obf flat it started to Dawn on us that maybe we had to go a different route”transcript, stated

Chunk only by ideal conceptual boundaries

Rejected because: Conceptual chunking is ideal, but at scale formatting is the realistic proxy.

“chunking the ideal way to chunk your context would be along conceptual boundaries so all of the information associated with one particular topic would go in one embedding and all of the information associated with another topic would go in another embedding”transcript, stated
“what we've seen at scale is the only realistic way to chunk your embeddings other than just sentences or you know something similar to that is to use formatting”transcript, stated

Store vectors only inside the selected vector database

Rejected because: The speaker recommends disk or blob storage so future database or embedding-model changes do not require recomputing vectors.

“if you're experimenting with Vector databases and you think you may change your vector database maybe you should store your vectors on dis or in Blob storage”transcript, stated

Patterns

rag-retrieval (retrieval)

Stinkbait uses retrieval-augmented generation to support cybersecurity research despite fragmented sources and LLM censorship.

“we decided to build a retrieval augmented generation system that could help with this”transcript, stated

data-quality-loop (data)

The system treats PDF repair, OCR, web scraping inspection, and preprocessing as core to RAG quality.

“there are some challenges that we've encountered that I think you and the audience may be interested in and you may experience similarly uh the first one we have is related to data quality”transcript, stated

retrieval-ranking (retrieval)

The vector database/index choice is framed as recall or accuracy versus latency, making retrieval behavior an explicit design dimension.

“all of these algorithms have different tradeoffs as far as recall or accuracy versus the latency associated with the request”transcript, stated

fallback-degradation (resilience)

Invalid PDFs fall back to image conversion and Textract processing rather than being dropped.

“you can actually transform the PDF into a JPEG and then reprocesses that file as a JPEG so textract allows for us to have sort of this backup capability”transcript, stated

Tradeoffs

Choose vector indexing technology

Chose A vector database/index with acceptable latency and recall over Staying with PostgreSQL/pgvector IVF-flat despite poor latency.

Rationale: The team valued open-source database benefits, but latency results pushed them toward a different vector search route.

“we thought that using an open-source database technology would have uh real benefits as we grew and and changed as an organization”transcript, stated
“when we started to see the latency results for obf flat it started to Dawn on us that maybe we had to go a different route”transcript, stated

Pick embedding models by use-case fit

Chose Evaluate context length, benchmark metric, and training data style over Defaulting automatically to Ada embeddings.

Rationale: Ada has long context and good performance, but other models may fit the data type or metric better.

“most people just choose Ada embeddings off the shelf because they're already using the open AI API”transcript, stated
“there are other uh embeddings models that may perform more uh positively for your particular use case”transcript, stated

Chunk by formatting at scale

Chose Formatting-based chunking over Pure conceptual-boundary chunking.

Rationale: Conceptual chunking is ideal, but formatting is the realistic signal available at scale.

“the ideal way to chunk your context would be along conceptual boundaries”transcript, stated
“what we've seen at scale is the only realistic way to chunk your embeddings other than just sentences or you know something similar to that is to use formatting”transcript, stated

Gotchas (what bit them)

PDF ingestion is unreliable even when files claim to be PDFs.

Root cause: PDFs include decades of extensions, invalid generator output, and poorly photocopied documents.

Resolution: Use Textract where possible and convert problematic PDFs to JPEG for backup OCR.

“various file formats that are called PDF may not actually be a valid PDF and PDF generator plugins that are associated with various websites they can often return invalid PDFs”transcript, stated
“you can actually transform the PDF into a JPEG and then reprocesses that file as a JPEG”transcript, stated

Website scraping tools may return poorly manicured data.

Root cause: HTML data is not well structured across varied frameworks and WYSIWYG editors.

Resolution: Inspect each website and choose the relevant HTML elements for that site.

“with the V variety of web Frameworks and wizzywig editors for creating websites HTML data is actually not that well structured”transcript, stated
“manual inspection of various websites and understanding the HTML elements that are most relevant for that particular website”transcript, stated

Formatting-based chunks only approximate conceptual boundaries.

Root cause: The realistic chunking signal at scale is often Markdown or document formatting, not true semantic separation.

Resolution: Use formatting as a proxy while recognizing it can differ from actual conceptual boundaries.

“this is sort of a a proxy for contextual separation but it is not equivalent to contextual separation”transcript, stated

Evaluation

The talk does not describe a formal production evaluation harness; it describes practical comparison dimensions such as latency, recall/accuracy, MTEB ranking, context length, and data fit.

Metrics: recall or accuracy versus latency · MTEB leaderboard performance · embedding context length · vector dimensionality and storage size

3 supporting quotes
“different tradeoffs as far as recall or accuracy versus the latency associated with the request”transcript, stated
“the state-of-the-art uh embeddings models on the mte leader Bard is not Ada embedding it varies depending on what particular evaluation metric”transcript, stated
“how many dimensions are the vectors how much space is that going to take up in your database”transcript, stated

Outcomes

No deployment adoption numbers are given; the strongest scale evidence is the speaker's statement that formatting-based chunking is what they have seen at scale.

“so much of the work that has to be done to make these models performant is done upfront in that reprocessing and processing of your data”transcript, stated
“what we've seen at scale is the only realistic way to chunk your embeddings other than just sentences or you know something similar to that is to use formatting”transcript, stated