atlasbot: tune synth and followup style
This commit is contained in:
parent
d8249bba37
commit
d9489f8790
@ -483,8 +483,17 @@ class AnswerEngine:
|
|||||||
plan: ModePlan,
|
plan: ModePlan,
|
||||||
call_llm: Callable[..., Any],
|
call_llm: Callable[..., Any],
|
||||||
) -> str:
|
) -> str:
|
||||||
|
style_hint = _style_hint(classify)
|
||||||
if not subanswers:
|
if not subanswers:
|
||||||
prompt = prompts.SYNTHESIZE_PROMPT + "\nQuestion: " + question
|
prompt = (
|
||||||
|
prompts.SYNTHESIZE_PROMPT
|
||||||
|
+ "\nQuestion: "
|
||||||
|
+ question
|
||||||
|
+ "\nStyle: "
|
||||||
|
+ style_hint
|
||||||
|
+ "\nQuestionType: "
|
||||||
|
+ (classify.get("question_type") or "unknown")
|
||||||
|
)
|
||||||
return await call_llm(prompts.SYNTHESIZE_SYSTEM, prompt, context=context, model=plan.model, tag="synth")
|
return await call_llm(prompts.SYNTHESIZE_SYSTEM, prompt, context=context, model=plan.model, tag="synth")
|
||||||
draft_prompts = []
|
draft_prompts = []
|
||||||
for idx in range(plan.drafts):
|
for idx in range(plan.drafts):
|
||||||
@ -492,6 +501,10 @@ class AnswerEngine:
|
|||||||
prompts.SYNTHESIZE_PROMPT
|
prompts.SYNTHESIZE_PROMPT
|
||||||
+ "\nQuestion: "
|
+ "\nQuestion: "
|
||||||
+ question
|
+ question
|
||||||
|
+ "\nStyle: "
|
||||||
|
+ style_hint
|
||||||
|
+ "\nQuestionType: "
|
||||||
|
+ (classify.get("question_type") or "unknown")
|
||||||
+ "\nSubanswers:\n"
|
+ "\nSubanswers:\n"
|
||||||
+ "\n".join([f"- {item}" for item in subanswers])
|
+ "\n".join([f"- {item}" for item in subanswers])
|
||||||
+ f"\nDraftIndex: {idx + 1}"
|
+ f"\nDraftIndex: {idx + 1}"
|
||||||
@ -982,6 +995,14 @@ def _default_scores() -> AnswerScores:
|
|||||||
return AnswerScores(confidence=60, relevance=60, satisfaction=60, hallucination_risk="medium")
|
return AnswerScores(confidence=60, relevance=60, satisfaction=60, hallucination_risk="medium")
|
||||||
|
|
||||||
|
|
||||||
|
def _style_hint(classify: dict[str, Any]) -> str:
|
||||||
|
style = (classify.get("answer_style") or "").strip().lower()
|
||||||
|
qtype = (classify.get("question_type") or "").strip().lower()
|
||||||
|
if style == "insightful" or qtype in {"open_ended", "planning"}:
|
||||||
|
return "insightful"
|
||||||
|
return "direct"
|
||||||
|
|
||||||
|
|
||||||
def _needs_evidence_fix(reply: str, classify: dict[str, Any]) -> bool:
|
def _needs_evidence_fix(reply: str, classify: dict[str, Any]) -> bool:
|
||||||
if not reply:
|
if not reply:
|
||||||
return False
|
return False
|
||||||
|
|||||||
@ -81,12 +81,15 @@ SUBANSWER_PROMPT = (
|
|||||||
SYNTHESIZE_SYSTEM = (
|
SYNTHESIZE_SYSTEM = (
|
||||||
CLUSTER_SYSTEM
|
CLUSTER_SYSTEM
|
||||||
+ " Synthesize a final answer from sub-answers. "
|
+ " Synthesize a final answer from sub-answers. "
|
||||||
+ "Keep it conversational and grounded."
|
+ "Keep it conversational and grounded. "
|
||||||
|
+ "Do not say 'based on the snapshot' or 'based on the context'."
|
||||||
)
|
)
|
||||||
|
|
||||||
SYNTHESIZE_PROMPT = (
|
SYNTHESIZE_PROMPT = (
|
||||||
"Write a final response to the user. "
|
"Write a final response to the user. "
|
||||||
"Use sub-answers as evidence, avoid raw metric dumps unless asked."
|
"Use sub-answers as evidence, avoid raw metric dumps unless asked. "
|
||||||
|
"If Style is insightful or the question is open-ended, choose 1-2 salient points and explain why they stand out. "
|
||||||
|
"If Style is direct, answer concisely with the specific value requested."
|
||||||
)
|
)
|
||||||
|
|
||||||
EVIDENCE_FIX_SYSTEM = (
|
EVIDENCE_FIX_SYSTEM = (
|
||||||
@ -188,7 +191,8 @@ FOLLOWUP_SYSTEM = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
FOLLOWUP_PROMPT = (
|
FOLLOWUP_PROMPT = (
|
||||||
"Answer the follow-up using provided evidence. Be conversational and concise."
|
"Answer the follow-up using provided evidence. "
|
||||||
|
"Be conversational and concise, and avoid restating all metrics."
|
||||||
)
|
)
|
||||||
|
|
||||||
SELECT_CLAIMS_PROMPT = (
|
SELECT_CLAIMS_PROMPT = (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user