Update summarization prompts with structured Markdown output

Add detailed system prompt with strict transcription rules
Update user prompt template to enforce consistent Markdown structure
Remove redundant title prefix in write_summary helper
This commit is contained in:
Damien
2026-06-17 14:08:49 +02:00
parent 02ca896808
commit 383c1bd966
2 changed files with 34 additions and 9 deletions

View File

@@ -2,14 +2,36 @@
from mlx_lm import generate, load
SYSTEM_PROMPT = "I would like for you to assume the role of a Technical Expert."
SYSTEM_PROMPT = (
"You are an expert technical analyst who writes clear, faithful summaries of "
"transcribed audio. Rules you always follow:\n"
"- Write the summary in the SAME language as the transcript.\n"
"- Only use information present in the transcript; never invent facts, names, "
"or numbers. If something is unclear or cut off, say so rather than guessing.\n"
"- Preserve technical terms, product names, and acronyms exactly as spoken.\n"
"- The text is raw speech-to-text: ignore filler, repetitions, and transcription "
"noise, and focus on the substance."
)
USER_PROMPT_TEMPLATE = """Generate a concise summary of the text below.
Text : {text}
Add a title to the summary.
Make sure your summary has useful and true information about the main points of the topic.
Begin with a short introduction explaining the topic. If you can, use bullet points to list important details,
and finish your summary with a concluding sentence."""
USER_PROMPT_TEMPLATE = """Summarize the transcript below as a Markdown document with this exact structure:
# <a short, descriptive title capturing the main topic>
**TL;DR:** <2-3 sentence overview a busy reader could read alone>
## Key points
- <the most important ideas, one per bullet — aim for 5-8 bullets>
## Details that matter
- <specific facts, examples, definitions, numbers, or steps worth keeping>
## Takeaways
- <conclusions, recommendations, or open questions raised in the discussion>
Keep it concise and skimmable. Omit any section that the transcript genuinely does not support.
Transcript:
{text}"""
def summarize_text(text: str, model_repo: str, max_tokens: int = 2048) -> str: