Skip to content

feat(core): room semantic segmentation (LLM-free, #1088) - #1090

Merged
ajianaz merged 5 commits into
developfrom
feat/room-segmentation
Aug 25, 2026
Merged

ajianaz merged 5 commits into
developfrom
feat/room-segmentation

Conversation

@ajianaz

@ajianaz ajianaz commented Aug 24, 2026 •

Copy link
Copy Markdown
Collaborator

What (description of the change)

Adds LLM-free room semantic segmentation (Uteke::room_segments), groundwork for segment-level memory consolidation (LycheeMemory V2, arXiv:2608.12990, tracked in #1088).

  • Orders room memories chronologically, computes adjacent cosine similarity using existing 768-d embeddings
  • Places a segment boundary when adjacent similarity < threshold (default 0.45, Semantic) or segment reaches max_size (default 12, MaxSize)
  • Runs shorter than min_size merge into the previous segment
  • Returns segments with memory_ids, mean within-segment similarity (coherence signal), and boundary reason
  • Zero LLM calls — boundaries are pure embedding distance

Why (the problem you're solving)

Room consolidation currently implies one LLM call per memory. LycheeMemory V2 shows the cost lever is consolidation granularity: batching by semantic segment gives one LLM call per segment instead of per memory, with no accuracy loss when boundaries are detected via cheap embedding distance.

Real-data validation (prod clone, read-only):

Room n median sim segments @0.45 LLM calls
content-research 35 0.66 5 5 vs 35 (-86%)
wa-group-6067377515 17 0.50 7 7 vs 17 (-59%)
uteke-cloud 23 0.70 1 (2 w/ max_size) 2 vs 23
uteke-mobile 17 0.71 1 (2 w/ max_size) 2 vs 17

Threshold 0.45 sits in the gap between intra-topic similarity (median 0.66–0.71) and topic boundaries (p10 ≈ 0.44); stable across 0.40–0.55 in 3 of 4 rooms.

Testing (how you verified this works)

4 new unit tests in rooms_segments:

  • segments_two_topic_clusters — 2 embedding clusters → 2 segments [3,3], Semantic boundary
  • max_size_split_single_topic — 7 memories one topic, max=3 → [3,4] tail merge + MaxSize boundary reason
  • empty_room_returns_empty
  • cosine_basics

All pass locally (cargo test -p uteke-core rooms_segments — 4/4). Integration into room_summary is follow-up work.

Segment a room's memories by embedding-distance boundaries (LycheeMemory
V2, arXiv:2608.12990). Boundaries: adjacent cosine < threshold or max
segment size; short runs merge into the previous segment. Segments are
the batching unit for future segment-level LLM consolidation — one LLM
call per segment instead of per memory.
@github-actions

github-actions Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

*m = prev;
}
// Re-scan from the start of the merged segment in case the
// merge made the previous segment exceed max_size; we accept
…ments

Previously the merge target was derived from the raw segment index
(merged[start] - 1). When the preceding run had itself been merged
earlier in the pass, this produced orphan indices, leaving tiny
segments behind and defeating min_size for chains of short runs.
Now targets merged[start - 1]. Adds regression test.
@ajianaz
ajianaz merged commit bca7666 into develop Aug 25, 2026
13 checks passed
@ajianaz
ajianaz deleted the feat/room-segmentation branch August 25, 2026 00:30
ajianaz added a commit that referenced this pull request Sep 6, 2026