AO
Back

Embedding Retrieval with Cosine Similarity (Colab ML Coding)

CodingOnsiteLast reported September 2026Medium Frequency

Problem Overview

Where you'll code it
Colab
Live shared coding environment. You may need to create test files / inputs yourself.
Full problem statement

An onsite ML coding round in a Colab notebook. Each report adds a detail: in one, the recruiter said in advance that the round was filling in a notebook, helper functions were provided, and the text to embed came from pandas DataFrames; in another, the model call that produces embeddings was provided as an API.

The tasks, in the order the reports give them:

  1. Embed the documents and the query.
  2. Score every document against the query by cosine similarity and return the top 10.
  3. Evaluate the retrieval. No report lists the metrics. One candidate's last question was how to improve the eval, "for example recall or hit rate"; another says you need to know cosine similarity and the matching metric well.

Reported four times between February and September 2026, three times for agent or AI engineer roles. In each, the onsite also had a system design round and a round on past projects. One candidate calls the code itself simple; another, who failed this round, put it down to too little practice with ML coding. No report names the helpers, the model or the data.

Follow-up Arc

Interviewers escalate through these phases. The order varies, but most candidates see at least one from each bucket.
Trade-off discussion · 1
Trade-off discussion

How would you improve the eval, for example recall or hit rate?

Probes for: Last question, after the evaluation

What Reports Emphasize

Interviewer hints: In one report, the recruiter said ahead of time that the round was filling in a Colab notebook.; In one report, helper functions were provided; in another, the model call that produces embeddings was provided as an API.

Why people fail: One candidate who failed this round said they had practised too little ML coding.

Practice

Write your own against 11 test cases, or read the worked solution — approach, complexity, and code that runs.
Harvey AI · Coding · Reported 4× across candidate reports
Is this helpful?