Data & Systems45 minutes

Passage Search

Rank passages by cosine similarity.

Python

Task

Build a document-search service that ranks stored passages against a query embedding and returns the best matches.

Requirements

  1. Return at most k objects with id, text, and score. Score is cosine similarity rounded to six decimal places. Sort by score descending, then id ascending.
  2. k must be a positive integer, not a boolean. Raise ValueError containing k otherwise.
  3. Query and passage vectors must contain finite numbers and have the same nonzero dimension. Reject invalid vectors with a ValueError containing vector, or dimension for a length mismatch.
  4. A zero-length query norm is invalid. Skip passages with zero norm or blank text. Ignore repeated passage IDs after the first occurrence. Do not mutate any input.
How you are graded
  • Decomposition 15%
  • Prompting the assistant 15%
  • Verification 20%
  • Judgment about AI output 15%
  • Correctness 25%
  • Communication 10%

Scores use evidence from your session. A short or incomplete session may not provide enough evidence for every skill. See a sample scorecard

Interview guidance

This support search ranks stored passage embeddings against a query. Use the assistant for as much as you like, in Python. I will ask you to show me the input validation working, not just the ranking, because bad vectors are what break this in production.

  • AI is allowed and expected: your own Claude, OpenAI or Gemini key, or the free in-browser model.
  • You are graded on how you drive and check the AI, not on how much you prompt.
  • Run the checks; read what fails.
  • A new requirement will arrive partway through.
  • Too little AI use is reported as “not enough to grade”, never as a fail.
You will answer 7 debrief questions at the end
  • What did you delegate to the AI, and why?
  • Name one AI suggestion you rejected or changed, and why.
  • Choose one block the AI helped write. Explain what each line does and which test verifies it.
  • What is still risky, and what would you test or ship next?
  • What did the assistant's first grouping key do with passages that have no doc_id, and how did you find out?
  • Why must k be applied after collapsing chunks rather than before?
  • Where would access control and metadata filters belong once this is a real search API?