Adam Cseresznye commited on
Commit ·
3fc8d67
1
Parent(s): 222302d
Enhance intent analysis
Browse files
agents/query_optimization_agent.py
CHANGED
|
@@ -148,14 +148,19 @@ class QueryOptimizationAgent:
|
|
| 148 |
|
| 149 |
**Strategy A: Expansion (Default)**
|
| 150 |
Use this for single-topic or straightforward queries.
|
| 151 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
|
| 153 |
Output Format (JSON):
|
| 154 |
{{
|
| 155 |
"strategy": "expansion",
|
| 156 |
"final_rephrase": "Clear natural language question for semantic search",
|
| 157 |
"primary": "3-6 specific keywords",
|
| 158 |
-
"broad": "3-
|
| 159 |
"alternative": "3-6 keywords focusing on limitations or debates"
|
| 160 |
}}
|
| 161 |
|
|
|
|
| 148 |
|
| 149 |
**Strategy A: Expansion (Default)**
|
| 150 |
Use this for single-topic or straightforward queries.
|
| 151 |
+
|
| 152 |
+
**INTENT ANALYSIS (Crucial):**
|
| 153 |
+
Analyze the user's intent to optimize the 'broad' field:
|
| 154 |
+
1. **Overview/Consensus needed?** (e.g., "What is...", "How does...", "Summary of...") -> Set 'broad' to keywords + "review" OR "survey" OR "state of the art".
|
| 155 |
+
2. **Latest News needed?** (e.g., "Recent...", "Newest...", "Updates on...") -> Set 'broad' to keywords + "recent" OR "advances" OR "novel".
|
| 156 |
+
3. **Specific Details?** -> Keep 'broad' as general synonyms.
|
| 157 |
|
| 158 |
Output Format (JSON):
|
| 159 |
{{
|
| 160 |
"strategy": "expansion",
|
| 161 |
"final_rephrase": "Clear natural language question for semantic search",
|
| 162 |
"primary": "3-6 specific keywords",
|
| 163 |
+
"broad": "3-6 keywords optimized for INTENT (e.g., include 'review' or 'recent' if applicable)",
|
| 164 |
"alternative": "3-6 keywords focusing on limitations or debates"
|
| 165 |
}}
|
| 166 |
|
agents/synthesis_agent.py
CHANGED
|
@@ -65,7 +65,10 @@ CITATION_QA_TEMPLATE = (
|
|
| 65 |
" - **Definitions:** Define ONLY non-standard acronyms on first use.\n\n"
|
| 66 |
"4. **PROTOCOL FOR INSUFFICIENT DATA:**\n"
|
| 67 |
" - If the provided chunks do not contain the answer, do not hallucinate.\n"
|
| 68 |
-
" - Output exactly: **Verdict: Insufficient Evidence.** followed by a brief explanation of what is missing.\n
|
|
|
|
|
|
|
|
|
|
| 69 |
"5. **CITATION RULES (STRICT):**\n"
|
| 70 |
" - **Valid Source Range:** You have access to Sources 1 through {max_id}. **ANY CITATION > {max_id} IS A HALLUCINATION.**\n"
|
| 71 |
" - **Atomic Citations:** Every specific claim must be cited immediately [N].\n"
|
|
|
|
| 65 |
" - **Definitions:** Define ONLY non-standard acronyms on first use.\n\n"
|
| 66 |
"4. **PROTOCOL FOR INSUFFICIENT DATA:**\n"
|
| 67 |
" - If the provided chunks do not contain the answer, do not hallucinate.\n"
|
| 68 |
+
" - Output exactly: **Verdict: Insufficient Evidence.** followed by a brief explanation of what is missing.\n"
|
| 69 |
+
" - If you know of a major scientific consensus that is NOT in the sources, you may add a final section: \n"
|
| 70 |
+
" '### Missing Context'\n"
|
| 71 |
+
" 'Major theories such as [Concept] were not found in the retrieved papers.' (DO NOT CITE THIS).\n\n"
|
| 72 |
"5. **CITATION RULES (STRICT):**\n"
|
| 73 |
" - **Valid Source Range:** You have access to Sources 1 through {max_id}. **ANY CITATION > {max_id} IS A HALLUCINATION.**\n"
|
| 74 |
" - **Atomic Citations:** Every specific claim must be cited immediately [N].\n"
|