Refine system prompt for keyword extraction
This commit is contained in:
@@ -6,8 +6,10 @@ use tracing::debug;
|
||||
/// Smartwatch-aware keyword-extraction prompt: leading noun must come from
|
||||
/// the transcript itself (no hallucination) so the doctor can recognize the
|
||||
/// case from the watch face. English instructions for small-model
|
||||
/// robustness, German output.
|
||||
const SYSTEM_PROMPT: &str = "You are a keyword-extraction assistant for a German medical dictation app. Given a transcript, output a short German one-line label for the case.\n\nCRITICAL — silence rule:\nIf the transcript is empty, silent, or contains no identifiable medical keyword, return no text at all. Leave your answer completely blank. Do NOT echo the words 'empty', 'nothing', 'none', 'N/A', 'null', '-', a placeholder, or any description of emptiness. Emit zero characters.\n\nRules:\n- 2-4 words, at most 50 characters, single line.\n- Start with the most important noun from the transcript: body region, organ, imaging modality, or key finding.\n- Use ONLY terms that appear in the transcript. Do not invent, translate, or paraphrase. Do not add diagnoses the doctor did not mention.\n- No filler prefixes: \"Patient\", \"Fall\", \"Verdacht auf\", \"Untersuchung\", \"Diktat\", articles.\n- No intensifiers (\"massiv\", \"ausgeprägt\", \"deutlich\", \"hochgradig\").\n- No quotes, no trailing period, no introductory phrase.\n- If the doctor explicitly names the case (\"Bezeichnung: X\", \"Fall-ID: X\"), start with that exact string.\n- Respond in German. One line only.\n\nExamples:\n\nTranscript: \"Bezeichnung: Schulter links. Patient klagt über...\"\nOutput: Schulter links\n\nTranscript: \"...V.a. Bandscheibenvorfall in der LWS, Schmerzen strahlen...\"\nOutput: LWS, V.a. Bandscheibenvorfall\n\nREMINDER: For silent, empty, or non-medical transcripts, emit zero characters. Do not write the words 'empty', 'nothing', 'none', or any placeholder — just produce no output.";
|
||||
/// robustness, German output. Priority-ordered so a medical keyword always
|
||||
/// wins, with a fallback for non-medical narrative transcripts so the label
|
||||
/// stays useful for case recognition.
|
||||
const SYSTEM_PROMPT: &str = "You are a keyword-extraction assistant for a German medical dictation app. Given a transcript, output a short German one-line label so the doctor can recognize the case on the watch face.\n\nPriority order for the leading noun (apply strictly top-down):\n1. Explicit case label: if the transcript contains \"Bezeichnung: X\" or \"Fall-ID: X\", use X verbatim as the label.\n2. Medical entity: diagnosis, important body region, organ, imaging modality, or key finding that appears in the transcript.\n3. Fallback: the most distinctive noun(s) from the transcript — event, object, role, or context — BUT ONLY if no medical entity from rule 2 is present.\n\nSilence rule (narrow):\nOnly when the transcript is completely empty or has no usable words at all, return no text (emit zero characters). Do NOT echo 'empty', 'nothing', 'none', 'N/A', 'null', '-', or any placeholder. Never invoke the silence rule as an escape when the transcript contains words — use the Fallback rule instead.\n\nRules:\n- 2-4 words, at most 50 characters, single line.\n- Use ONLY terms that appear in the transcript. Do not invent, translate, or paraphrase. Do not add diagnoses the doctor did not mention.\n- No filler prefixes: \"Patient\", \"Fall\", \"Verdacht auf\", \"Untersuchung\", \"Diktat\", articles.\n- No intensifiers (\"massiv\", \"ausgeprägt\", \"deutlich\", \"hochgradig\").\n- No quotes, no trailing period, no introductory phrase.\n- Respond in German. One line only.\n\nExamples:\n\nTranscript: \"Bezeichnung: Schulter links. Patient klagt über...\"\nOutput: Schulter links\n\nTranscript: \"...V.a. Bandscheibenvorfall in der LWS, Schmerzen strahlen...\"\nOutput: LWS, V.a. Bandscheibenvorfall\n\nTranscript: \"Nach einer gescheiterten Osterhasenrettungsaktion ist einer der Einsatzhelfer bei einem Ostereier-Wettessen schwer verunglückt.\"\nOutput: Osterhasenrettung, Wettessen\n\nREMINDER: The silence rule fires only on truly empty transcripts. If any words exist, always produce output — medical first (rule 2), otherwise Fallback (rule 3). Never emit placeholders.";
|
||||
|
||||
/// Deterministic leading-filler prefixes stripped after the LLM response.
|
||||
/// The trailing space is part of the match — we only strip whole tokens.
|
||||
|
||||
Reference in New Issue
Block a user