用文本提示让大模型零样本检测网络入侵,效果接近传统方法。
From Flows to Words: Can Zero-/Few-Shot LLMs Detect Network Intrusions? A Grammar-Constrained, Calibrated Evaluation on UNSW-NB15
- 将网络流量转为带领域标志的文本,用语法约束输出提升可靠性。
- 7B模型在200条数据上达宏F1 0.78,3B模型在1000条上达F1 0.68。
- 无需训练即可生成可读结果,适合快速验证和解释性需求者。
大型语言模型(LLMs)能处理自然语言输入,但其在不微调情况下用于入侵检测的作用尚不明确。本研究通过将每个网络流转换为紧凑的文本记录,并添加轻量级、领域启发的布尔标志(不对称性、突发率、TTL异常、时间戳异常、罕见服务/状态、短持续突发),在UNSW-NB15数据集上评估纯提示方法。为减少输出漂移并支持度量,模型被约束生成结构化且语法正确的响应,并在小规模开发集上校准单一决策阈值。在相同划分下,对比零样本、指令引导和少样本提示与强表格及神经基线,报告准确率、精确率、召回率、F1及宏评分。实证表明,无指导提示不可靠,而指令加标志显著提升检测质量;校准评分进一步稳定结果。在200条平衡流上,7B指令微调模型的宏F1接近0.78;3B模型在1000条示例上通过少样本提示与校准达到近0.68的F1。当评估集扩大至2000条时,决策质量下降,揭示对覆盖范围和提示方式的敏感性。表格基线仍更稳定且更快,但纯提示流程无需梯度训练,产生可读输出,可通过指令和标志轻松适应。贡献包括流量到文本的协议、可解释提示机制、阈值校准方法、系统性基线比较,以及包含提示、语法、指标和图表的可复现包。
原文摘要 · Abstract (English)
Large Language Models (LLMs) can reason over natural-language inputs, but their role in intrusion detection without fine-tuning remains uncertain. This study evaluates a prompt-only approach on UNSW-NB15 by converting each network flow to a compact textual record and augmenting it with lightweight, domain-inspired boolean flags (asymmetry, burst rate, TTL irregularities, timer anomalies, rare service/state, short bursts). To reduce output drift and support measurement, the model is constrained to produce structured, grammar-valid responses, and a single decision threshold is calibrated on a small development split. We compare zero-shot, instruction-guided, and few-shot prompting to strong tabular and neural baselines under identical splits, reporting accuracy, precision, recall, F1, and macro scores. Empirically, unguided prompting is unreliable, while instructions plus flags substantially improve detection quality; adding calibrated scoring further stabilizes results. On a balanced subset of two hundred flows, a 7B instruction-tuned model with flags reaches macro-F1 near 0.78; a lighter 3B model with few-shot cues and calibration attains F1 near 0.68 on one thousand examples. As the evaluation set grows to two thousand flows, decision quality decreases, revealing sensitivity to coverage and prompting. Tabular baselines remain more stable and faster, yet the prompt-only pipeline requires no gradient training, produces readable artifacts, and adapts easily through instructions and flags. Contributions include a flow-to-text protocol with interpretable cues, a calibration method for thresholding, a systematic baseline comparison, and a reproducibility bundle with prompts, grammar, metrics, and figures.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。