Ship embed / nearest
# grade this stage (from your course directory)
npx theinference test --stage embed-and-nearest-cli --watchMake it a tool. embed "<text>" prints the 32-d vector for any string; nearest "<text>" prints the 5 nearest sentences from the pool by cosine. This is the screenshot — paraphrases come back that share zero words with the query.
$ ./your_program.sh embed "how do i reset my password"
{"dim":32,"vector":[-0.354629, 0.032056, ... ]}
$ ./your_program.sh nearest "how do i reset my password"
{"neighbors":["reset my account password please",
"how to reset the password",
"i need to reset my password", ...]}
What to build
Implement embed + nearest
Make embed "<text>" print {"dim":32,"vector":[...]} and nearest "<text>" print {"neighbors":[...]} — the trained encoding of the input, and the top-5 pool sentences ranked by cosine (ties broken by index). Both train the model first from the frozen config, so the output is reproducible.
$ ./your_program.sh nearest "how do i reset my password"
{"neighbors":[ "reset my account password please", ... ]}
Process mode: your_program.sh nearest "how do i reset my password" must print JSON whose neighbors exactly match fixtures/expected.json. Because the trained model and the pool are seeded and the ranking ties are broken deterministically, the neighbor list is reproducible — graded as an exact match.
Run nearest "how do i reset my password" and watch paraphrases come back that share zero words with the query. That is a representation model you trained from a random init, on a CPU, in seconds.