Skip to content

research(atlas): boundary-drift measurement for span reuse (#6038) - #7661

Merged
dezren39 merged 2 commits into
mainfrom
queue/13010-6038-boundary-drift
Nov 8, 2026
Merged

dezren39 merged 2 commits into
mainfrom
queue/13010-6038-boundary-drift

Conversation

@dezren39

@dezren39 dezren39 commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Closes the measurement deliverable for #6038 (parent #6028); the reuse-safety rule is stated for the span-schema design in #6035.

What was measured

Real Atlas corpus (114,165 messages scanned, 498,564 candidate targets), deterministic sample of 50 paragraph targets (seed 6038), each embedded in its original window (prev + target + next paragraph) and in 4 perturbed windows, with the production embedder replicated exactly (pinned Snowflake arctic-embed-m-v2.0 ONNX, CLS pooling, prompt-free documents; queries with the production query: prompt) and a fixed set of 20 golden queries. Corpus text stays private — numbers and methodology only.

Headline numbers

perturbation median cosine drift p95 drift median |Δrank| (pool of 50) top-10 flips
boundary shift (1 sentence) 0.047 0.190 2 6.9%
neighbor replaced (prev) 0.292 0.554 7 17.8%
neighbor replaced (next) 0.121 0.360 4 10.3%
target alone (no context) 0.168 0.478 5 11.9%

Reuse-safety rule

A stored span vector may be reused only when the full window text that produced it is byte-identical in the new version; any boundary shift or neighbor change invalidates it and the span must be re-embedded. Full report: pkgs/atlas-search/eval/boundary-drift-6038.md; experiment script: pkgs/atlas-search/eval/boundary_drift_6038.py.

🤖 queue worker lane code-d, task 13010


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Measured on the real Atlas corpus (50 sampled paragraph targets, 498,564 candidates, 20 fixed golden queries) with the production Snowflake arctic-embed-m-v2.0 ONNX pipeline replicated from embed_onnx.py. Every perturbation class moves rank materially: one-sentence boundary shift flips top-10 membership for 6.9% of query/target pairs; replacing one neighbor flips 10.3-17.8%. Report states the reuse-safety rule (reuse only byte-identical windows; re-embed on any context change) for the #6035 span-schema design. Numbers + methodology only; no corpus text.
@dezren39
dezren39 requested a review from a team as a code owner November 8, 2026 11:27
@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T12:08:49.258871Z 43a547f New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d4c25b922f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +125 to +126
sents = sentences(w0)
shifted = sents[1:]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep the target paragraph intact in boundary shifts

When the previous paragraph is a heading, list item, or code block without terminal ., !, or ?, sentences(w0) merges it with at least the first sentence of tgt, so dropping sents[0] deletes part of the target itself. Candidate selection admits these inputs because it only validates the target's length and sentence count. The resulting drift then measures a target-content change rather than the advertised context-only perturbation of the same paragraph. Remove a sentence wholly within prev, or filter out these cases, and recompute the measurements.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disposition (task 13010, lane code-y): FIXED in 43a547f. boundary_shift now drops only the previous paragraph's first sentence (sentences(prev)[1:]), keeps the target paragraph byte-identical, and preserves the blank-line window shape instead of space-joining the whole window. The experiment was re-run end-to-end on the laptop: boundary_shift top-10 flips 69 -> 58/1000, cosine drift median 0.047 -> 0.045, p95 0.190 -> 0.175; all other perturbations reproduced the original numbers exactly. Report updated with the corrected construction and numbers.

Comment on lines +95 to +97
The top-10 flip rate is the portable figure: it is the fraction
of (query, target) pairs whose top-10 membership changes when
only the target's window changes.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Scope top-10 flip rates to the measured candidate pool

Top-10 membership depends on the candidate pool, so this rate is not portable from 50 sampled windows to the production corpus. For example, a target moving from sampled ranks 9 to 11 counts as a flip, but adding production competitors can place both versions outside the top 10, yielding no flip. Calling the rate portable makes the headline percentages misleading as estimates of production retrieval impact. Keep these percentages explicitly scoped to the 50-window experiment, or measure against production competitors before extrapolating.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disposition (task 13010, lane code-y): FIXED in 43a547f (report text). The flip rates are now explicitly scoped to the measured 50-window candidate pool — stated as a property of that pool, not a portable constant — with the production-pool density caveat, and the reuse rule is written to hold regardless of the exact production rate. The corrections section of the report records the change.

import onnxruntime as ort
from transformers import AutoTokenizer

model_dir = sorted(glob.glob("/home/user/.cache/huggingface/hub/models--Snowflake--snowflake-arctic-embed-m-v2.0/snapshots/*"))[-1]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Pin the model snapshot used by the experiment

If the Hugging Face cache contains multiple snapshots, this selects whichever revision hash sorts last lexicographically, not necessarily the production revision 95c2741480856aa9666782eb4afe11959938017f specified in the report. Merely caching another revision can therefore silently change the tokenizer or model used to reproduce the measurements. Use the explicit production snapshot, as fixtures/gen_fixtures.py does, and fail clearly when it is unavailable.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disposition (task 13010, lane code-y): FIXED in 43a547f. The script pins snapshot 95c2741480856aa9666782eb4afe11959938017f and exits loudly if it is absent. Verified on the laptop: that is the only snapshot in the HF cache, so the reported run did use it; the pin makes future reproductions deterministic instead of cache-order-dependent.

Pin the HF model snapshot (was: whichever sorts last), rebuild
boundary_shift so it drops only the previous paragraph's first
sentence with the target byte-identical and the blank-line window
shape preserved (was: whole-window sentence split that could eat
into the target), and scope the top-10 flip rates to the measured
50-window pool in the report. Experiment re-run end-to-end:
boundary_shift flips 69->58/1000, drift median 0.047->0.045; all
other rows reproduced exactly.
@dezren39
dezren39 merged commit ec6938a into main Nov 8, 2026
2 of 5 checks passed
@dezren39
dezren39 deleted the queue/13010-6038-boundary-drift branch November 8, 2026 12:08
dezren39 pushed a commit that referenced this pull request Nov 8, 2026
…e rule (#6035)

The boundary-drift measurement landed on main after this design was
drafted (pkgs/atlas-search/eval/boundary-drift-6038.md, PR #7661, merge
ec6938a): holding a span byte-identical and changing only a
neighbour flips top-10 membership in 10.3-17.8% of query/target pairs,
and a one-sentence boundary shift flips 5.8-6.9%. Span identity is not a
sufficient reuse key.

- new span_windows table: window_hash = sha256 of the exact bytes handed
  to the embedder (span + recorded neighbours), stored verbatim
- span_embeddings now keyed (window_hash, embedder_id); version_spans
  and span_index carry window_hash
- invariants I1/I4/I5 rewritten, I1a/I1b added (a neighbour change must
  force a re-embed, at the schema level)
- worked example corrected: the trailing span now re-embeds too
- section 9 records #6038 as landed and adopted, superseding the draft's
  'out of scope' position
dezren39 pushed a commit that referenced this pull request Nov 13, 2026
…e rule (#6035)

The boundary-drift measurement landed on main after this design was
drafted (pkgs/atlas-search/eval/boundary-drift-6038.md, PR #7661, merge
ec6938a): holding a span byte-identical and changing only a
neighbour flips top-10 membership in 10.3-17.8% of query/target pairs,
and a one-sentence boundary shift flips 5.8-6.9%. Span identity is not a
sufficient reuse key.

- new span_windows table: window_hash = sha256 of the exact bytes handed
  to the embedder (span + recorded neighbours), stored verbatim
- span_embeddings now keyed (window_hash, embedder_id); version_spans
  and span_index carry window_hash
- invariants I1/I4/I5 rewritten, I1a/I1b added (a neighbour change must
  force a re-embed, at the schema level)
- worked example corrected: the trailing span now re-embeds too
- section 9 records #6038 as landed and adopted, superseding the draft's
  'out of scope' position
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant