synthesize: context and offer kinds, Q1 section, points cap, firmer novel rule (dress rehearsal tuning)
From a 50-response dress rehearsal on 2026-10-27: - Answers about why someone joined were being clustered as points and padded the privacy theme with 'joined because they hate ads'. Tag them as kind=context, keep them out of clustering, and render a 'Why people joined' sample instead. - Two members volunteered help and landed under standout ideas. Tag those as kind=offer and give them an 'Offers of help' section. - 'Points raised' lists ran to 27 bullets per theme; cap at 12 with a pointer to synthesis.json. - One run read 'novel' as 'left unthemed' and returned 2 standout ideas instead of ~10. The cluster prompt now says standout ideas usually sit inside a theme and asks for 5 to 10 concrete mechanisms. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
68775856f4
commit
a285ccb1dc
7 files changed
+144
-104
No files matched your search
+49
-6
@@ -49,7 +49,11 @@ PRICES = {
|
||||
"greenpt/deepseek-v4.1-flash": (0.22, 1.10),
|
||||
}
|
||||
|
||||
KINDS = {"idea", "want", "need", "goal", "concern"}
|
||||
KINDS = {"idea", "want", "need", "goal", "concern", "context", "offer"}
|
||||
# context (why someone joined / how they use it) and offer (volunteering help) are
|
||||
# reported in their own sections and kept out of theme clustering.
|
||||
UNCLUSTERED_KINDS = {"context", "offer"}
|
||||
POINTS_PER_THEME = 12 # cap on the "Points raised" list per theme in the review doc
|
||||
STANCES = {"for", "against", "neutral"}
|
||||
META_COL_RE = re.compile(r"^(id|#|time|timestamp|date|submitted|created|author|user|participant)\b", re.I)
|
||||
|
||||
@@ -383,6 +387,14 @@ def stage_tag(gw: Gateway, loaded: dict, batch_size: int, use_tools: bool,
|
||||
return items, dropped
|
||||
|
||||
|
||||
def split_items(items: list[dict]) -> tuple[list[dict], list[dict], list[dict]]:
|
||||
"""Return (to_cluster, context, offers)."""
|
||||
to_cluster = [it for it in items if it["kind"] not in UNCLUSTERED_KINDS]
|
||||
context = [it for it in items if it["kind"] == "context"]
|
||||
offers = [it for it in items if it["kind"] == "offer"]
|
||||
return to_cluster, context, offers
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Stage B: cluster
|
||||
# --------------------------------------------------------------------------- #
|
||||
@@ -488,6 +500,23 @@ def render(loaded: dict, items: list[dict], clusters: dict, meta: dict) -> str:
|
||||
out.append(f"- {bar} **{c}** · {opt}")
|
||||
out.append("")
|
||||
|
||||
# Why people joined: context items, quotes only, kept out of the themes
|
||||
context = [it for it in items if it["kind"] == "context"]
|
||||
if context:
|
||||
people = {it["rid"] for it in context}
|
||||
out.append("## Why people joined\n")
|
||||
out.append(f"_{len(people)} of {n_resp} people said what brought them here or how they use the co-op today. "
|
||||
"A sample; the rest are in the appendix._\n")
|
||||
shown_ctx: set[str] = set()
|
||||
for it in context:
|
||||
if it["rid"] in shown_ctx:
|
||||
continue
|
||||
out.append(quote_line(it["iid"]))
|
||||
shown_ctx.add(it["rid"])
|
||||
if len(shown_ctx) >= 12:
|
||||
break
|
||||
out.append("")
|
||||
|
||||
# Themes ordered by distinct respondents
|
||||
def theme_key(t):
|
||||
rids = {by_iid[i]["rid"] for i in t["item_ids"]}
|
||||
@@ -511,8 +540,11 @@ def render(loaded: dict, items: list[dict], clusters: dict, meta: dict) -> str:
|
||||
out.append(t["summary"] + "\n")
|
||||
labels = Counter(by_iid[i]["label"] for i in t["item_ids"])
|
||||
out.append("Points raised:\n")
|
||||
for label, c in labels.most_common():
|
||||
ranked = labels.most_common()
|
||||
for label, c in ranked[:POINTS_PER_THEME]:
|
||||
out.append(f"- {label}" + (f" (×{c})" if c > 1 else ""))
|
||||
if len(ranked) > POINTS_PER_THEME:
|
||||
out.append(f"- …and {len(ranked) - POINTS_PER_THEME} more (full list in synthesis.json)")
|
||||
out.append("")
|
||||
# Up to 4 quotes from distinct respondents
|
||||
shown: set[str] = set()
|
||||
@@ -535,6 +567,15 @@ def render(loaded: dict, items: list[dict], clusters: dict, meta: dict) -> str:
|
||||
out.append(f" {quote_line(i)[2:]}")
|
||||
out.append("")
|
||||
|
||||
offers = [it for it in items if it["kind"] == "offer"]
|
||||
if offers:
|
||||
out.append("## Offers of help\n")
|
||||
out.append("_People who volunteered time or skills. Worth a follow-up._\n")
|
||||
for it in offers:
|
||||
out.append(f"- **{it['label']}** ")
|
||||
out.append(f" {quote_line(it['iid'])[2:]}")
|
||||
out.append("")
|
||||
|
||||
if clusters["dissent"]:
|
||||
out.append("## Notable dissent\n")
|
||||
out.append("_Places where people pull in different directions. Worth time in the meeting._\n")
|
||||
@@ -655,13 +696,15 @@ def main(argv: list[str] | None = None) -> int:
|
||||
reasoning_effort=None if a.reasoning_effort == "default" else a.reasoning_effort,
|
||||
raw_dir=a.save_raw, verbose=a.verbose)
|
||||
items, dropped = stage_tag(gw, loaded, a.batch_size, a.use_tools, a.max_tokens)
|
||||
print(f"tagged: {len(items)} points kept, {len(dropped)} dropped", file=sys.stderr)
|
||||
to_cluster, context, offers = split_items(items)
|
||||
print(f"tagged: {len(items)} points kept ({len(context)} context, {len(offers)} offers), "
|
||||
f"{len(dropped)} dropped", file=sys.stderr)
|
||||
for d in dropped[:10]:
|
||||
print(f" dropped: {d}", file=sys.stderr)
|
||||
if not items:
|
||||
print("no points extracted; nothing to cluster", file=sys.stderr)
|
||||
if not to_cluster:
|
||||
print("no points to cluster", file=sys.stderr)
|
||||
return 1
|
||||
clusters = stage_cluster(gw, items, a.use_tools, a.max_tokens)
|
||||
clusters = stage_cluster(gw, to_cluster, a.use_tools, a.max_tokens)
|
||||
print(f"clustered: {len(clusters['themes'])} themes · {len(clusters['novel'])} novel · "
|
||||
f"{len(clusters['dissent'])} dissent · {len(clusters['unthemed'])} unthemed", file=sys.stderr)
|
||||
|
||||
|
||||
Reference in new issue
Block a user