perf(agent): cache lowercased entity names and early-exit in resolve_or_create
resolve_or_create allocated a fresh lowercased String for every entity on every call (this runs per extracted mention during entity/relation extraction) and never short-circuited on an exact dist == 0 match, scoring every remaining entity regardless. Add Entity::name_lower, computed once at construction (add_entity, and schema.rs's direct-push load path), and break out of the scan as soon as an exact match is found. INT-12
This commit is contained in:
@@ -480,6 +480,7 @@ fn load_knowledge_group(file: &clawhdf5::File) -> Result<KnowledgeCache, MemoryE
|
||||
cache.entities.push(crate::knowledge::Entity {
|
||||
id: entity_ids[i] as u64,
|
||||
name: entity_names[i].clone(),
|
||||
name_lower: entity_names[i].to_lowercase(),
|
||||
entity_type: entity_types[i].clone(),
|
||||
embedding_idx: emb_idxs[i],
|
||||
..Default::default()
|
||||
|
||||
Reference in New Issue
Block a user