diff --git a/src/audio_summary/pipeline/summarization.py b/src/audio_summary/pipeline/summarization.py index 4620c72..b994b1a 100644 --- a/src/audio_summary/pipeline/summarization.py +++ b/src/audio_summary/pipeline/summarization.py @@ -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: + +# + +**TL;DR:** <2-3 sentence overview a busy reader could read alone> + +## Key points +- + +## Details that matter +- + +## Takeaways +- + +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: diff --git a/src/audio_summary/utils/helpers.py b/src/audio_summary/utils/helpers.py index 05ef5fe..dc2ebdb 100644 --- a/src/audio_summary/utils/helpers.py +++ b/src/audio_summary/utils/helpers.py @@ -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}")