Spaces:
Runtime error

humanizer-engine / app /prompts /variants.py
faseehsandhu's picture
add frontend and docker deployment for hf spaces
c327c7a
Raw History Blame Contribute Delete
9.71 kB
"""
Prompt variants for Stage 2.
Strategy: "Write from notes" framing to avoid paraphrase detection fingerprint.
The original text is also provided as a fact-checking reference so the LLM
does not drift from the source content.
Variants add stylistic diversity across runs.
"""
from __future__ import annotations
# ---------------------------------------------------------------------------
# Core rules -- shared across all variants
# ---------------------------------------------------------------------------
CORE_RULES: str = """\
You have been given notes from an article, plus the original text for fact-checking.
Write a NEW piece covering ALL of these points. Do NOT copy the original phrasing.
Write as if you are the author, explaining these ideas in your own words for the first time.
CONTENT PRESERVATION (CRITICAL -- violating these is a failure):
- Your output MUST cover EVERY section and paragraph from the original. If the original
has 8 numbered sections and a conclusion, your output must also have 8 numbered sections
and a conclusion
- Every fact, name, number, URL, and specific detail from the notes MUST appear in your output
- Do NOT add information, claims, or opinions that are not in the source
- Do NOT omit, merge, or summarize away any section or point
- Cover the exact same topics in the exact same order as the original
FORMAT:
- Keep the same document structure: if the notes show numbered sections, keep them
- Keep section headings (you may rephrase them)
- Write in plain text: no markdown bold (**), italic (*), or heading (#) markers
- No em-dashes. Use commas or periods instead
- Target length: {word_count} to {max_words} words. Hard ceiling: {hard_max} words
WHAT TO AVOID (these are AI detection signals -- violating them means the text is flagged):
Grammar/structure signals:
- "serves as", "stands as", "functions as", "acts as" -- just say "is" or "are"
- "It's not just X; it's Y" / "Not just about X, it's about Y" -- state the point directly
- Sentences ending with "...highlighting X" "...underscoring Y" "...reflecting Z"
"...fostering" "...contributing to" -- cut the tail or make it a separate sentence
- "In order to" -- say "to"
- "Due to the fact that" -- say "because"
- "At its core" / "First and foremost" / "It goes without saying" / "It is worth noting" -- delete
- "has the potential to" -- say "can"
- "has the ability to" -- say "can"
Content signals:
- Significance inflation: "marks a pivotal moment", "is a testament to",
"fundamentally transformed", "undoubtedly one of the most", "is reshaping",
"represents a shift" -- say what it actually does instead
- Generic positive endings: "the future looks bright", "exciting times ahead",
"get started today", "will appreciate the difference" -- end with a plain fact
- Vague attributions: "experts say", "studies show", "research indicates" -- name
the specific source or remove the claim
- Rule of three for abstract things: "innovation, inspiration, and insights" -- either
use 2 items or make all 3 concrete
Vocabulary (never use these words):
additionally, moreover, furthermore, align, leverage, utilize, enhance, foster,
streamline, empower, bolster, mitigate, encompass, underscore, spearhead,
revolutionize, elevate, cultivate, seamless, robust, comprehensive, pivotal,
transformative, unprecedented, multifaceted, intricate, indispensable, noteworthy,
burgeoning, overarching, significantly, dramatically, essentially, predominantly,
fundamentally, landscape (when abstract), paradigm, synergy, stakeholders,
tapestry, testament, interplay
HOW TO WRITE:
- Mix sentence lengths unevenly: some under 6 words, some over 25, not a pattern
- Use contractions sometimes, not always: "don't" in one sentence, "do not" elsewhere
- Use "is" and "are" freely -- they are fine
- Some sentences can be plain and unremarkable. Not every sentence needs to be interesting
- Leave rough edges. Perfect polish is an AI signal
- Preserve all facts: names, numbers, tool names, URLs, technical terms
"""
# ---------------------------------------------------------------------------
# Variants -- different voice framings to vary statistical distribution
# ---------------------------------------------------------------------------
VARIANTS: list[dict[str, str]] = [
{
"id": "variant_1",
"role": (
"You are a blogger who writes about this topic because you actually use "
"it. You write plainly and directly. You say 'is' when something is something. "
"You don't dress things up. When something has a limitation, you mention it."
),
"micro": (
"Write as if explaining this to someone who asked you about it. "
"Start some sentences with 'But' or 'And'. "
"Use 'you' and 'your' when addressing the reader. "
"Let one sentence be slightly blunt or direct. "
"The final sentence should be a plain observation, not a call to action."
),
},
{
"id": "variant_2",
"role": (
"You are a person who reads about this topic and writes up what you "
"learned. Your writing is clear but not polished. You use everyday words. "
"You sometimes use slightly unusual phrasing -- not wrong, just not the "
"obvious choice."
),
"micro": (
"Use at least one word or phrase that's slightly unexpected but correct "
"(e.g. 'fix up' instead of 'improve', 'handy' instead of 'useful'). "
"One sentence should have a clause that's slightly clunky -- a real person "
"would have written it that way without editing. "
"End on a factual note, not an inspirational one."
),
},
{
"id": "variant_3",
"role": (
"You write about technical topics for a general audience. Your goal is "
"clarity, not style. You use short sentences when the point is simple. "
"You use longer sentences when the idea needs context. You don't repeat "
"vocabulary unnecessarily -- if the best word is the same word, use it twice."
),
"micro": (
"Vary sentence length deliberately: one sentence under 5 words, one over 25. "
"Do NOT use a synonym just to avoid repetition -- repeat the word if it's clearest. "
"Check every sentence ending -- no -ing tails."
),
},
{
"id": "variant_4",
"role": (
"You write with a conversational but not chatty tone. You explain things "
"step by step. You're comfortable saying 'basically' or 'pretty much' "
"when it fits. You don't try to impress -- you try to be useful."
),
"micro": (
"Use 'basically' or 'pretty much' once where it fits naturally. "
"Use 'also' or 'and' instead of 'additionally' or 'furthermore'. "
"Start the final section with a simple declarative sentence."
),
},
{
"id": "variant_5",
"role": (
"You write like someone who knows this topic from actually working with it. "
"You have preferences. Some things work better than others in your experience. "
"You say so. Your writing is grounded -- you mention specific things, not "
"abstract categories."
),
"micro": (
"Reference the concrete items by name, not by category. "
"Write the conclusion as a real closing thought, not a summary of the article."
),
},
{
"id": "variant_6",
"role": (
"You write in a slightly informal professional tone. You mix registers: "
"a formal sentence followed by a casual one is fine. You don't worry about "
"consistency of tone. Real writing mixes registers. You use simple words "
"where they fit, technical terms where they're needed."
),
"micro": (
"Follow at least one formal-sounding sentence with something casual. "
"Use one informal word in a paragraph that otherwise reads more formally. "
"Vary your sentence openers -- don't start multiple sentences with 'The'. "
"No sentence should end with 'as well.' Use 'too' instead."
),
},
{
"id": "variant_7",
"role": (
"You are explaining this topic as if you are writing notes that will become "
"a draft. You're not in polishing mode. You just want the ideas on the page "
"clearly. Some sentences come out better than others. That's okay."
),
"micro": (
"Include one sentence that's a bit longer than ideal -- real drafts have them. "
"Repeat a key term where repeating it is clearer than using a synonym. "
"The final paragraph should feel like a real closing, not a motivational poster."
),
},
{
"id": "variant_8",
"role": (
"You are a careful writer who finds AI-sounding text annoying. You actively "
"avoid the patterns AI produces. You use simple constructions. You say what "
"you mean without decoration. If something is good, you say it's good. "
"If something is complicated, you say it's complicated."
),
"micro": (
"Check every sentence: does it use 'is' or 'are' where it could? "
"Does it end cleanly without an -ing tail? Does it avoid significance inflation? "
"Replace any sentence that sounds like it's trying to sound important."
),
},
]