Retrieval Recall at k

~12 mincode completion

Implement recall_at_k(query, passages, relevant, k) returning recall@k as a float. relevant holds passage indices and is never empty.

Where this shows up

~12 min

8 employers weight this skill

3 AI product companies, 2 frontier labs, 1 health and bio company, 1 big tech firm, 1 autonomy company. Top match scores 93.

Python
import numpy as np


def recall_at_k(query, passages, relevant, k):
    """
    Recall@k of a dot-product retriever.

    Args:
        query:    query embedding, shape (d,)
        passages: passage embeddings, shape (n, d)
        relevant: indices of the relevant passages (non-empty)
        k:        number of passages retrieved

    Returns:
        float: fraction of relevant passages found in the top k
    """
    # YOUR CODE HERE
    pass
Loading docs…

The AI Mentor needs an account

It reads your code and the failing tests and nudges you toward the fix without handing you the answer. Free accounts get it on every problem you're working on today.