利用轻量级分类器 Jev 优化 RAG Agent 路由与验证
This is how I used Jev in my RAG agent.
提供了一套可复用的 RAG 架构优化方案,用低成本分类器解决路由、幻觉和记忆污染等痛点,参数和提示词细节丰富,值得 Agent 开发者参考落地。
I ignored Jev at first because it looked like viral marketing. Later it occurred to me that a small & general classifier might be useful in plenty of places. I was building a RAG agent anyway, so I tried it.
起初我忽略了 Jev,因为它看起来像是病毒式营销。后来我意识到,一个小型且通用的分类器可能在许多地方都很有用。反正我当时正在构建一个 RAG 智能体,于是我就试了一下。
Here is where I use it.
以下是我使用它的方式。
Routing. Every question used to go through the same pipeline. Now the classifier decides if it's local search (RAG needed), file organization, an extra task (do not need RAG), or a change to the agent's own settings. It also decides whether to decompose the question and which datasources to search. My RAG agent supports various search through telegram, whatsapp, mail, browser history... so routing data sources were crucial.
路由。过去每个问题都会经过相同的处理流程。现在,分类器会判断该问题是本地搜索(需要 RAG)、文件整理、额外任务(不需要 RAG),还是对智能体自身设置的更改。它还会决定是否需要将问题分解以及应搜索哪些数据源。我的 RAG 智能体支持通过 Telegram、WhatsApp、邮件、浏览器历史等多种方式进行搜索,因此路由数据源至关重要。
Checking the first answer. The agent answers fast before long agentic trajectories, then the classifier says whether the answer needs follow-up. Before that, either everything got verified or nothing did. Wording mattered: "does this need correction or more research?" flagged almost every good answer, while "is it unanswered or uncertain?" worked much better. (bad question to Jev leads bad results)
检查首个答案。智能体在漫长的代理轨迹之前能快速作答,随后分类器会判断该答案是否需要后续跟进。在此之前,要么所有答案都被验证,要么都没有。措辞很关键:“这是否需要纠正或进一步研究?”几乎标记了每一个好答案,而“它是否未回答或不确定?”则效果要好得多。(向 Jev 提出糟糕的问题会导致糟糕的结果)
Citations. LLMs sometimes cite a chunk unrelated to the sentence, like a footer or a generic intro. Each cited chunk now gets a relevant/not relevant check, and unrelated ones are dropped.
引用。LLM 有时会引用与句子无关的文本块,比如页脚或通用引言。现在每个被引用的文本块都会经过相关/不相关的检查,不相关的内容会被丢弃。
Memory. The memory of past questions was filling up with plausible but wrong evidence. Now only evidence classified as really supporting the answer is stored.
记忆。过去问题的记忆库中充斥着看似合理但实际错误的证据。现在,只有被分类为真正支持答案的证据才会被存储。
Approval gate Pretty normal use-case; Classify that bash call is safe to run or not.
审批关卡。这是一个非常常规的用例;分类判断 bash 调用是否可以安全运行。
Some practical notes: batch many questions into one call. If the classifier is down, fall back to the sLLM calls. Test your question wording on real inputs, since it changes results a lot. And tell it things it can't see, like whether a target file exists.
一些实用建议:将多个问题批量放入一次调用中。如果分类器不可用,则回退到 sLLM 调用。在实际输入上测试你的问题措辞,因为措辞会对结果产生很大影响。并且告知它一些它看不到的信息,例如目标文件是否存在。
If you wanna use RAG agents that i am building on It's open source, so try it: https://github.com/Marker-Inc-Korea/AutoRAG (the Jev code is in src/agent/). I think it's the most satisfying open-source RAG project out there.
如果你想使用我正在构建的 RAG 智能体,它是开源的,欢迎尝试:https://github.com/Marker-Inc-Korea/AutoRAG(Jev 的代码位于 src/agent/ 中)。我认为这是目前最让人满意的开源 RAG 项目。
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力