all-minilm-l6-v2 on Tenstorrent p150

Derived from sentence-transformers/all-MiniLM-L6-v2 (the sentence-transformers authors; base model nreimers/MiniLM-L6-H384-uncased, Microsoft MiniLM), with unmodified weights downloaded from that repository. Official code: sentence-transformers. This is a third-party port, not affiliated with or endorsed by the sentence-transformers authors, Hugging Face or Microsoft. See the original model card for training details.

all-MiniLM-L6-v2 maps sentences and short paragraphs to 384-dimensional vectors for semantic search, clustering and similarity: a 6-layer BERT encoder (hidden size 384, 12 heads, 22.7M parameters) over the model's uncased WordPiece tokens, mean-pooled over the tokens and L2-normalized, exactly SentenceTransformer.encode. Inputs are truncated to 256 word pieces. On the device the whole encoder (embedding LayerNorm, the 6 layers and the pooling sums) runs as one megakernel: a single device program on the 12 x 10 Tensix grid whose weights stay resident in the cores' SRAM between requests, driven by a per-request plan, so every batch size (1 to 32 texts per launch) and every text length runs without recompiling (two compiled program variants, picked by launch size), at a cost proportional to its tokens. Tokenization, the embedding table lookup and the final division / normalization run on the host CPU. The server speaks the OpenAI embeddings API and merges concurrent requests into shared device launches.

Runs on Tenstorrent p150 (mesh P150).

Packaged and published with tt-model-manager 0.1.0 (manifest schema 5.1).

At a glance

Hardware p150
License apache-2.0

Intended use

Embedding text on one Tenstorrent p150 for semantic search, retrieval-augmented generation, clustering, duplicate detection and sentence similarity, from single low-latency queries to batches of documents.

Prerequisites

  • The Tenstorrent CLI, tt: uv tool install tenstorrent (or use tt-model alone, see the Quickstart)
  • Docker
  • Tenstorrent hardware: p150
  • About 100 MB of free disk for the weights (fetched once into the Hugging Face cache), plus the container image

Quickstart

tt serve changh95/all-MiniLM-L6-v2

tt serve downloads the Docker image and the sentence-transformers/all-MiniLM-L6-v2 at 1110a243fdf4706b3f48f1d95db1a4f5529b4d41 weights (into your HF cache; they are not in the image), then starts the model's own HTTP server on port 20000 (or the next free port, if that one is busy). The first start compiles kernels for your device, which takes several minutes; the server is ready when it logs Application startup complete.

Without tt-cli: tt-model serve changh95/all-MiniLM-L6-v2.

On the port tt serve reported:

curl -s localhost:20000/v1/embeddings -H 'Content-Type: application/json' \
  -d '{"input": ["A man is playing a guitar.", "Someone is playing an instrument."]}' | head -c 300
curl -s localhost:20000/similarity -H 'Content-Type: application/json' \
  -d '{"source": "How do I bake bread?", "targets": ["Mix flour, water, salt and yeast, then bake.", "Paris is the capital of France."]}'

Capabilities

This package exposes the model's own HTTP server on port 20000, not an OpenAI-compatible chat API β€” its request and response shapes are the model's own. See the author's notes for the payload it expects.

POST /v1/embeddings is OpenAI-compatible (input as a string or a list of strings, model, encoding_format float or base64, dimensions 384, user); POST /embed is the native route with every option below; POST /similarity scores targets against source; GET /health reports readiness, GET /info the engine, the device, the weights commit, the configuration and the limits; GET /v1/models lists the model. The OpenAI Python client works against it:

from openai import OpenAI
client = OpenAI(base_url="http://localhost:20000/v1", api_key="unused")
r = client.embeddings.create(model="all-MiniLM-L6-v2", input=["first text", "second text"])
vectors = [d.embedding for d in r.data]          # 384 floats each, unit norm
request field (/embed) values default meaning
texts (input on /v1/embeddings) a string or a list of up to MINILM_MAX_INPUTS (2048) strings required the texts; any UTF-8
normalize true, false true L2-normalize the vectors (/v1/embeddings: always)
pooling mean, cls, max, none mean mean is the pooling the model was trained with (over [CLS], the word pieces and [SEP]); none returns one vector per token
max_length 2 .. 256 256 tokens per text including [CLS] / [SEP]
truncate right, left, error right keep the start (official), keep the end, or refuse longer texts with 400
encoding_format float, base64 float base64: little-endian float32
  • /v1/embeddings answers {"object": "list", "data": [{"object": "embedding", "index", "embedding"}], "model", "usage": {"prompt_tokens", "total_tokens"}} (tokens incl. [CLS] / [SEP]); /embed adds n_tokens and timing_ms (tokenization, device, total, device batches).
  • Errors: 400 with the reason (token-id input, dimensions other than 384, a too-long text with truncate: error, max_length out of range, empty input), 413 more than MINILM_MAX_INPUTS texts or a body above MINILM_MAX_BODY_MB, 422 an unknown field or a wrong type (native routes), 429 when MINILM_QUEUE_DEPTH device batches already wait (Retry-After), 503 while starting or after MINILM_QUEUE_TIMEOUT_S, 500 on a device failure.
  • A Python API with the same options (tt_minilm.api.MiniLM: encode, tokenize, embed_ids) is described in code/PYTHON.md; it needs a tt-metal build with the two patches in patches/.

Configuration

The server builds its device program when it starts; change these with environment variables in the container's launch command (tt-model serve --print prints it). GET /info reports them. Batch size and text length are not configuration: every request runs at its real size on the same program.

item environment variable values default
device engine MINILM_ENGINE mk (the megakernel), ttnn (tt-nn operations, one trace per batch x length bucket; less accurate, see the evaluation), cpu (float32 reference, no device) mk
texts per device launch MINILM_MAX_BATCH 1 .. 32 32
texts per request MINILM_MAX_INPUTS 1 .. 65536 2048
truncation length MINILM_MAX_SEQ_LEN 2 .. 256 256
extra wait to merge requests MINILM_BATCH_WINDOW_MS 0 .. 100 0 (requests that arrive while the device is busy are merged anyway)
matmul fidelity (megakernel) MINILM_MK_FIDELITY HiFi4, HiFi3, HiFi2 (HiFi2 not evaluated) HiFi4
row all-gathers inside the megakernel MINILM_MK_ALLGATHER auto (multicasts for launches of up to 5 row tiles of 32 tokens, unicast fan-out above), multicast, unicast (same results bit for bit) auto
queue MINILM_QUEUE_DEPTH, MINILM_QUEUE_TIMEOUT_S device batches, seconds 256, 60
sequence buckets (ttnn engine only) MINILM_SEQ_BUCKETS, MINILM_BATCH_BUCKETS multiples of 32 up to 256; 1 .. 32 32,64,128,256; 1,2,4,8,16,32

Example output

all-MiniLM-L6-v2 on a Tenstorrent p150: cosine similarities of 16 sentences on 4 topics, and of 5 search queries against them

A small semantic search, served by this package's container on a p150. The corpus is 16 sentences written for this demo, four each on cooking, astronomy, cycling and software, embedded in one POST /v1/embeddings request (left: their cosine similarities; sentences on the same topic average 0.21, sentences on different topics 0.05). Each query is one POST /similarity request with the 16 sentences as targets (right; best match boxed):

query best match (cosine) runner-up (cosine)
How do I make bread at home? Knead the dough for ten minutes, then let it rise in a warm place until it doubles in size. (0.547) Toast the spices in a dry skillet before grinding them to ... (0.354)
Why do the northern lights glow in the night sky? The aurora appears when charged particles from the Sun strike the upper atmosphere. (0.558) Light from the nearest star beyond the Sun takes a little ... (0.337)
My bike chain keeps skipping between gears. A chain that keeps slipping under load usually means the derailleur needs adjusting. (0.561) Clean and oil the chain every few hundred kilometres to ... (0.381)
Why does my app get slower and use more memory over time? A memory leak makes a program use more and more RAM the longer it runs. (0.607) Check the tyre pressure before every long ride; soft tyres ... (0.159)
What is the biggest planet? Jupiter is the largest planet in the solar system and has dozens of moons. (0.692) A total solar eclipse happens when the Moon completely ... (0.241)

The official sentence-transformers model in float32 on the CPU ranks all 16 sentences in the same order for every query; no score in the two matrices differs from it by more than 0.0014, and the lowest embedding cosine to float32 is 0.99998. One query sent alone to /v1/embeddings took 4.3 ms per request on loopback (p50 of 100 requests, a new connection each; 1.3 ms of it in the server). The exact requests, scores and timings are in media/demos.json; media/make_demo.py repeats them against a running server.

Expected performance

Agreement with the official sentence-transformers float32 code on the CPU (same weights and texts; 97 cases: 42 varied texts incl. empty, CJK, Arabic, emoji and truncated paragraphs, 23 exact lengths of 2 to 256 tokens, 8 queries x 24 passages), next to the official model run in bfloat16:

eval this package official bfloat16
Embedding cosine to float32: lowest / mean 1 - cosine 0.99996 / 1.6e-5 0.99989 / 5.4e-5
Retrieval (8 queries x 24 passages): top-1 agreement, top-5 sets, largest similarity change 8/8, identical, 0.0013 8/8, -, 0.0024
Same text alone vs inside batches of 4, 8 and 32 texts, lowest cosine 0.999973 0.999896
Token embeddings (pooling: none), lowest per-token cosine 0.99996 0.99980
200 repeated runs bitwise identical -
speed (warm, traced) 1 text x 16 tokens 1 x 128 1 x 256 32 texts x 32 tokens 32 x 256
Device time per launch (megakernel) 0.37 ms 0.44 ms 0.53 ms 1.66 ms 15.9 ms
Device time, the same model in stock tt-nn operations (MINILM_ENGINE=ttnn) 0.74 ms 0.93 ms 1.29 ms 11.9 ms 28.2 ms
Python encode (tokenize + device + post-processing) 0.86 ms 1.45 ms 1.93 ms 6.9 ms 39 ms
Throughput, texts per second (device time / Python encode) 2,700 / 1,160 2,300 / 690 1,880 / 520 19,270 / 4,640 2,010 / 820
Served /v1/embeddings, client round trip on loopback (new connection per request) 3.4 ms - 5.8 ms 11.6 ms -

Measured with code/scripts/bench.py (30 iterations, p50) and code/scripts/device_server_smoke.sh on one p150 with ETH dispatch; texts are English prose cut to exactly that many tokens incl. [CLS] / [SEP].

Limitations

  • Texts longer than 256 word pieces are truncated (the official max_seq_length); the model was trained on 128-token inputs. English only in training: other languages tokenize (CJK characters split, accents stripped, lower-cased) but embed with lower quality, as in the official model.
  • dimensions other than 384 is refused: the model is not trained for truncated (Matryoshka) embeddings.
  • Token-id input (OpenAI's arrays of tokens) is refused; send text. Text pairs / token type 1 are not exposed.
  • Up to 32 texts share one device launch; larger requests and concurrent requests are split / merged automatically. One p150 only: device dispatch runs on the chip's Ethernet cores, so multi-chip meshes are not supported. The megakernel needs the 12 x 10 grid of ETH dispatch; with fewer grid columns the server falls back to the ttnn engine.
  • Precision: bfloat16 weights and matmul inputs with float32 accumulation; float32 residual stream, partial sums, LayerNorm and softmax. Embeddings differ from the float32 model by 1 - cosine 1.6e-5 on average (the official bfloat16 run: 5.4e-5); the same text can differ by up to 3e-5 (1 - cosine) depending on the other texts of its launch, because its position in the launch changes the order of float32 additions before bfloat16 roundings.
  • Latency is set by synchronisation inside the megakernel (11 exchanges per layer), not by arithmetic: a 16-token text takes about as long as a 64-token one, and long batches gain less over tt-nn than short ones.

Licensing

  • Weights (not redistributed here; tt serve downloads them at this commit), Apache-2.0: sentence-transformers/all-MiniLM-L6-v2 1110a243. Notices: code/tt_minilm/licenses/NOTICE.md.
  • This package is a derivative work: the inference code is written anew (tokenization framing, the encoder, the pooling and normalization follow the official code's behaviour), the encoder runs on the device as one custom megakernel (or in tt-nn operations), and the weights are loaded unmodified.
  • Port, server and scripts (code/) and the tt-metal patches in patches/: Apache-2.0.
  • The sample texts in code/tt_minilm/samples/ were written for this package; their reference embeddings were computed with the official code.
  • The demo in media/ (the figure, demos.json, make_demo.py): Apache-2.0; its sentences and queries were written for this package and its scores are this package's outputs. Attributions: media/ATTRIBUTION.md.

Related packages

Feedback

Questions or problems with this package: open a discussion at https://huggingface.co/changh95/all-MiniLM-L6-v2/discussions β€” that is what reaches its author. A problem with the tt tooling itself: tt report issue (collects your environment and opens a prefilled issue against tenstorrent/tt-cli). Product feedback: support@tenstorrent.com.

Provenance

The exact sources the image was built from β€” code/ in this repo is byte-identical to the model code inside the image:

component built from
tt-metal 44d66500520fda9f2c7060c0f6b41ec48f7ab37e (dirty tree β€” the image includes uncommitted changes)
code/ digest ac5ef890b4c3818d (sha256, first 16 hex digits)
built 2026-11-30T15:39:28+00:00 by tt-model 0.1.0
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for changh95/all-MiniLM-L6-v2

Collection including changh95/all-MiniLM-L6-v2