Repository navigation
Avoid redundant work when resolving entity names - #1060
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This was referenced Nov 20, 2026
Candidate names often already survive normalization unchanged. Recognize that subset before Unicode and punctuation folding while keeping the final entity rules shared. Signed-off-by: Lareb Zafar <[email protected]>
Two qualifying scores already exceed the entropy limit when its threshold is below a conservative entropy floor. Keep uncertain numerical boundaries on the full scoring path and preserve the existing gap shortcut. Signed-off-by: Lareb Zafar <[email protected]>
Candidate preparation and rejected overlap checks still dominate writes with few qualifying matches. Use a constant ASCII deletion table and direct integer overlap accumulation while preserving Unicode and multiset behavior. Signed-off-by: Lareb Zafar <[email protected]>
zlareb1
force-pushed
the
perf/entity-ascii-normalization
branch
from
November 20, 2026 18:31
0fcee34 to
e0482d3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):
Entity resolution avoids redundant normalization and stops scoring once ambiguity already prevents a merge, while preserving canonical names and resolution decisions.
Why
A new mention can make the resolver score many near-identical candidates even when two qualifying scores already guarantee that entropy will refuse the merge. Candidate preparation and overlap checks also repeat character work for every write.
The resolver can refuse once two scores qualify and the entropy cutoff is safely below their entropy floor. For
nqualifying scores in[m, 1], their total is at mostn, so each normalized probability is at leastm/n. The probability distribution contains a uniform component of weightm; entropy concavity therefore gives normalized entropy at leastm.The shortcut reserves
64 * ulp(1) * N, whereNis the full prepared-candidate count. This covers both sums, probability division and weighted-log evaluation. The guard also keeps positive probabilities away from underflow. Cutoffs near the floor use the original scoring and entropy calculation, preserving floating-point boundary decisions. Exact names still return first, and the existing gap shortcut remains in place.ASCII names also avoid redundant Unicode folding and use a constant translation table for compaction. Character overlap accumulates integer minima directly, avoiding a Python call for every shared character.
Scope and risk
The change touches entity normalization, compaction, overlap computation and the existing ambiguous-candidate refusal. It retains no per-input cache or private text beyond existing request-local structures.
Canonical text, IDs, aliases, input bounds, candidate limits, thresholds, tie behavior, store queries and inserted rows remain equivalent. The main risks are an incorrectly admitted ASCII character or an entropy shortcut too close to a floating-point boundary. Tests cover the ASCII alphabet, Unicode fallback, exact-name precedence, computed-entropy thresholds and adjacent floats, including score-one compact ties at zero gap.
Compatibility, rollout and rollback
Tests
LOOM_ENV_FILE= make format-check,make lint, andmake typecheckpass.LOOM_ENV_FILE= .venv/bin/python -m pytest tests/unit/test_graph_quality.py tests/unit/test_memory_entities_canonical.py tests/unit/test_point_write_relation_names.py tests/unit/test_entity_resolution.py tests/unit/test_entity_resolution_prefilter.py tests/unit/test_entity_stopwords_and_embed_batch.py -q: 461 passed.This bounded offline command reproduces the comparison count without providers or a database:
AI assistance in the code (leave one; writing this description with AI is fine):
AI-generated: Codex wrote the change and checked mathematical and floating-point boundaries, affected callers, complete resolver operations, focused tests and static gates. A fresh independent source review of the published head reports no findings.
I can explain every line of this diff and how it interacts with the rest of Loom.
Checklist
make format-check,make lint,make typecheckandmake test-unitpass; the integration suite passes if server behaviour changed.main; no migration changes.frontend/changed; no frontend changes.docs/describe the system as it now is, and this description names any operator steps and wire changes; behavior and interfaces are unchanged.git commit -s).