Extraction name resolution is quadratic in a document's entity count
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 74/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- python, typescript
- Ambito
- backend, performance
Direzione di ricerca
Read src/selfgraph/extraction/extractor.py and typescript/src/extraction/extractor.ts, focusing on resolve() and the registry construction in _assemble and assembleExtraction. Check existing extraction tests, then reproduce the timings with the provided script. Done means both implementations avoid rescanning registered entities for each unresolved name and existing extraction behavior still passes.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What happens
_assemble (Python) and assembleExtraction (TypeScript) resolve every relation, preference, and decision name against the extracted entities. A name that is not a key of the registry falls back to a linear scan that calls entity_id twice per registered entity. All chunks of one document share one registry, so the cost grows with the square of the document's entity count. The work is synchronous and blocks the event loop, so an MCP server or other async callers stall while it runs.
Reproduce
On main (5a277c9), no store needed:
import time
from selfgraph.extraction.extractor import LLMExtractor, _RelOut
from selfgraph.models import EntityInput
for n in (250, 500, 1000, 2000):
ents = [EntityInput(type="Person", name=f"Person {i}") for i in range(n)]
rels = [_RelOut(from_name=f"Person {i}", type="KNOWS", to_name=f"Stranger {i}") for i in range(n)]
t = time.time()
LLMExtractor._assemble(ents, rels, [], [])
print(n, f"{time.time() - t:.2f}s")
250 0.44s
500 1.54s
1000 5.97s
2000 24.87s
A document of about 150 chunks with 20 entities per chunk and 5 relations per chunk to names the entities pass did not list takes 9 s in _assemble alone.
Cause
resolve() in src/selfgraph/extraction/extractor.py and typescript/src/extraction/extractor.ts: registry.get(key) or next(e for e in registry.values() if entity_id(e.type, name) == entity_id(e.type, e.name)). Precomputing the canonical name of each registered entity once, and looking candidates up by it, makes this linear.
- Lingua principale
- TypeScript
- Stelle
- 173
- Fork
- 58
- Merge medio
- 6h
- PR unite (30g)
- 120
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di hydra-db/selfgraph
-
approved-for-pr area: cli-mcp area: errors bug effort: S P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
hydra-db/selfgraph#401 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
approved-for-pr area: errors area: store bug effort: S P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
hydra-db/selfgraph#398 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
approved-for-pr area: errors area: write bug effort: S P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
hydra-db/selfgraph#392 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
approved-for-pr area: parity area: write bug effort: S P3
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
hydra-db/selfgraph#391 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di hydra-db/selfgraph
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
code-yeongyu/senpi#7139 ·
I maintainer di solito rispondono entro 1 giorno
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficoltà 1/5 1-3 ore Idoneità per principianti 72/100
lingdojo/kana-dojo#34395 · 1 commento · 5 reazioni ·
I maintainer di solito rispondono entro 1 giorno
-
bug status: needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
mastra-ai/mastra#31093 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
area:web p2 product:business triage:active type:bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 89/100
cuadrao-ai/argus#2328 ·
I maintainer di solito rispondono entro 1 giorno
-
bug frontend good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
nikhilb2/simple_invoicing#907 ·