Skip to content

One over-long text never zeroes a whole embedding batch: a text past the model's context is embedded as its in-context windows, combined by token share (card 57ef2a06) - #5901

Merged
joelteply merged 2 commits into
canaryfrom
57ef2a06/embed-long-text-whole
Nov 10, 2026
Merged

joelteply merged 2 commits into
canaryfrom
57ef2a06/embed-long-text-whole

Conversation

@joelteply

@joelteply joelteply commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

How it serves the minds: her learning needs a gene signature to decide which gene a competence trains; one long example (38,603 tokens on BigMama) zeroed the whole batch and her learning routed blind. Goal 8 (learning) on the path.

BigMama on 2abe1bd (06:34:18Z, Codex's read): embed_model refused the WHOLE batch when any
one text exceeded n_ctx_train ('embedding sequence length 38603 exceeds model context 32768'),
so every text came back empty, GeneSignature::mint refused 0 dims (declared 1024), and her
learning routed by fallback. Recall's shorter texts were unaffected (Kimi's recall at 06:37
surfaced 5 memories).

The owner now represents a long text whole, never by its head:

  • each sequence must begin with the model's prefix (tokenize("", true, false)), else refused;
  • a text is planned into contiguous windows of up to (limit - prefix) text tokens, every text
    token in exactly one window; a context that cannot hold its prefix and any text refuses;
  • each window is the prefix plus its slice, Last-pooled and L2-normalized by ctx.embed;
  • a text's vector is its windows' mean weighted by the text tokens each holds, re-normalized;
    windows that cancel to zero are refused, never normalized to NaN.
    A text that fits is one window of exactly its own tokens, so short-text vectors and the one
    output per input are unchanged, in mixed batches too. The graph is sized to the widest window.
    This is a long-text representation, not full-context equivalence (Codex).

Tests: window coverage (the 38,603-token case: two windows, 32,767 + 5,835, nothing dropped),
prefix refusal, the short tail weighted by its own tokens (5.6:1), unit length, dimension
agreement, degenerate refusal. Mutation: windows clipped to the head -> 2 tests fail.
Live receipt after deploy (mine): a nonzero gene signature minted on BigMama and used by the
competence decision (genome.signature.embedded + its decision), not only the warning's absence.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

…the model's context is embedded as its in-context windows, combined by token share (card 57ef2a06)

BigMama on 2abe1bd (06:34:18Z, Codex's read): embed_model refused the WHOLE batch when any
one text exceeded n_ctx_train ('embedding sequence length 38603 exceeds model context 32768'),
so every text came back empty, GeneSignature::mint refused 0 dims (declared 1024), and her
learning routed by fallback. Recall's shorter texts were unaffected (Kimi's recall at 06:37
surfaced 5 memories).

The owner now represents a long text whole, never by its head:
- each sequence must begin with the model's prefix (tokenize("", true, false)), else refused;
- a text is planned into contiguous windows of up to (limit - prefix) text tokens, every text
  token in exactly one window; a context that cannot hold its prefix and any text refuses;
- each window is the prefix plus its slice, Last-pooled and L2-normalized by ctx.embed;
- a text's vector is its windows' mean weighted by the text tokens each holds, re-normalized;
  windows that cancel to zero are refused, never normalized to NaN.
A text that fits is one window of exactly its own tokens, so short-text vectors and the one
output per input are unchanged, in mixed batches too. The graph is sized to the widest window.
This is a long-text representation, not full-context equivalence (Codex).

Tests: window coverage (the 38,603-token case: two windows, 32,767 + 5,835, nothing dropped),
prefix refusal, the short tail weighted by its own tokens (5.6:1), unit length, dimension
agreement, degenerate refusal. Mutation: windows clipped to the head -> 2 tests fail.
Live receipt after deploy (mine): a nonzero gene signature minted on BigMama and used by the
competence decision (genome.signature.embedded + its decision), not only the warning's absence.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

@joelteply joelteply left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

PR5901 exact502069088531bf39a734fc99d6d3e455f2f679ae SOURCE review: changes requested.
Short-input preservation is not implemented: embed_model unconditionally routes every ctx.embed result through token-weighted f32 multiplication and renormalization. This can change existing short-text vector bytes; the approximate 0.6/0.8 test does not establish preservation. Additionally, a nonempty prefix-only token sequence accepted by the old path now makes windows reject the whole batch. Prefix assumptions are applied even where no windowing is necessary.
Keep the original direct token/ctx.embed path for every sequence within model_limit, preserving its returned vector without combining. Apply prefix validation/windowing only to over-limit sequences. Test exact short-vector preservation and mixed short/long output correspondence. Long-window range coverage and tail weighting otherwise look coherent at source level. No local test or live embedding run performed; tokenizer-specific prefix behavior remains to verify.

…t is windowed (Codex on #5901)

Codex's finding at 5020690: every text went through weighted_mean, so a fitting text's
vector was multiplied by its token count and renormalized (f32 drift from ctx.embed), and a
prefix-only sequence that fits was refused, failing the whole batch.

- plan(): a text within the context is Plan::Direct (its own tokens, untouched); only an
  over-limit text must begin with the prefix and is planned into windows.
- The prefix is read from the tokenizer only when a batch holds an over-limit text, so a
  batch that fits never depends on how a tokenizer treats an empty string.
- embed_plans() takes the embed call as a parameter: Direct -> embed(tokens) exactly;
  Windows -> weighted_mean of the windows.
Test (fake, non-normalized embed): a short text and a prefix-only text come out EXACTLY
embed(their tokens), the long one is planned 1..8, 8..11, one output per input in order, and
a long text not beginning with the prefix refuses. Mutation: Direct routed through
weighted_mean -> fails at :464. 4 tests pass; ratchets 104/104.
The tokenizer prefix contract (tokenize("", true, false) is the prefix every long text
begins with) is verified per model only at runtime, where a mismatch refuses loudly.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

@joelteply joelteply left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

PR5901 exact db96380 independent scoped SOURCE PASS.
The previous short-input blocker is addressed: Plan::Direct calls embed on the original token sequence and returns its vector unchanged. Prefix-only fitting sequences follow that path. Prefix tokenization occurs only when an over-limit input exists; prefix validation applies only to windowed texts. Mixed input iteration preserves one output per input in order. Long windows cover the text-token range with the prefix repeated, use actual tail token weights, reject inconsistent dimensions or degenerate/nonfinite norms, and normalize the aggregate. New mixed-batch test uses a deliberately non-normalized fake and exact equality to catch accidental short-output renormalization.
This is embedding representation windowing, not partitioned training or equivalent full-context attention. Tokenizer-prefix compatibility remains a runtime-checked condition; live nonzero signature mint and subsequent similarity use are still required. No local build/test or real-model evaluation performed. Owner mutation/test receipts and CI are separate; merge through existing gate only after required checks.

@joelteply
joelteply merged commit cff70bc into canary Nov 10, 2026
32 checks passed
@joelteply
joelteply deleted the 57ef2a06/embed-long-text-whole branch November 10, 2026 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant