Delta retain matches chunks by position, so an insertion near the top re-extracts the rest of the document

Aperta
#7,243 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
ai, backend

Direzione di ricerca

Read hindsight_api/engine/retain/orchestrator.py around _classify_chunk_diff (lines 4064–4080) and the full-retain fallback around line 4310. Trace how stored and new chunks are matched and how chunk_id depends on the index; reproduce with the 20-paragraph document described in the issue. Done means inserting one paragraph at the start triggers extraction only for that new chunk, without the full-retain fallback.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

core
Bug Description

_classify_chunk_diff compares each new chunk with the stored chunk at the same chunk_index (engine/retain/orchestrator.py L4064-L4080). Text inserted or removed early in a document shifts every later chunk to a new index, so chunks whose content_hash matches a stored chunk count as changed and are extracted again. If no chunk keeps its index, delta falls back to a full retain (L4310).

#6763 raised positional identity more broadly; #6807 fixed the stale-replace case and left the rest out of scope. This is the narrower case inside one document.

Steps to Reproduce
  1. Retain a document of 20 paragraphs of about 2,900 characters each (one chunk each at the default retain_chunk_size).
  2. Retain it again with one new paragraph inserted first.
  3. Read GET /v1/default/banks/{bank_id}/llm-requests?scope=retain_extract_facts&document_id={document_id} for the second retain, and the worker log.
Expected Behavior

One extraction call, for the new chunk.

Matching by content_hash before index would avoid it; chunk_id is derived from the index, so a matched chunk that moves would need its id rewritten.

Actual Behavior

21 extraction calls, and the worker logs Delta retain: no unchanged chunks for {document_id}, falling back to full retain.

On one of our pages, 116 of 131 chunks had the same text as a stored chunk and were extracted again.

Version

1.3.1

LLM Provider

Gemini (Vertex AI)

Lingua principale
Python
Stelle
45.2k
Fork
5.9k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di vectorize-io/hindsight

Tutte le issue di vectorize-io/hindsight

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.