Spaces:
Sleeping
Sleeping
Commit ·
0aa4caf
1
Parent(s): d336f72
Narration: stop the gate rejecting the LLM's own title + 'Just' (traces-driven)
Browse filesLive traces showed the LLM writes great flowing prose but gets rejected over false
positives: its evocative title ('### The Quiet Canvas'), the word 'Just' (sentence
starter), and a few off-route NYC landmarks. Fix: exempt markdown heading/title
lines from grounding, allow 'just'/'main'/evocative prose words, add NYC landmarks
to the gazetteer. Planted-hallucination guarantee still holds.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
src/discoverroute/narrate/gazetteer.py
CHANGED
|
@@ -57,6 +57,10 @@ CITY_GAZETTEER: dict[str, list[str]] = {
|
|
| 57 |
"Chelsea", "the Lower East Side", "the Upper West Side",
|
| 58 |
"the Upper East Side", "Times Square", "Central Park", "Hudson",
|
| 59 |
"East River", "Broadway", "Fifth Avenue", "the Flatiron",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
],
|
| 61 |
"sanfrancisco": [
|
| 62 |
"San Francisco", "Union Square", "the Financial District", "North Beach",
|
|
|
|
| 57 |
"Chelsea", "the Lower East Side", "the Upper West Side",
|
| 58 |
"the Upper East Side", "Times Square", "Central Park", "Hudson",
|
| 59 |
"East River", "Broadway", "Fifth Avenue", "the Flatiron",
|
| 60 |
+
"Brooklyn", "Brooklyn Heights", "Saint Patrick's Cathedral", "St. Patrick's",
|
| 61 |
+
"the Garment District", "Hell's Kitchen", "Murray Hill", "Koreatown",
|
| 62 |
+
"Herald Square", "Madison Square", "the High Line", "Rockefeller Center",
|
| 63 |
+
"Grand Central", "Penn Station", "Bryant Park",
|
| 64 |
],
|
| 65 |
"sanfrancisco": [
|
| 66 |
"San Francisco", "Union Square", "the Financial District", "North Beach",
|
src/discoverroute/narrate/grounding.py
CHANGED
|
@@ -32,6 +32,14 @@ _COMMON = {
|
|
| 32 |
"before", "here", "there", "now", "your", "let", "take", "enjoy", "pause",
|
| 33 |
"north", "south", "east", "west", "left", "right", "monday", "today",
|
| 34 |
"paris", "parisian",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
# template/narration sentence-starters and connective words
|
| 36 |
"why", "spending", "every", "threads", "discoveries", "real", "spot",
|
| 37 |
"nothing", "invented", "breath", "hush", "shelves", "stalls", "something",
|
|
@@ -193,8 +201,13 @@ def verify_grounded(text: str, pois, start_label="", end_label="",
|
|
| 193 |
"""
|
| 194 |
allowed_norm = [_norm(a)
|
| 195 |
for a in allowed_names(pois, start_label, end_label, extra_allowed)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
offenders = [
|
| 197 |
-
mention for mention in extract_mentions(
|
| 198 |
if not _is_grounded_mention(mention, allowed_norm)
|
| 199 |
]
|
| 200 |
return (len(offenders) == 0, offenders)
|
|
|
|
| 32 |
"before", "here", "there", "now", "your", "let", "take", "enjoy", "pause",
|
| 33 |
"north", "south", "east", "west", "left", "right", "monday", "today",
|
| 34 |
"paris", "parisian",
|
| 35 |
+
# ubiquitous sentence-starters + evocative prose/title words the traces showed
|
| 36 |
+
# the gate wrongly flagging as place names ("Just around the corner", titles
|
| 37 |
+
# like "The Quiet Canvas"). None are venues, so admitting them is safe.
|
| 38 |
+
"just", "main", "canvas", "serene", "golden", "thread", "serendipity",
|
| 39 |
+
"awaits", "loop", "tucked", "secret", "alcove", "heart", "memory", "story",
|
| 40 |
+
"stories", "forgotten", "damp", "concrete", "dusty", "afternoon", "sky",
|
| 41 |
+
"subway", "grid", "skyscrapers", "skyscraper", "serenity", "canvas", "echoes",
|
| 42 |
+
"whisper", "whispers", "glow", "shimmer", "quietude",
|
| 43 |
# template/narration sentence-starters and connective words
|
| 44 |
"why", "spending", "every", "threads", "discoveries", "real", "spot",
|
| 45 |
"nothing", "invented", "breath", "hush", "shelves", "stalls", "something",
|
|
|
|
| 201 |
"""
|
| 202 |
allowed_norm = [_norm(a)
|
| 203 |
for a in allowed_names(pois, start_label, end_label, extra_allowed)]
|
| 204 |
+
# Markdown heading lines ('#', '##', '###') are evocative TITLES / section
|
| 205 |
+
# labels, not "go here" instructions — the model's own title ("### The Quiet
|
| 206 |
+
# Canvas") was tripping the gate. Exempt heading lines from grounding; the prose
|
| 207 |
+
# body, where actual stops are named, is still fully checked.
|
| 208 |
+
body = "\n".join(ln for ln in text.splitlines() if not ln.lstrip().startswith("#"))
|
| 209 |
offenders = [
|
| 210 |
+
mention for mention in extract_mentions(body)
|
| 211 |
if not _is_grounded_mention(mention, allowed_norm)
|
| 212 |
]
|
| 213 |
return (len(offenders) == 0, offenders)
|