Repository navigation
embed: record embedding models and compare their vectors - #4
Merged
Merged
Conversation
…tors and cosine, compare two tapes
…trix, play --against with the band
…ped queries, top-k, task prompts, MRL, topic clusters; --verify keeps the per-input screen
…ulse, typed queries blink, clusters fade in by topic; machine pane on the right; embed records host samples
…cing publish/share accept embedding tapes; the PNG card has an embedding layout (request p50, recall@1); the index row carries mode and the request p50; the web player replays the search scene with the resource panel. The demo tape is re-recorded on an RTX 3090 with GPU samples. Written by the bloomery AI assistant.
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.
Adds
toktape embed, which records embedding models. The goal is to record the EmbeddingGemma 2 work tracked in bloomery #190 and later check bloomery's vectors against llama-server's.Format. This is a new tape mode,
embedding. It's built like the decision tape:Requestsstays empty, the run lives inTape.Embeddings, and its summary lives inSummary.Embedding.prompt_tokens, when the server reports themdim,normand the first 8 values, all taken from the full vector--vector-cap Ncan trim the stored vector. Dim, norm and head are still kept whole.openai→POST /v1/embeddings,llama→POST /embedding), endpoint, model,dimensions,encoding_format, input set, dim, and latency p50/max.--pooling.Views.
toktape playscreen for an embedding tape is a search scene. It's used whenever the inputs carry arole. Every ranking on it is computed from the recorded vectors when the screen is drawn, as a pure function of the tape and the replay time:rightPane: SPEED, PLACEMENT, MEMORY, RESOURCES) sits on the right of the search scene. On an embedding tape, SPEED shows requests, latency p50 and prompt tokens instead of tok/s.toktape embednow samples the host and the server's process every 500ms with the record path's sampler, so RSS, CPU and load are on the tape.--verifyeach input's strip, fills left to right. The item in flight pulses instead of showing a spinner. The prompt and MRL figures tween in one after another and the margins count up. The typing cursor blinks, and typing speed wavers per character (a fixed per-character hash, so every replay is the same). The cluster matrix fades in one topic block at a time.toktape playredraws an embedding tape at about 30fps while the scene runs and drops to 4fps once it has settled.toktape play --verifykeeps the per-input verify screen: vector strips, norm and the coloured cosine matrix.--against b.tapeadds a cosine bar per input with the band at 0.999; records are matched by id and prompt.toktape cardprints the text view, andtoktape compare a bgives the per-input cosine and max |diff| as text.Task prompts. The strings are taken verbatim from the
promptsin google/embeddinggemma-2'sconfig_sentence_transformers.json:query:"task: search result | query: "document:"title: none | text: "Each labelled row is sent once with its prompt and once bare.
--no-promptssends every input bare only.Pacing.
--gap(100ms after each doc),--type-rate(25ms per query character, which the replay shows as typing) and--hold(1s after each query, plus a short closing hold) control how long the replay takes; the whole demo replays in about 16s.--no-paceturns them all off. The idle time is stored in the timestamps (shown_at,outro_at,scene_end) and is never part of a latency.Inputs. The built-in set is a search corpus:
expectdoc. They include Korean queries that should find English docs and English queries that should find Korean docs.--inputstakes your own JSONL of{"id","input"}rows, optionally with"role"(doc or query),"topic"and"expect".Demo. Real recordings of embeddinggemma-2-Q8_0.gguf served by mainline llama-server with
--embeddings, 768 dims:assets/embedding-demo.tape: llama-server 843e7dc built with CUDA, the model on one RTX 3090 (CUDA_VISIBLE_DEVICES,-ngl 99),/v1/embeddingswith pacing. Request p50 6.6 ms (max 60.9 ms, the first request). The host and GPU samples are on the tape, so the right pane shows GPU0/GPU1. It replays in about 16s; the clusters view starts at about 12s.internal/tape/testdata/embedding-llama.tape: a CPU recording (llama-server a0e6dc7),/embeddingwith--no-pace.internal/tape/testdata/embedding-llama.tapeuses/embeddingwith--no-pace. It's used by the--againsttest.On this set recall@1 is 6/6 both with the prompts and bare; the prompts mostly widen the margin over the next doc, and the top hit holds at 256 and 128 dims.
Publishing.
toktape publishandtoktape shareaccept embedding tapes:publish.ErrEmbeddingis removed).toktape card -o png, and the card the upload carries): the decision card's frame with the request p50 as the hero, recall@1 beside it (with prompts, and bare), and dim/docs/queries/slowest in the mid band. The summary gainshits,hits_bareandgraded, computed at record time from the vectors, and the at-end memory and GPU readings.mode = "embedding", no stream count, and the request p50 indecision_p50_ms(no new column, no migration). The run page labels it by mode ("request p50", "embedding model").--no-textremoves the inputs (the scene then shows no text) and the dry run counts the input characters that would travel.render.RunEndends an embedding tape at the scene's end, so the wasm player replays the search scene with the right pane, GPU rows included.web/player/smoke.mjsloads the demo tape and checks for the scene. brotli is 1,360,854 bytes, under the 1,700,000 budget.Not in this PR.
toktape render(GIF/MP4 clips) still refuses embedding tapes, and the README isn't updated, since the translations need to be written by hand../scripts/check.shpasses. There are new tests ininternal/tape,internal/publish,internal/card/png,internal/recorder,internal/tuiandcmd/toktape. Theinternal/tuitests walk the search scene through indexing, typing, the answer (✓, prompts, MRL) and the clusters at 120×40 and 100×30. They also check the right pane, motion (typing never goes backwards and is complete when the query is sent, the frame changes while it animates and stays still once settled), that the demo replay is 15–25s, that the plain and colour renderings match, the verify and--againstscreens, and the strip and downsample code.Note: I changed the
internal/tapeschema (only additive fields), so it needs a schema review.— written by the bloomery AI assistant