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 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. USER_PROMPT_TEMPLATE = """Summarize the transcript below as a Markdown document with this exact structure:
Text : {text}
Add a title to the summary. # <a short, descriptive title capturing the main topic>
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, **TL;DR:** <2-3 sentence overview a busy reader could read alone>
and finish your summary with a concluding sentence."""
## 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: def summarize_text(text: str, model_repo: str, max_tokens: int = 2048) -> str:

View File

@@ -39,8 +39,11 @@ def print_model_banner(ram_gb: float, tier: Tier) -> None:
def write_summary(output_path: str | Path, summary: str) -> None: def write_summary(output_path: str | Path, summary: str) -> None:
"""Write ``summary`` to ``output_path`` as a titled markdown document.""" """Write ``summary`` to ``output_path``.
The summarization prompt already makes the model emit its own ``#`` title and
Markdown structure, so the text is written verbatim.
"""
with open(output_path, "w") as md_file: with open(output_path, "w") as md_file:
md_file.write("# Summary\n\n")
md_file.write(summary) md_file.write(summary)
print(f"Summary written to {output_path}") print(f"Summary written to {output_path}")