Repository navigation
feat(core): room semantic segmentation (LLM-free, #1088) - #1090
Merged
Merged
Conversation
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.
🔍 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.
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).threshold(default 0.45,Semantic) or segment reachesmax_size(default 12,MaxSize)min_sizemerge into the previous segmentWhy (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):
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 boundarymax_size_split_single_topic— 7 memories one topic, max=3 → [3,4] tail merge + MaxSize boundary reasonempty_room_returns_emptycosine_basicsAll pass locally (
cargo test -p uteke-core rooms_segments— 4/4). Integration intoroom_summaryis follow-up work.