除了模型本身,无问芯穹还开源了基于 Megrez-3B-Instruct 的 Web-Search 方案,可本地搭建类似 Kimi 或 Perplexity 的搜索助手。
1. 技术架构
该项目并非简单的 RAG 总结,而是包含以下工程细节:
摘要过程: 去除无效网页信息,缓存内容以提高回复效果。
工具调用时机: 模型能准确判断何时调用 Search Tool,避免日常问题过度依赖搜索引擎。
多轮对话理解: 在检索过程中保持上下文一致性。
引用格式: 输出带 [[citation:x]] 格式的参考文献,增强可信度。
2. 核心 Prompt 设计
项目使用了特定的 Prompt 模板来控制生成行为。
SUMMARY_PROMPT_TEMPLATE = (
'从信息中总结能够回答问题的相关内容,要求简明扼要不能完全照搬原文。直接返回总结不要说其他话,如果没有相关内容则返回"无相关内容", 返回内容为中文。\n\n'"<问题>{question}</问题>\n""<信息>{context}</信息>"
)
OBSERVATION_PROMPT_TEMPLATE = (
"You will be given a set of related contexts to the question, ""each starting with a reference number like [[citation:x]], where x is a number. ""Please use the context and cite the context at the end of each sentence if applicable.\n\n""Please cite the contexts with the reference numbers, in the format [citation:x]. ""If a sentence comes from multiple contexts, please list all applicable citations, like [citation:3][citation:5]. ""If the context does not provide relevant information to answer the question, ""inform the user that there is no relevant information in the search results and that the question cannot be answered."# noqa: E501"\n\n""Other than code and specific names and citations, your answer must be written in Chinese.\n\n""Ensure that your response is concise and clearly formatted. ""Group related content together and use Markdown points or lists where appropriate.\n\n""Remember, summarize and don't blindly repeat the contexts verbatim. And here is the user question:\n""{question}\n""Here is the keywords of the question:\n""{keywords}\n\n""Here are the set of contexts:\n\n""{context}"
)