arXiv:2512.06660cs.CRcs.AI2025-12被引 3

用小型语言模型实现安全查询的自然语言转KQL,又快又省

Towards Small Language Models for Security Query Generation in SOC Workflows

  • 设计三组件框架:提示优化、轻量微调、两阶段生成与判别
  • 在微软数据集上达98.7%语法准确率,比GPT-5节省10倍成本
  • 适合安全运营中心快速部署,降低对专家的依赖

安全运营中心分析师常使用Kusto查询语言(KQL)处理海量遥测数据。编写正确KQL需专业技能,成为团队扩展时的瓶颈。本文探讨小型语言模型(SLMs)在企业安全场景下实现自然语言到KQL转换的可行性。提出三要素框架:首先,采用轻量检索与错误感知提示,提升SLM对常见解析失败的鲁棒性;其次,通过LoRA微调结合推理链蒸馏,在不增加模型规模的前提下迁移教师模型的推理能力;第三,设计两阶段架构,由SLM生成候选查询,再由低成本大模型判别器进行模式感知的精炼与选择。在微软NL2KQL Defender评估数据集上,该方法达到0.987的语法准确率和0.906的语义准确率;在Microsoft Sentinel数据上,语法准确率达0.964,语义准确率为0.831。整体成本较GPT-5降低最高10倍,证明了小型模型在安全查询生成中的实用性与可扩展性。

原文摘要 · Abstract (English)

Analysts in Security Operations Centers routinely query massive telemetry streams using Kusto Query Language (KQL). Writing correct KQL requires specialized expertise, and this dependency creates a bottleneck as security teams scale. This paper investigates whether Small Language Models (SLMs) can enable accurate, cost-effective natural-language-to-KQL translation for enterprise security. We propose a three-knob framework targeting prompting, fine-tuning, and architecture design. First, we adapt existing NL2KQL framework for SLMs with lightweight retrieval and introduce error-aware prompting that addresses common parser failures without increasing token count. Second, we apply LoRA fine-tuning with rationale distillation, augmenting each NLQ-KQL pair with a brief chain-of-thought explanation to transfer reasoning from a teacher model while keeping the SLM compact. Third, we propose a two-stage architecture that uses an SLM for candidate generation and a low-cost LLM judge for schema-aware refinement and selection. We evaluate nine models (five SLMs and four LLMs) across syntax correctness, semantic accuracy, table selection, and filter precision, alongside latency and token cost. On Microsoft's NL2KQL Defender Evaluation dataset, our two-stage approach achieves 0.987 syntax and 0.906 semantic accuracy. We further demonstrate generalizability on Microsoft Sentinel data, reaching 0.964 syntax and 0.831 semantic accuracy. These results come at up to 10x lower token cost than GPT-5, establishing SLMs as a practical, scalable foundation for natural-language querying in security operations.

小模型安全分析自然语言查询KQL

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。