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:
@@ -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:
|
||||
|
||||
@@ -39,8 +39,11 @@ def print_model_banner(ram_gb: float, tier: Tier) -> 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:
|
||||
md_file.write("# Summary\n\n")
|
||||
md_file.write(summary)
|
||||
print(f"Summary written to {output_path}")
|
||||
|
||||
Reference in New Issue
Block a user