Implementation:416rehman DeepZero GenericLLM
| Knowledge Sources | |
|---|---|
| Domains | LLM_Assessment, Map |
| Last Updated | 2026-10-27 00:00 GMT |
Overview
Built-in MapProcessor that renders a Jinja2 prompt template with upstream sample data and artifacts, sends it to an LLM via the LLMProvider, and classifies the response.
Description
The GenericLLM class is a built-in MapProcessor that performs LLM-based assessment of pipeline samples. It is the final analytical stage in the BYOVD pipeline, where an LLM receives all upstream context (decompiled code, dispatch tables, semgrep findings, PE metadata) and produces a vulnerability verdict.
Key operations:
- Prompt rendering: the prompt config value is a Jinja2 template file path (or inline string). The template is rendered with variables built from upstream data:
- sample_name, sample_path: identity of the sample
- history: flattened dict of all upstream stage data
- config: the processor's own config
- Artifact files: JSON and text files in the sample directory are loaded as template variables, with paths folded via template_key_for_artifact() (e.g., "decompiled/dispatch_ioctl.c" → "decompiled_dispatch_ioctl_c")
- Context budget: artifacts exceeding max_context_tokens (default 900K tokens × 4 chars/token) are skipped or truncated to avoid exceeding the LLM's context window.
- LLM call: rendered prompt is sent via ctx.llm.complete() with configurable retry/backoff.
- Classification: the classify_by config is a regex matched against the first 200 chars of the response to extract a verdict (e.g., \\[VULNERABLE\\]|\\[SAFE\\]).
- Output caching: the response is written to output_file (default "assessment.md"). If the file already exists, the cached response is used without calling the LLM.
Usage
- BYOVD LLM assessment: prompt: "pipelines/loldrivers/assessment.j2", output_file: "assessment.md", classify_by: "\\[VULNERABLE\\]|\\[SAFE\\]"
- Custom assessment: provide a Jinja2 template referencing upstream data names declared by previous stages' provides.
Code Reference
Source Location
- Repository: DeepZero
- File: src/deepzero/stages/llm.py
Signature
class GenericLLM(MapProcessor):
description = "generic LLM assessment - sends context to an LLM via a jinja2 prompt template"
provides = ("llm_output_file", "classification")
def validate(self, ctx: ProcessorContext) -> list[str]: ...
def process(self, ctx: ProcessorContext, entry: ProcessorEntry) -> ProcessorResult: ...
Import
from deepzero.stages.llm import GenericLLM
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| prompt | str | Yes (config) | Jinja2 template file path or inline prompt |
| output_file | str | No (config) | Output filename (default "assessment.md") |
| classify_by | str | No (config) | Regex to extract classification from response |
| max_context_tokens | int | No (config) | Max context size (default 900000) |
| max_retries | int | No (config) | LLM retry count (default 3) |
| backoff | dict | No (config) | Backoff config: initial, max, decay |
| ctx.llm | LLMProtocol | Yes (runtime) | LLM provider from pipeline context |
Outputs
| Name | Type | Description |
|---|---|---|
| returns | ProcessorResult | ok with artifacts and classification data |
| artifacts["llm_output"] | str | The output_file name (e.g., "assessment.md") |
| data["llm_output_file"] | str | The output file name |
| data["classification"] | str | Extracted verdict (e.g., "vulnerable", "safe") |
Usage Examples
BYOVD Assessment Stage
stages:
- name: assess
processor: generic_llm
config:
prompt: "pipelines/loldrivers/assessment.j2"
output_file: "assessment.md"
classify_by: '\[VULNERABLE\]|\[SAFE\]'
max_context_tokens: 900000
max_retries: 3
backoff:
initial: 2.0
max: 60.0
decay: 0.7
Jinja2 Template Example
{# assessment.j2 #}
Analyze this Windows kernel driver for BYOVD vulnerability potential.
## Driver Information
- Name: {{ sample_name }}
- Priority Score: {{ history.discover.priority_score if history.discover else 'N/A' }}
- IOCTL Count: {{ history.decompile.ioctl_count if history.decompile else 0 }}
## Decompiled Dispatch Routine
{{ decompiled_dispatch_ioctl_c }}
## Semgrep Findings ({{ history.semgrep_scanner.finding_count if history.semgrep_scanner else 0 }})
{{ findings_json if findings_json else 'No findings' }}
Respond with [VULNERABLE] or [SAFE] and explain your reasoning.