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

Live embedding (deep dive)

0 / 1

You could wire embedQuery(text) with transformers.js and embed your own sentence live, on CPU, in pure TypeScript. It's a great extension — but it is deliberately not on the graded path of this course, and it's worth understanding why.

Why live embedding is ungraded here

ONNX is not bit-identical across CPUs

onnxruntime-node produces slightly different float outputs on different CPU microarchitectures. A grader that compared a live embedding byte-for-byte (or even within a tight tolerance) would pass on one machine and fail on another — the opposite of what a deterministic course needs. So the graded capstone retrieves over the frozen query vectors instead, and live embedding stays an optional extension.

How you would sanity-check it

If you do build embedQuery, print l2norm(await embedQuery("hello")) — it should be ≈ 1.0. If it isn't, normalize: true didn't take and every cosine score downstream is off. The embedding must land in the same unit-sphere space as the corpus.