Implementation:AISecurityLab Hackagent Labelling
| Knowledge Sources | |
|---|---|
| Domains | Datasets, Classification |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
Concrete taxonomy classifier that labels unlabelled goals with risk category and subcategory using an LLM model, batching goals and failing open on errors, provided by the HackAgent datasets package.
Description
label_goals() is an async function that takes a list of Goal objects and a ClassifierModel (a protocol with acomplete()). It batches goals (default 20 per batch), asks the model to classify each into one category and subcategory, parses the numbered-line reply, and returns goals with labels. Goals already labelled (from intents) are left alone. The classifier fails open: after the first failed call, the model is not asked again, and unlabelled goals get UNCLASSIFIED labels.
Usage
- Campaign goal labelling: The campaign runner calls label_goals() to tag goals before running attacks.
Code Reference
Source Location
- Repository: AISecurityLab_Hackagent
- File: hackagent/datasets/labelling.py
Signature
async def label_goals(
goals: Sequence[Goal],
model: ClassifierModel,
*,
batch_size: int = BATCH_SIZE,
concurrency: int = 1,
) -> list[Goal]: ...
def is_labelled(goal: Goal) -> bool: ...
Import
from hackagent.datasets.labelling import label_goals, is_labelled
Usage Examples
Label Goals with a Model
import asyncio
from hackagent.datasets.labelling import label_goals
from hackagent.core.contracts import Goal
goals = [Goal(text="How to hack a wifi", index=0)]
labelled = asyncio.run(label_goals(goals, model=my_classifier))
for g in labelled:
print(g.text, g.labels)