Repository navigation
feat(retrieval): SIMILAR TO, similarity search by hypergraph edit distance - #122
Merged
Merged
Conversation
…tance SIMILAR TO finds groups of hyperedges close to a query: a pattern written as in HYPERMATCH, a set of stored hyperedges, or the children of a container. Candidates are the children of every container of a type, connected sets of up to six hyperedges around an anchor, or listed sets. The distance is hypergraph edit distance with incidence edits. For each mapping of hyperedges, the node mapping is solved exactly as an assignment problem, which makes the distance exact up to five hyperedges per side; larger candidates get an interval. A lower bound from type counts, sizes and degrees rejects candidates first. WITHIN returns every candidate within a distance and TOP the closest, stopping once the lower bounds pass the k-th distance. IDENTITY keeps atoms fixed and is exact for any size. Only the reader's hyperedges and visible members count. No issue tracks this work.
An assignment over more than 512 nodes or hyperedges is no longer solved; such a candidate gets the cost of deleting the query and inserting it as its upper bound, and every solve is charged by its size. Finding and bounding candidates and verifying them each get half of the budget, and a budget stop keeps what was done. TOP no longer reports an exact answer after dropping a candidate whose interval could have ranked higher. Member reads are cached for the search and charged, ties include the candidate, repeated listed sets are compared once, empty sets and empty example containers are refused, and THROUGH must name hyperedge types. No issue tracks this work.
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.
Stacked on #121, which it shares parser changes with. Merge #121 first, then retarget this to
main.SIMILAR TOfinds groups of hyperedges that look like a query. A match can have the same shape with any participants, or, withIDENTITY, the same participants. The query is a pattern written like aHYPERMATCHpattern, a set of stored hyperedges, or the child hyperedges of a container.The syntax is open for renaming before merge. Details are in
docs/database/similarity.md.Distance. Hypergraph edit distance with incidence edits. Each node or hyperedge inserted, deleted or retyped costs 1, and each membership added or removed costs 1, so a meeting missing one attendee is one or two edits away.
retrieve/Assignment.java). Enumerating the hyperedge mappings with branch and bound makes the distance exact up to 5 hyperedges per side.IDENTITYfixes the atoms and is exact for any size.Candidates
Answers
WITHIN dreturns everything within distanced.TOP kvisits candidates in order of their lower bound and stops once the bound passes the k-th distance.lowerandupper; they are equal when the distance is exact.Testing
EditDistanceTestagainst a brute force over every node map and every hyperedge map, on 300 random pairs with type changes:SimilarityTest: threshold and top-k over children and around-anchor spaces against the brute force; tie order; finding an exact copy at distance 0; a 3,000-member candidate; budget stops keeping partial answers; never claiming exactness wrongly.SimilarStatementTest: the worked example end to end, and every invalid form.SecurityTest#similaritySearchStaysInsideTheTenantplants cross-tenant children and members. Without the member filter the test fails.SIMILAR TOchecks per tenant agree with a Python brute force, including identity mode. Results are identical after a SIGKILL and recovery, and all 3 cross-tenantSIMILAR TOprobes are refused. The earlier statements, rechecked in the same run, are also unchanged.Independent review. One critical issue: an unbounded assignment that could exhaust memory on a huge candidate. Also four important ones:
All are fixed, and each has a test that failed first except the exactness claim, which random data never triggered and which now has a guard test.
Not done here