Skip to content

Per-chunk entity attribution in koi_entity_chunk_links #22

Description

@DarrenZal

Summary

The new link_entities_to_chunks write-path (eaf803f) fans every doc-level entity across every chunk of the document. For a typical Notion page (18 entities × 19 chunks = 342 link rows), every chunk appears to contain every entity. Historical koi_entity_chunk_links data (614K rows from before Feb 10) had genuine per-chunk attribution — we should return to that fidelity.

Proposed work

  1. Evaluate whether per-chunk precision is worth the cost vs. current doc-level fanout
  2. Implement either:
    • A. Per-chunk LLM extraction (highest fidelity, N× LLM cost, N ≈ 20 for Notion)
    • B. Offset-match: after doc-level extraction, substring-search each entity in each chunk's text and only link where it actually appears (~free, misses synonyms/pronouns)
  3. Populate char_offset (currently NULL) for chunk-level context in UI
  4. Adjust ranking in koi-query-api.ts to use per-chunk entity density where available

Option B is likely the right MVP. It compounds well with improved entity extraction (#19).

Dependencies

Blocked by #19 (entity extraction quality) — not strictly, but the combined improvement is much more valuable than either alone.

References

  • Current write-path: eaf803flink_entities_to_chunks in src/core/koi_event_bridge_v2.py
  • Backfill script: scripts/backfill_entity_chunk_links.py
  • Search consumer: koi-query-api.ts line ~1163 (entity_memories CTE)

Task key: other-2026-04-14-per-chunk-entity-attribution
Vault task: Tasks/2026-04-14-per-chunk-entity-attribution.md

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backlogDeferred technical ideas

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions