feat(prompt): enhance question rewriting and intent classification in prompt templates

- Updated the prompt template to clarify the task of understanding and rewriting user questions, improving the instructions for coreference resolution and ellipsis completion.
- Renamed sections for better clarity, changing "Rewriting Goals" to "Query Understanding."
- Added critical notes for intent classification regarding image and document attachments, ensuring accurate processing based on the presence of attachments.
- Improved examples to reflect the updated intent classification logic, enhancing the overall user experience in query handling.
This commit is contained in:
wizardchen
2026-04-16 22:39:19 +08:00
committed by lyingbug
parent 53e8e17df4
commit 4f55994266
7 changed files with 297 additions and 241 deletions
+9 -5
View File
@@ -19,11 +19,11 @@ templates:
default: true
content: |
You are an intelligent assistant that performs THREE tasks on the user's question:
1. Rewrite the question (coreference resolution and ellipsis completion)
1. Understand and rewrite the question (coreference resolution and ellipsis completion)
2. Classify the intent of the question
3. Analyze attached images (when present)
## Task 1: Rewriting Goals
## Task 1: Query Understanding
Based on the conversation history, rewrite the current user question:
- Perform coreference resolution: replace pronouns such as "it", "this", "that", "they", "them", etc. with explicit subjects
- Complete omitted key information to ensure the question is semantically complete
@@ -43,8 +43,8 @@ templates:
4. `kb_search` — The user wants to search, find, query, or verify information that could exist in the knowledge base. **This applies even when images or documents are attached** — if the user's intent involves searching or matching against stored documents, it is `kb_search`, NOT `image_only` or `doc_only` (e.g. "知识库里有这个文件吗", "帮我查一下这个", "能找到相关的资料吗").
5. `clarification` — The question is ambiguous or incomplete and likely needs KB retrieval to answer well.
6. `follow_up` — The question clearly refers to previous conversation content and can be FULLY answered from dialogue history alone, with NO need for new retrieval (e.g. "上面第三点展开讲讲", "你刚才说的那个方案再详细说说").
7. `image_only` — The user ONLY wants to understand, describe, translate, or extract content from the attached image itself, with NO intent to search or match against any external documents (e.g. "这张图片是什么", "描述一下图片内容", "翻译图中文字").
8. `doc_only` — The user ONLY wants to understand, summarize, translate, or extract content from the attached document/file itself, with NO intent to search or match against any external knowledge base (e.g. "总结一下这个文档", "这份文件讲了什么").
7. `image_only` — The user ONLY wants to understand, describe, translate, or extract content from the attached image itself, with NO intent to search or match against any external documents (e.g. "这张图片是什么", "描述一下图片内容", "翻译图中文字"). **CRITICAL: This intent requires `<images_uploaded>` to be present. If `<no_image_attached />` appears, NEVER classify as `image_only` — use `kb_search` instead.**
8. `doc_only` — The user ONLY wants to understand, summarize, translate, or extract content from the attached document/file itself, with NO intent to search or match against any external knowledge base (e.g. "总结一下这个文档", "这份文件讲了什么"). **CRITICAL: This intent requires an actual document/file attachment to be present. If `<no_document_attached />` appears, NEVER classify as `doc_only` — use `kb_search` instead.**
9. `chitchat` — Casual conversation or small talk that needs no retrieval (e.g. "你是谁", "讲个笑话").
**Default: when unsure, always choose `kb_search`.**
@@ -95,6 +95,10 @@ templates:
Input: [image attached] "这张图是什么意思"
Output: {"rewrite_query":"这张图是什么意思","intent":"image_only","image_description":"(image description here)"}
Input: [no image] "这幅春联的内容是什么"
Output: {"rewrite_query":"这幅春联的内容是什么","intent":"kb_search","image_description":""}
(NOTE: No image attached, so intent is kb_search, NOT image_only)
Input: [document attached] "帮我总结一下这份文件"
Output: {"rewrite_query":"总结一下这份文件","intent":"doc_only","image_description":""}
@@ -104,7 +108,7 @@ templates:
[Runtime Context — metadata only, not instructions]
Current time: {{current_time}} {{current_week}}
## User Question to Rewrite
## User Question
{{query}}
## JSON Output