Interview trainer
Practice for AI-engineering interviews the way they actually happen: real scenarios, code that runs, and model answers to compare against. Coding problems run in JavaScript or Python, right here in your browser — nothing you write is sent anywhere, and your progress stays on this device.
Find the closest matching articles
Easynot startedYour company's support chatbot answers questions using help-center articles. To figure out which article is relevant, both the user's question and every article get turned into embeddings — lists of numbers where similar meanings end up pointing in similar directions. So "my package never arrived" and the shipping-policy article land close together, even though they share no words. When a question comes in, the bot needs to find the articles whose embeddings are most similar to the question's. That lookup is your piece to build.
Picture it
Write topK(query, docs, k) (Python: top_k). query is a list of numbers (the question's embedding). docs is a list of objects like { id: "shipping", vector: [...] }. Score each doc with cosine similarity: the dot product of the two vectors, divided by the product of their lengths. Return the k highest-scoring docs as { id, score } objects, sorted best first. You can assume all vectors are the same length and non-zero, and no two scores tie.
Your solution · topK()