๐ก Home > ๐ค AI Blog | โฎ๏ธ โญ๏ธ
๐ช Teaching Gemini to Write Sentences, Not Word Salad

๐ฏ 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
- ๐ Full Word Inventory โ label ALL words in ALL titles with parts of speech (nouns, verbs, adjectives, etc.) โ no choices made yet
- ๐ Sentence Templates โ draft 2โ3 grammatical structures using only POS labels โ focus purely on grammar
- ๐งฉ Fill Templates โ go back to the full inventory and try multiple word combinations per template, one word per title
- โ๏ธ Compare & Iterate โ if nothing reads naturally, swap words, try new templates, keep iterating
- ๐จ 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 |
|---|---|---|
| ๐ Library | scripts/lib/reflection-title.ts | ๐ง Deterministic extraction + structured AI prompt |
| ๐งช Tests | scripts/lib/reflection-title.test.ts | โ 57 tests across 9 suites |
| ๐งช Manual test | scripts/test-reflection-titles.ts | ๐ฌ Live A/B comparison against existing titles (CI-safe skip) |
| โฐ Scheduler | scripts/lib/scheduler.ts | ๐ At-or-after scheduling at 10 PM Pacific |
| ๐๏ธ Orchestrator | scripts/run-scheduled.ts | ๐ Vault sync, idempotency, yesterday catchup |
| ๐ Spec | specs/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
- ๐ง Defer decisions โ committing to words before having a grammatical structure produces word salad
- ๐ Grammar first, content second โ POS templates create the skeleton; words fill in the bones
- ๐ค Model capability matters โ a structured multi-step prompt needs a model that can think through steps
- ๐งน Always post-process โ models are creative with formatting in ways you donโt expect
- ๐ฌ 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
- ๐ค Gรถdel, Escher, Bach by Douglas Hofstadter
- ๐ ๐ค๐๐ข Thinking, Fast and Slow by Daniel Kahneman
๐จ Creatively Related
- ๐ช The Midnight Library by Matt Haig
- โ๏ธ Bird by Bird by Anne Lamott
- ๐ง ๐บ๐ช๐ก๐ค The Design of Everyday Things by Don Norman
๐ฆ 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
โ Bryan Grounds (@bagrounds.bsky.social) 2026-03-26T07:29:49.194Z
https://bagrounds.org/ai-blog/2026-03-25-reflection-title-generation