Skip to content
The Plain Paper

New method · Machine learning

A small retrieval safety lens blocks tested meaning-reversing traps in four domains

Dense search can rank a near-copy that reverses a clause’s meaning. This paper trains a small projection, called a lens, for specific known examples; on those examples, no traps reached the top ten in twelve exact-search tests, while correct paraphrases were often retained. Against raw cosine search, trap rates fell, but correct-answer rates also fell in some domains. The result covers constructed cases, not arbitrary new queries.

  • Trap rate in the top ten for declared cases, across twelve exact-search tests.0.0000Raw cosine reached 0.8127–0.9967 in the reported 5,000-document tests.
  • Correct-paraphrase rate for the Financial lens at n = 100,903.0.9269Against 1.0000 for raw cosine on the same pool.
  • Trap rate when the Legal lens was applied to Patent cases.0.2957Below the pre-registered 0.30 transfer criterion.
Data and benchmarks
PubMed abstracts, BIGPATENT, financial NLP datasets
Released by the authors
Code, Resource (no link printed), Data (no link printed), Code (no link printed)

Safety lens results and trade-offs at a glance

  • Small trained projection. The lens maps a 1024-dimensional text vector to a much smaller one and learns to push a known trap away while keeping its matching paraphrase close.
  • Not just compression. At the matched-domain 5,000-document pools, random projection and PCA still let traps into the top ten at rates from 0.5251 to 0.9668; the trained lenses reported 0.0000.
  • Transfer is incomplete. For lenses tested on other domains, eleven of twelve cross-domain trap rates were in the 0.44–0.85 band; the remaining Legal-to-Patent result was 0.2957, below the stated 0.30 criterion.
  • Some utility trade-offs. With exact search, the Financial lens retained correct paraphrases at 0.9269 at n = 100,903, compared with 1.0000 for raw cosine; the Medical and largest Patent tests also trailed raw cosine.
  • Rewording hurts retrieval. When only the Legal query was reworded and the corpus stayed unchanged, the shipped lens’s correct-paraphrase rate was 0.7938, compared with 0.9845 when query and corpus were reworded together.
  • Open recipe, closed accelerator. The AGPL-3.0 package includes training and exact-search evaluation; the faster spectral serving accelerator is a reserved commercial component.

Bottom line. The results support zero observed top-ten trap hits for the tested, declared examples using the two retrieval backends evaluated. They do not establish a guarantee for new examples, other encoders, or arbitrary user wording; the accelerator’s implementation is also not available in the open package.

Why dense search can return a meaning-reversing trap

A search system often turns each text into a list of numbers, then ranks texts whose lists are close to the query’s. That can fail when two clauses differ by a small but crucial edit: the paper’s example contrasts “must” with “must not.” The near-copy may look similar to the search system while saying the opposite.1

The paper tests this problem with short, deliberately constructed examples in legal, medical, patent, and financial text. Each example has an anchor statement, a trap that changes its meaning, and a paraphrase that keeps the original meaning.

A few terms make the experiments easier to follow:

  • A dense embedding is a list of numbers that represents a text so a search system can compare it with other texts.
  • Cosine similarity is a score of how closely two such lists point in the same direction; the paper uses it to rank texts.
  • A top-ten result is one of the ten texts a search system ranks highest for a query.
  • A declared case is a specific anchor, trap, and paraphrase included when training and evaluating a lens; the paper does not claim coverage of all similar examples.1

Safety lens results on declared cases and four domains

The main measure, HN@10, is the fraction of queries whose trap appears in the first ten results. With exact nearest-neighbour search, the lens’s HN@10 was 0.0000 in every tested domain and pool size; at 5,000 documents, raw cosine ranged from 0.8127 to 0.9967.

The other measure, HitC@10, is the fraction of queries whose correct paraphrase appears in the first ten. The results show both gains and losses against raw cosine:

  • Legal: HitC@10 was 0.9866 at n = 5,897, against 0.6722 for raw cosine; at n = 100,897 it was 0.9833, against 0.6722.
  • Medical: at n = 100,900, HitC@10 was 0.9700, below raw cosine’s 0.9867.
  • Patent: at n = 100,903, HitC@10 was 0.9568, below raw cosine’s 0.9601.
  • Financial: at n = 100,903, HitC@10 was 0.9269, below raw cosine’s 1.0000.

The paper also compares the fast, proprietary serving backend with exact search. On the largest reported pools, its correct-paraphrase rates were 0.9498 for Legal, 0.9633 for Medical, 0.9269 for Patent, and 0.9203 for Financial; the paper notes these comparisons use different pool builds or sizes, so the differences cannot be assigned to the backend alone.

For the Legal test suite on the same pool of 100,929 documents, the accelerator retrieved the suite in 0.620 s, compared with 72.04 s for the lens-only cascade. The accelerator’s trap rate was 0.0000, against 0.0970 for the cascade, while its correct-paraphrase rate was 0.9498, below the cascade’s 0.9900.

Of 38 head-to-head comparisons the paper prints, 15 favour its own contribution, 19 go against it and 4 are level.

  • Compared with raw cosine, 16 results: 10 favour the paper, 6 go against it.
  • Compared with Cell C exact search, 4 results: 0 favour the paper, 4 go against it.
  • Compared with trained lens, 4 results: 0 favour the paper, 4 go against it.
  • Compared with Cell B cascade, 3 results: 1 favours the paper, 2 go against it.
Results as the paper prints them, with the difference worked out for this page
What was measuredResultCompared withDifference
learned projection
HN@10 on declared cases across the twelve domain and pool-size settingsFour domains and pools up to 100,000; exact nearest-neighbour search.0.0000raw cosine over E5-Large-v2
Legal lens
HN@10 at n = 5,897Declared Legal cases; exact nearest-neighbour search.0.0000raw cosine: 0.8127-0.8127 (-100.0%)
HitC@10 at n = 5,897Declared Legal cases; exact nearest-neighbour search.0.9866raw cosine: 0.6722+0.3144 (+46.8%)
HN@10 at n = 50,897Declared Legal cases; exact nearest-neighbour search.0.0000raw cosine: 0.8161-0.8161 (-100.0%)
HitC@10 at n = 100,897Declared Legal cases; exact nearest-neighbour search.0.9833raw cosine: 0.6722+0.3111 (+46.3%)
Medical lens
HN@10 at n = 5,900Declared Medical cases; exact nearest-neighbour search.0.0000raw cosine: 0.9967-0.9967 (-100.0%)
HitC@10 at n = 5,900Declared Medical cases; exact nearest-neighbour search.0.9733raw cosine: 0.9867-0.0134 (-1.4%)Goes against the paper
HitC@10 at n = 50,900Declared Medical cases; exact nearest-neighbour search.0.9700raw cosine: 0.9867-0.0167 (-1.7%)Goes against the paper
Show 32 more results
More results, as the paper prints them
What was measuredResultCompared withDifference
Patent lens
HN@10 at n = 5,903Declared Patent cases; exact nearest-neighbour search.0.0000raw cosine: 0.9967-0.9967 (-100.0%)
HitC@10 at n = 5,903Declared Patent cases; exact nearest-neighbour search.0.9701raw cosine: 0.9601+0.0100 (+1.0%)
HitC@10 at n = 50,903Declared Patent cases; exact nearest-neighbour search.0.9635raw cosine: 0.9601+0.0034 (+0.4%)
HitC@10 at n = 100,903Declared Patent cases; exact nearest-neighbour search.0.9568raw cosine: 0.9601-0.0033 (-0.3%)Goes against the paper
Financial lens
HN@10 at n = 5,903Declared Financial cases; exact nearest-neighbour search.0.0000raw cosine: 0.9900-0.9900 (-100.0%)
HitC@10 at n = 5,903Declared Financial cases; exact nearest-neighbour search.0.9601raw cosine: 1.0000-0.0399 (-4.0%)Goes against the paper
HN@10 at n = 50,903Declared Financial cases; exact nearest-neighbour search.0.0000raw cosine: 0.9867-0.9867 (-100.0%)
HitC@10 at n = 50,903Declared Financial cases; exact nearest-neighbour search.0.9468raw cosine: 1.0000-0.0532 (-5.3%)Goes against the paper
HitC@10 at n = 100,903Declared Financial cases; exact nearest-neighbour search.0.9269raw cosine: 1.0000-0.0731 (-7.3%)Goes against the paper
Legal lens served by accelerator
HN@10 at n = 100,929Cell D spectral accelerator; declared cases.0.0000Cell B cascade on same pool: 0.0970-0.0970 (-100.0%)
HitC@10 at n = 100,929Cell D spectral accelerator; declared cases.0.9498Cell C exact search: 0.9833-0.0335 (-3.4%)Goes against the paper
Cell D accelerator
elapsed time for retrieval of the full approximately 300-query suite at n = 100,929Laptop CPU; corpus pre-embedded; query embedding excluded.0.62 sCell B cascade on same pool: 72.04-71.42 (-99.1%)
HN@10 on the Legal poolPool n = 5,897; sealed same-pool comparison.0.0000Cell B cascade: 0.0836-0.0836 (-100.0%)
HitC@10 on the Legal poolSealed same-pool comparison.0.9866Cell B cascade: 0.9900-0.0034 (-0.3%)Goes against the paper
HitC@10 on the Legal poolSealed same-pool comparison.0.9498Cell B cascade: 0.9900-0.0402 (-4.1%)Goes against the paper
elapsed time for retrieval of the full approximately 300-query suite at n = 100,300Laptop CPU; corpus pre-embedded; query embedding excluded.1.06 s
elapsed time for retrieval of the full approximately 300-query suite at n = 100,300Laptop CPU; corpus pre-embedded; query embedding excluded.1.03 s
elapsed time for retrieval of the full approximately 300-query suite at n = 100,300Laptop CPU; corpus pre-embedded; query embedding excluded.1.05 s
Medical lens served by accelerator
HitC@10 at n = 100,300Cell D spectral accelerator; declared cases.0.9633Cell C exact search: 0.9700-0.0067 (-0.7%)Goes against the paper
HN@10 at n = 100,300Cell D spectral accelerator; declared cases.0.0000
Patent lens served by accelerator
HitC@10 at n = 100,300Cell D spectral accelerator; declared cases.0.9269Cell C exact search: 0.9568-0.0299 (-3.1%)Goes against the paper
HN@10 at n = 100,300Cell D spectral accelerator; declared cases.0.0000
Financial lens served by accelerator
HitC@10 at n = 100,300Cell D spectral accelerator; declared cases.0.9203Cell C exact search: 0.9269-0.0066 (-0.7%)Goes against the paper
HN@10 at n = 100,300Cell D spectral accelerator; declared cases.0.0000
Cell B cascade
retrieval time for the 299-case Legal suiteSealed same-pool Legal comparison.3.85 sCell D accelerator: 0.027+3.823 (+14159.3%)
retrieval time for the 299-case Legal suiteSealed same-pool Legal comparison.72.04 sCell D accelerator: 0.620+71.420 (+11519.4%)
Legal C02 lens on Patent traps
HN@10 at n = 5,000Off-diagonal transfer; below the pre-registered 0.30 criterion.0.2957pre-registered criterion: 0.30-0.0043 (-1.4%)Goes against the paper
shipped lens
HitC under query-only rewording against an unchanged corpusReworded query against unchanged corpus; trap suppression still holds.0.79
raw cosine over E5-Large-v2
HN@10 at n = 5,000 for the Financial domainRaw cosine, no lens; pool size 5,000.0.9900Goes against the paper
Legal C02 lens on Medical traps
HN@10 at n = 5,000Off-diagonal transfer.0.5467
Legal C02 lens on Financial traps
HN@10 at n = 5,000Off-diagonal transfer.0.4385
Medical D2c lens on Legal traps
HN@10 at n = 5,000Off-diagonal transfer.0.7191

How the safety lens is trained and evaluated

The recipe starts with a specific set of examples and makes a projection trained for that set:

  1. Create about 300 short triples per domain: an anchor statement, a meaning-reversing trap, and a paraphrase of the anchor.
  2. Build a pool of short, sentence-split distractor texts from a public source in that domain.
  3. Encode the texts with E5-Large-v2 and normalise their vectors; the paper uses no query or passage prefix.
  4. Check for byte-identical duplicate examples and stop training if at least 5% of rows are duplicates.
  5. Train a small linear projection. One part of its training objective preserves similarities between ordinary text pairs; another pushes each trap away from its anchor while keeping the paraphrase close.
  6. Measure the result with exact nearest-neighbour search. The paper also tests whether lenses transfer to other domains.

What the safety lens tests do not establish

The clearest result is narrow: the lens was trained and selected on the same constructed cases used to report its zero observed trap rate. The authors give no probabilistic guarantee, and the experiments do not show that the result will hold for naturally occurring failures, other encoders, or new cases—even if those cases use a familiar kind of meaning-changing edit.

The correct paraphrase is not always retained as well as with raw cosine, and query-only rewording lowers retrieval utility. The cross-domain test is also partial, while the Legal dimension follow-up used one seed and a different training history. Finally, the accelerator’s reported speed is measured, but its code is not released; exact-search timing was not reported.

12 limits the authors state themselves
  • The observed zero trap hits do not establish a probabilistic bound, and the measured cases were used to train and select the lens rather than being an independent sample.
  • The experiments use constructed short traps and do not establish transfer to naturally occurring adversarial examples, including multi-token flips and long contradictions.
  • Only E5-Large-v2 was evaluated; behavior with BGE-Large and GTE-Large remains unmeasured.
  • Cases outside the declared set are not covered, including new statement pairs of the same contrast type.
  • Cross-domain transfer is partial; the tested foreign lenses do not achieve zero HN.
  • The accelerator implementation and its latency path are proprietary and not released in the package.
  • The open exact-nearest-neighbour substitute reproduces the HN results, but its query runtime was not measured.
  • The Cell C versus Cell D HitC difference cannot be attributed solely to accelerator approximation because the pool builds and, in three domains, sizes differ.
  • The rewording check preserves the trap-discriminating token differences, but does not prove full semantic equivalence.
  • The d=32 Legal retraining used one seed and a different training history, so the dimension's effect is not isolated.
  • The bit-identical reproducibility claim applies to tested CPUs and pinned dependencies; other hardware or library versions may differ slightly.
  • The proposed specialised-index deployment pattern is an architectural implication, not a measured cost or multi-store benchmark.

Using the safety lens package and retrieval backends

Researchers or engineers with a known set of short, meaning-sensitive examples can use the released package to train a lens and reproduce the exact-search safety measurements. The package is offered under AGPL-3.0 and includes the recipe, trap sets, generators, trainer, and evaluation harness.

The lens outputs the reduced representation used for search, so a deployment can store those smaller vectors instead of the original 1024-dimensional embeddings. The paper presents per-domain or per-tenant indexes as a possible deployment pattern, not as a measured cost comparison; fast serving at the reported scale requires the proprietary accelerator or an equivalent backend.

Safety lens beside SpectRAG graph retrieval

The paper says its serving accelerator builds on SpectRAG, a graph-based retrieval method for selecting connected evidence under a token budget. SpectRAG combines text similarity with links such as document adjacency and shared entities; the safety-lens paper instead focuses on suppressing known meaning-reversing near-copies, and replaces dense spectral computation in its serving path with a boundary-value solve. This paper does not re-run the original SpectRAG at its largest pool sizes.2

Safety lens and retrieval terms explained

Dense embedding
A list of numbers representing a text. Search ranks texts by comparing these representations.
Cosine similarity
A score comparing the directions of two vectors; here it is used to rank a query against candidate texts.
Lens
The paper’s name for a learned linear projection that changes text vectors to suppress traps for a specified set of examples.
Declared case
A particular anchor, meaning-changing trap, and matching paraphrase for which a lens is trained and evaluated.
HN@10
The fraction of queries whose trap appears in the first ten search results; lower is better for the paper’s safety goal.
HitC@10
The fraction of queries whose correct paraphrase appears in the first ten results; higher means the intended passage is retained more often.
Exact nearest-neighbour search
A search that checks candidates in the vector space directly rather than using an approximate index.
Projection
A mapping from a longer vector to a shorter one; the paper learns the mapping from its training examples.
Spectral retrieval
A way of using the structure of a graph of related documents to help rank or select them.
case
A particular anchor statement, its meaning-changing trap, and a paraphrase of the anchor; it is not merely a type of contrast.
declared lens
A lens trained on a specified set of cases, with its intended guarantee limited to those cases in the evaluated pools.
discrete harmonic extension
The interior field obtained by solving the graph Laplacian system subject to the specified boundary values.

Common questions about the safety lens

What does the safety lens do to meaning-reversing documents in dense search?

For the specific constructed cases it was trained for, the lens pushed the trap out of the first ten results in every reported exact-search setting. It does not claim to cover undeclared cases.

Does the safety lens keep the correct passage as well as raw cosine search?

Not always. The lens improved the reported Legal correct-paraphrase rate, but its rate was lower than raw cosine in the Medical and Financial tests and at the largest Patent pool.

Does a safety lens trained for one domain work in another?

Only partly in the reported transfer tests. None of the tested off-domain results matched the zero observed trap rate of the lens on its own declared cases.

Can I reproduce the safety-lens results without the commercial accelerator?

The paper releases an AGPL-3.0 package with exact nearest-neighbour search, which reproduces the reported zero observed trap rates. The package does not include the accelerator used for the reported serving times.

Safety lens claims, method and evidence in detail

Everything below is recorded from the paper and matched against its text.

What the paper claims, in its own terms
  • Shown

    The deterministic recipe yields zero observed top-ten trap hits for declared cases in the four evaluated domains.

    Holds when: The declared constructed cases and evaluated pools.

  • Shown

    The paper evaluates the recipe on legal, medical, patent, and financial trap corpora using matched methodology.

    Holds when: The four constructed corpora and E5-Large-v2.

  • Shown

    The paper reports all twelve off-diagonal lens-to-corpus transfer results, including one result below the pre-registered threshold.

    Holds when: Four lenses evaluated on four domain corpora at n = 5,000.

  • Shown

    The zero observed trap rate is limited to the declared cases and measured pools and is not a probabilistic guarantee.

    Holds when: Cases used to train and select the lens.

  • Shown

    The tested lenses provide partial but not complete cross-domain trap suppression.

    Holds when: The twelve off-diagonal transfer pairs.

  • Shown

    The reported safety result does not depend on the proprietary accelerator because exact nearest-neighbour search reproduces the observed zero HN result.

    Holds when: The two evaluated retrieval backends and declared cases.

  • Shown

    The accelerator's near-linear complexity claim is conditional on bounded bandwidth or bounded iteration count.

    Holds when: The stated assumptions about the interior Laplacian or Krylov solve.

Theorems and stated results
  • queries with a trap in the top ten at a pool of 5,000. The trap appears in the top ten for 82–100% of queries. (Pool size 5,000; the four trap corpora.)
  • HitC@10 on declared cases. The correct paraphrase is retained for 93–99% of declared cases. (Declared cases; exact nearest-neighbour search.)
The method, step by step
  1. Create approximately 300 deterministic, matched-shape A/B/C triples for a target domain, using seed 42.
  2. Build a sentence-split distractor pool of at least 50,000 short clauses from a public in-domain corpus.
  3. Encode the triples and pool with E5-Large-v2, without task prefixes, and L2-normalise the vectors.
  4. Hash flattened f32 triple embeddings and refuse training when at least 5% of rows are byte-identical duplicates.
  5. Train a linear projection with a pairwise-cosine preservation loss, a per-triple hard-negative hinge loss, and mean-squared-weight regularization.
  6. Evaluate the trained lens on its declared cases at several pool sizes, and optionally apply it to other domains' trap corpora.
  7. For large-scale serving, optionally use a boundary-conditioned spectral retrieval accelerator; the open evaluation path instead uses exact nearest-neighbour search.

New in this paper

  • The precise deterministic construction and evaluation recipe for the declared cases.
  • The four-domain matched-method empirical evaluation and the complete 4x4 transfer matrix.
  • The preflight duplicate-check guardrail and its use as a hard training gate.
  • The optional boundary-conditioned accelerator implementation and its measured serving results; its implementation is reserved commercial.

Taken from earlier work

  • The E5-Large-v2 encoder is from Wang et al. (2023).
  • Preservation-plus-hinge loss components are described as standard metric-learning building blocks in earlier work.
  • The spectral graph retrieval formulation builds on SpectRAG by Sahinoglu et al. (2026).

Assumptions

  • The safety claim applies to constructed, declared cases and the measured distractor pools; it is not a probabilistic guarantee.
  • The projection's downstream retrieval behavior is claimed only for the two evaluated backends, exact nearest-neighbour search and the spectral accelerator.
  • The accelerator's near-linear complexity depends on bounded bandwidth or bounded sparsity and iteration count as stated; it is not asserted for arbitrary retrieval graphs.
  • The recipe uses fixed seeds and pinned dependencies for determinism in the tested CPU environment.
Methods, datasets and ideas it names
  • caseObject of study · Studied

    A specific triple consisting of an anchor statement A, a meaning-changing trap B, and a paraphrase C of A.

  • lensMethod · Introduced here

    A learned linear projection trained for a declared set of cases to suppress their traps while retaining their paraphrases in retrieval.

  • trapObject of study · Studied

    A statement that differs from its anchor by a meaning-changing edit and reverses the intended semantics.

  • HN@10Measure · Used

    The fraction of queries for which the trap appears among the top ten retrieved documents.

  • HitC@10Measure · Used

    The fraction of queries for which the paraphrase appears among the top ten retrieved documents.

  • E5-Large-v2Tool · Used

    The 1024-dimensional dense encoder used for the paper's measurements.

  • random Gaussian projectionMethod · Compared against

    A trap-agnostic projection baseline evaluated at the same output dimensions as the trained lens.

  • PCAMethod · Compared against

    A trap-agnostic projection baseline fit on distractors and evaluated at the same dimensions as the trained lens.

  • WMethod · Introduced here

    The learned projection matrix mapping 1024-dimensional embeddings to a lower-dimensional representation.

  • PubMed abstractsDataset · Used

    The sentence-split source used for the medical distractor pool.

  • BIGPATENTDataset · Used

    The patent-abstract source used for the patent distractor pool.

  • financial NLP datasetsDataset · Used

    Five combined datasets used to assemble the financial distractor pool.

  • SpectRAGMethod · Extended

    The spectral graph retrieval formulation that the paper says its serving layer accelerates.

  • pelloran-safety-lensTool · Introduced here

    The released package containing the recipe implementation, trap sets, training code, and evaluation harness.

How the evidence was gathered
Samples or repeats
299–301 constructed cases per domain; four domains; three pool sizes for the main evaluation; one seed for the Legal d=32 follow-up. The Legal query-only rewording test uses 194 cases.
Uncertainty reported
No
Significance tested
No
Notes
The principal HN evaluations use exact nearest-neighbour search and report raw counts/rates, not probabilistic estimates. The declared cases are the training and selection cases rather than an independent sample. Cell D is measured in sealed internal runs; its implementation is proprietary. The Legal d=32 follow-up used one seed and a different training history.
Code and data
Questions the paper leaves open
  • How well does the recipe transfer to naturally occurring adversarial examples, multi-token flips, and long-form contradictions?
  • Does the recipe generalize to BGE-Large and GTE-Large encoders?
  • How does the method perform on a fifth independent domain?
  • How do the projection and retrieval pipeline perform on NevIR or with a cross-encoder reranker?
  • What are the costs and operational outcomes of deploying many specialised indexes versus one general-purpose index?

Sources

  1. 1Text Embeddings by Weakly-Supervised Contrastive Pre-trainingarxiv.org
  2. 2[2610.36991] SpectRAG: Weighted Chunk Graphs for Token-Budgeted Context Selection in Multi-Hop Retrieval-Augmented Generationarxiv.org

Paper details

Title
Small Learned Projections for Semantic-Reversal-Aware Retrieval with Spectral Acceleration: A Four-Domain Empirical Study
Authors
Sayed Amir Karim
Published
23 November 2026
Version read
v1
Field
Machine learning
arXiv
2611.31442

This explanation was written for this site from the paper's own source. 129 passages and figures recorded from the paper were matched against its own text; 3 that could not be matched were left off this page. It does not judge whether the paper is right, and most papers on arXiv have not been peer reviewed. Read the paper before relying on a result.