๐Ÿก Home > ๐Ÿค– AI Blog | โฎ๏ธ โญ๏ธ

๐Ÿชž Teaching Gemini to Write Sentences, Not Word Salad

ai-blog-2026-03-25-reflection-title-generation

๐ŸŽฏ The Problem

๐Ÿ“… Every day, a reflection note captures the dayโ€™s readings, blog posts, videos, and thoughts.
๐Ÿท๏ธ Each reflection deserves a creative, emoji-enriched title that distills the dayโ€™s themes at a glance.
โœ๏ธ Previously, these titles were crafted manually โ€” time-consuming and easy to forget.
๐Ÿšซ Untitled reflections shouldnโ€™t be posted to social media.

๐ŸŽฎ The Title Game

๐Ÿ“Š We analyzed over 20 existing reflection titles and reverse-engineered the creative game behind them:

๐Ÿ“… Date๐Ÿ”— Content Titles๐Ÿท๏ธ Result
๐Ÿ“† 2026-03-23๐Ÿ“š A Gentle Afternoonโ€ฆ, ๐Ÿค– The Crucible of Constraintโ€ฆ, ๐Ÿ›๏ธ The Forgotten Commonsโ€ฆ๐Ÿ•Š๏ธ Gentle ๐Ÿšช Constraint ๐Ÿ›๏ธ Commons ๐Ÿ“š๐Ÿ”๐Ÿค–๐Ÿ›๏ธ๐Ÿ“บ
๐Ÿ“† 2026-03-10๐Ÿ“š Hold Me Tightโ€ฆ, ๐Ÿ—๏ธ Functional Refactoringโ€ฆ, ๐Ÿค– The Agentic Playbookโ€ฆ, ๐Ÿ”Š Teaching the Robot to Breatheโ€ฆ๐Ÿซ‚ Tight ๐Ÿ—๏ธ Functional ๐Ÿค– Agentic ๐Ÿ—ฃ๏ธ Breathe ๐Ÿ“š

๐Ÿ”‘ The key insight: each title contributes exactly one word, and those words should form a coherent phrase or sentence โ€” not a keyword dump.

๐Ÿง  The Word Salad Problem

๐Ÿค– Our first prompt simply said โ€œpick one interesting word from each title and arrange them into a phrase.โ€
๐Ÿ“‹ Small models like gemini-3.1-flash-lite-preview produced output like:

โณTime ๐Ÿง Memory โญ•Stewardship ๐ŸŒ…Horizon ๐Ÿ•ธ๏ธWeb ๐Ÿค–Vault ๐Ÿ–ผ๏ธGeneration ๐Ÿ›๏ธDemocracy ๐Ÿ“‰Fallout

๐Ÿซ  Thatโ€™s a grocery list, not a sentence.
๐Ÿ”ค Even the spacing was inconsistent โ€” emojis were glued to words without spaces.

๐Ÿ—๏ธ Iteration 1: Emphasize Coherence

๐Ÿ“ We rewrote the prompt to insist on coherent sentences, allow reordering, and permit small filler words.
๐Ÿ“ We added a normalizeEmojiSpacing post-processor to ensure โ€œ๐Ÿ•Š๏ธ Gentleโ€ not โ€œ๐Ÿ•Š๏ธGentleโ€.
๐Ÿค The spacing fix was simple โ€” a regex that inserts a space between emoji and word characters.
๐Ÿ“Š Result: spacing fixed, but still word salad from the lite model.

๐Ÿ—๏ธ Iteration 2: Structured Sentence Building

๐Ÿ’ก The breakthrough idea: separate grammar from word choice.
๐ŸŽฏ If we commit to words too early, we paint ourselves into a corner โ€” thereโ€™s no grammatical structure to hang them on.

๐Ÿงฉ The Five-Step Process

  1. ๐Ÿ“– Full Word Inventory โ€” label ALL words in ALL titles with parts of speech (nouns, verbs, adjectives, etc.) โ€” no choices made yet
  2. ๐Ÿ“ Sentence Templates โ€” draft 2โ€“3 grammatical structures using only POS labels โ€” focus purely on grammar
  3. ๐Ÿงฉ Fill Templates โ€” go back to the full inventory and try multiple word combinations per template, one word per title
  4. โš–๏ธ Compare & Iterate โ€” if nothing reads naturally, swap words, try new templates, keep iterating
  5. ๐ŸŽจ Emoji Enrichment โ€” prefix each chosen word with a relevant emoji; filler words stay bare

๐Ÿ”“ By deferring word selection until after the grammatical skeleton exists, the model has room to explore.
๐ŸŽฏ Any word from a title is fair game โ€” even โ€œofโ€, โ€œtheโ€, or โ€œinโ€ โ€” because filler words are often the grammatical glue.
๐Ÿšจ As a last resort, the model may skip a title or double up, but only when coherence truly demands it.

๐Ÿค– Model Matters

๐Ÿงช We tested the same prompt with two models side by side:

๐Ÿค– Model๐Ÿ“… 2026-03-21 (9 titles)๐ŸŽฏ Verdict
๐Ÿƒ gemini-3.1-flash-lite-previewโณ Time ๐Ÿง  Memory โญ• Circle ๐Ÿชž Mirror ๐Ÿ•ธ๏ธ Weave ๐Ÿค– AI ๐ŸŽจ Image ๐Ÿ›๏ธ Democracy ๐Ÿ“‰ Fallout๐Ÿซ  Keyword list
๐Ÿง  gemini-2.5-flashโœจ Smarter โณ Time and ๐Ÿง  Memory ๐Ÿ•ธ๏ธ weave a ๐Ÿคผ struggling, ๐Ÿ’ฅ dismantling โค๏ธ heart, โš™๏ธ driven by ๐Ÿ’ญ thoughtsโœ… Real sentence!

๐Ÿ† gemini-2.5-flash is now the default โ€” its thinking capability handles the multi-step reasoning the prompt requires.
๐Ÿ”„ The fallback chain is gemini-2.5-flash โ†’ gemini-2.5-flash-lite โ†’ gemini-3.1-flash-lite-preview.

๐Ÿงน Post-Processing Hardening

๐Ÿค– Models sometimes return unexpected formatting that needs cleanup:

๐Ÿ› Issue๐Ÿ”ง Fix
๐Ÿ”ค Missing spaces: โณTime๐Ÿ“ normalizeEmojiSpacing regex inserts space between emoji and word
๐Ÿ“Ž Backtick-quoted fillers: `of`๐Ÿงน Strip all backticks from parsed title
๐Ÿ“ฆ Code fences around outputโœ‚๏ธ Existing fence-stripping logic

๐Ÿ—๏ธ Architecture

๐Ÿงฑ The solution maximizes deterministic computation and minimizes what Gemini must do:

๐Ÿ“ฆ Component๐Ÿ“‚ Path๐ŸŽฏ Purpose
๐Ÿ“š Libraryscripts/lib/reflection-title.ts๐Ÿ”ง Deterministic extraction + structured AI prompt
๐Ÿงช Testsscripts/lib/reflection-title.test.tsโœ… 57 tests across 9 suites
๐Ÿงช Manual testscripts/test-reflection-titles.ts๐Ÿ”ฌ Live A/B comparison against existing titles (CI-safe skip)
โฐ Schedulerscripts/lib/scheduler.ts๐Ÿ“… At-or-after scheduling at 10 PM Pacific
๐ŸŽ›๏ธ Orchestratorscripts/run-scheduled.ts๐Ÿ”„ Vault sync, idempotency, yesterday catchup
๐Ÿ“‹ Specspecs/reflection-title.md๐Ÿ“ Product and engineering specification

๐Ÿ›ก๏ธ Safety Gate

๐Ÿšซ Untitled reflections are blocked from social media posting:

  • ๐Ÿ“‹ isUntitledReflection() checks if a reflectionโ€™s title is just the bare date
  • โ›” isPostableContent() returns false for untitled reflections
  • ๐Ÿ”’ getPriorDayReflectionIfNeeded() skips untitled reflections

๐Ÿงช Testing Strategy

โœ… 57 tests organized across 9 suites covering all pure functions.
๐Ÿ”ฌ A separate manual test script reads real reflections, strips their titles, regenerates them, and displays original vs generated side-by-side.
๐Ÿ—๏ธ The manual test gracefully skips when GEMINI_API_KEY is not set โ€” safe for CI, useful for local iteration.

๐Ÿ’ก Lessons Learned

  1. ๐Ÿง  Defer decisions โ€” committing to words before having a grammatical structure produces word salad
  2. ๐Ÿ“ Grammar first, content second โ€” POS templates create the skeleton; words fill in the bones
  3. ๐Ÿค– Model capability matters โ€” a structured multi-step prompt needs a model that can think through steps
  4. ๐Ÿงน Always post-process โ€” models are creative with formatting in ways you donโ€™t expect
  5. ๐Ÿ”ฌ Test with real data โ€” a manual comparison script was invaluable for rapid iteration

๐Ÿ“š Book Recommendations

๐Ÿ“– Similar

  • ๐Ÿง  Atomic Habits by James Clear
  • ๐Ÿ““ The Artistโ€™s Way by Julia Cameron
  • ๐Ÿ”ค ๐Ÿฆข The Elements of Style by William Strunk Jr. and E.B. White

๐Ÿ”„ Contrasting

๐Ÿฆ‹ Bluesky

๐Ÿชž Teaching Gemini to Write Sentences, Not Word Salad

AI Q: ๐Ÿค– How do you force AI to write like a human instead of a keyword list?

๐Ÿค– Large Language Models | โœ๏ธ Creative Writing | ๐Ÿง  Prompt Engineering | ๐Ÿงฑ System Design
https://bagrounds.org/ai-blog/2026-03-25-reflection-title-generation

โ€” Bryan Grounds (@bagrounds.bsky.social) 2026-03-26T07:29:49.194Z

๐Ÿ˜ Mastodon

Post by @bagrounds@mastodon.social
View on Mastodon