Build your own semantic search
The search CLI (the capstone)·5 min

From text to a vector

0 / 1

Until now you've used precomputed vectors. To search your own sentence, you need the front of the pipeline: tokenize the text into WordPiece ids, run the transformer, mean-pool the token vectors into one, and L2-normalize. That's exactly what produced every vector in corpus_emb.f32 — the embedding front-end.

The three steps the model does for you

Sentence → vector
text → WordPiece ids → MiniLM forward → [seq_len × 384] → mean-pool → [384] → L2-normalize → [384] unit vector
A library does the heavy lifting

In a production TS stack, @huggingface/transformers (transformers.js) bundles the WordPiece tokenizer, the ONNX model, mean-pooling, and normalization behind one pipeline('feature-extraction', 'Xenova/all-MiniLM-L6-v2', { pooling: 'mean', normalize: true }) call, running on CPU. The next step explains why this course keeps that off the graded path.