arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2505.14524cs.AI
收藏

受保护的查询路由用于大型语言模型

Guarded Query Routing for Large Language Models

Faculty of Informatics(信息学系);Information Technologies, Slovak University of Technology in Bratislava(信息技术,斯洛伐克技术大学布拉迪斯拉发分校);Centre for Machine Learning, University of Southern Denmark(机器学习中心,丹麦南部大学)

Richard Šléher, William Brach, Tibor Sloboda, Kristián Košťál, Lukas Galke

AI总结:

本文提出受保护的查询路由基准,对比不同方法在准确率与速度上的表现,发现WideMLP在两者之间取得最佳平衡。

摘要:

查询路由,即将用户查询路由到不同的大型语言模型(LLM)端点的任务,可以被视为一个文本分类问题。然而,分布外的查询必须得到妥善处理,因为这些可能涉及无关的领域、其他语言的查询,甚至包含不安全的文本。因此,我们研究了一个受保护的查询路由问题,首先介绍了受保护的查询路由基准(GQR-Bench,作为Python包gqr发布),涵盖了三个示例目标领域(法律、金融和医疗),并七个数据集以测试对分布外查询的鲁棒性。我们随后使用GQR-Bench来对比LLM基于路由机制(GPT-4o-mini、Llama-3.2-3B和Llama-3.1-8B)、标准LLM基于守卫方法(LlamaGuard和NVIDIA NeMo Guardrails)、连续词袋分类器(WideMLP、fastText)和传统机器学习模型(SVM、XGBoost)的有效性和效率。我们的结果表明,增强有领域检测能力的WideMLP在准确率(88%)和速度(<4ms)之间取得了最佳平衡。基于嵌入的fastText在速度(<1ms)方面表现优异,准确率(80%)可以接受,而LLM在准确率(91%)方面最高,但相对较慢(本地Llama-3.1:8B为62ms,远程GPT-4o-mini为669ms)。我们的发现挑战了自动依赖LLM进行(受保护的)查询路由,并为实际应用提供了具体的建议。源代码可用:https://github.com/williambrach/gqr。

英文摘要:

Query routing, the task to route user queries to different large language model (LLM) endpoints, can be considered as a text classification problem. However, out-of-distribution queries must be handled properly, as those could be about unrelated domains, queries in other languages, or even contain unsafe text. Here, we thus study a guarded query routing problem, for which we first introduce the Guarded Query Routing Benchmark (GQR-Bench, released as Python package gqr), covers three exemplary target domains (law, finance, and healthcare), and seven datasets to test robustness against out-of-distribution queries. We then use GQR-Bench to contrast the effectiveness and efficiency of LLM-based routing mechanisms (GPT-4o-mini, Llama-3.2-3B, and Llama-3.1-8B), standard LLM-based guardrail approaches (LlamaGuard and NVIDIA NeMo Guardrails), continuous bag-of-words classifiers (WideMLP, fastText), and traditional machine learning models (SVM, XGBoost). Our results show that WideMLP, enhanced with out-of-domain detection capabilities, yields the best trade-off between accuracy (88%) and speed (<4ms). The embedding-based fastText excels at speed (<1ms) with acceptable accuracy (80%), whereas LLMs yield the highest accuracy (91%) but are comparatively slow (62ms for local Llama-3.1:8B and 669ms for remote GPT-4o-mini calls). Our findings challenge the automatic reliance on LLMs for (guarded) query routing and provide concrete recommendations for practical applications. Source code is available: https://github.com/williambrach/gqr.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑