BetaJobprepping.com is in beta and still under construction. New sign-ups are closed.
Start practising
Applied AI Engineer

Applied AI Engineer Coding Interview in Python Explained

What the applied AI engineer coding interview tests, how hidden tests probe ranking and text edge cases, a worked Python example and the costly mistakes.

Updated

The applied AI engineer coding interview usually asks you to write the deterministic code that surrounds a model: scoring and ranking text, merging results, validating output and checking that what the model claims is really in the source. It is ordinary Python, judged on correctness, readability and edge cases, and it rarely involves calling a model API live.

This post covers the coding round in detail. For the whole loop, see the Applied AI Engineer interview guide.

What kind of problem to expect#

Across the industry, applied AI coding rounds come in three broad shapes. Some companies run a standard algorithms round with an AI flavour. Others set a take-home, such as a small question-answering system with a handful of eval questions, followed by a conversation about your choices. A growing number use a practical live task: implement a retrieval scoring function, compute cosine similarity without dividing by zero, parse structured model output, or debug an agent loop that never terminates.

The common thread is that the model is treated as an unreliable component and your code is the reliable part around it. Interviewers like these tasks because the answers are deterministic, so they can test them fairly.

Our practice exercise follows that pattern. It is in Python and involves ranking documents and checking citations, set at Wrenfold, a fictional company whose assistant answers questions from an organisation's own documents. You write code in the browser and hidden tests run against it. The round lasts 13, 18 or 20 minutes depending on the paper, and you can practise it in the Applied AI Engineer interview at any length.

How realistic the data is#

Expect text that looks like real documents, not tidy toy strings. That means mixed case, extra whitespace, punctuation next to words, repeated documents, empty fields and passages that nearly but not quite match. Ranking inputs may contain ties, missing scores or a document that appears in more than one list. Deciding how to normalise text, and saying why out loud, is part of the task.

Talking while you code#

The interviewer cannot see your intent, only your words and your code. Narrate decisions, not keystrokes.

  • Restate the task and define correct. "So given these lists I return the top three document IDs, highest score first, and ties break by ID."
  • List the edge cases before writing code. Empty input, duplicates, ties, case and whitespace differences, and values that are missing.
  • Start simple. Write the plainest version that could pass, then improve it if time allows.
  • Test as you go. Run a tiny example after each function. A two-line check you wrote yourself is worth more than a long silent stretch.
  • State complexity. One sentence is enough: "This is a sort, so n log n in the number of candidates."

What hidden tests tend to probe#

Hidden tests reward the boring cases. In this genre they usually check:

  • empty inputs and lists with a single item;
  • ties, and whether your order is stable and deterministic;
  • duplicates, both exact and differing only by case or whitespace;
  • normalisation: punctuation, repeated spaces, line breaks and capital letters;
  • boundaries such as k larger than the number of candidates, or k of zero;
  • larger inputs, where an accidental quadratic loop becomes slow.

If a hidden test fails, resist the urge to change code at random. Say what kind of input could produce that failure, write it as a small case, and fix the cause.

A worked example on an invented problem#

Here is a problem in the same genre, written for this post. Two retrievers, one keyword-based and one embedding-based, each return a ranked list of chunk IDs in the form doc:chunk. Merge them using reciprocal rank fusion, keep at most two chunks per document so one long document cannot crowd out the rest, and return the top k chunk IDs.

Before coding, a strong candidate says: scores from the two retrievers are on different scales, so fuse by rank, not by raw score. Ties break by chunk ID so the output is deterministic. A chunk that appears twice in one list counts once.

from collections import defaultdict
def fuse(rankings, k, per_doc=2, c=60):
    scores = defaultdict(float)
    for ranking in rankings:
        seen = set()
        for rank, chunk_id in enumerate(ranking, start=1):
            if chunk_id in seen:
                continue
            seen.add(chunk_id)
            scores[chunk_id] += 1.0 / (c + rank)
    ordered = sorted(scores, key=lambda cid: (-scores[cid], cid))
    result, per_doc_count = [], defaultdict(int)
    for chunk_id in ordered:
        doc = chunk_id.split(":", 1)[0]
        if per_doc_count[doc] < per_doc:
            result.append(chunk_id)
            per_doc_count[doc] += 1
        if len(result) == k:
            break
    return result

Then test as you go, saying what each case is for:

keyword = ["a:1", "b:4", "a:2", "a:3"]
vector = ["a:2", "c:1", "a:1", "b:4"]
print(fuse([keyword, vector], k=3))   # a:1 and a:2 lead, then b:4
print(fuse([keyword, vector], k=10))  # a:3 dropped by the per-doc cap
print(fuse([], k=3))                  # empty input gives []
print(fuse([["a:1", "a:1"]], k=1))    # duplicate in one list counts once
print(fuse([keyword], k=0))           # k of zero

The last case exposes a bug: the length check runs after the append, so with k of zero it never matches and the function returns every chunk the cap allows. Saying so, and moving the check to the top of the loop, is exactly the behaviour interviewers want to hear. Complexity is dominated by the sort, so n log n in the number of distinct chunks.

A good follow-up discussion covers why rank fusion beats adding raw scores, what the constant does, and how you would check on an eval set that the per-document cap improves answers rather than just changing them.

Mistakes that cost points#

  • Trusting the input. Assuming IDs are unique, text is clean or lists are non-empty.
  • Comparing raw scores from different systems. A keyword score and a cosine similarity are not on the same scale.
  • Non-deterministic order. Iterating over a set or relying on insertion order without a tie-breaker.
  • Silent coding. Ten minutes without a word leaves the interviewer nothing to score except the final result.
  • Normalising without explaining. Lower-casing and stripping punctuation can be right, but say what it might break, such as product codes.
  • Over-building. Reaching for a vector database or a framework when the task needs twenty lines of standard library Python.
  • Never running the code. Hidden tests find what a quick example would have found earlier.

How to practise#

Write five small functions from scratch against a timer: a keyword overlap scorer, cosine similarity with a zero-vector guard, a top-k with stable ties, a text normaliser, and a check that a quoted span appears in a passage. Then do them again while explaining aloud. The applied AI engineer interview prep plan spaces this practice across two weeks, and the applied AI engineer interview questions cover the design and evaluation rounds around it.

To rehearse with hidden tests and a live interviewer, practise the Applied AI Engineer coding interview in the 30, 45 or 60-minute format.

Frequently asked questions#

What language is the applied AI engineer coding interview in?#

Python is by far the most common, because most LLM tooling and evaluation code is written in it. Our practice exercise is in Python. Some companies accept TypeScript for product-focused roles. Whatever the language, you should be comfortable with sorting by keys, dictionaries, string handling and writing small tests without looking anything up.

Do I need to call an LLM API in the coding round?#

Usually not in a live round. Model output varies between runs, which makes it hard to assess fairly, so interviewers prefer deterministic tasks such as ranking, parsing and validation. Take-homes are different and often expect a working system that calls a model, along with a small evaluation of its quality.

Are applied AI coding interviews LeetCode style?#

Some are, particularly at larger companies that use a shared engineering loop. Many applied AI teams prefer practical tasks with realistic text data instead. Prepare for both by keeping basic data structures fresh, while spending most of your time on text processing, ranking and edge cases, which appear in nearly every format.

What do hidden tests check?#

They check the cases a rushed solution misses: empty input, ties, duplicates, case and whitespace differences, boundary values of k and larger inputs. Passing the example in the prompt is not enough. Writing your own small checks for each edge case before you finish is the most reliable way to pass them.

How is the coding round scored?#

Coding is a must-have skill for this role, so it needs a Hire-ready rating for an overall yes. Hire-ready means correct, readable code with edge cases handled and tested, and a stated complexity. Hidden test results count, but so does how you reasoned, tested and explained along the way.

Read next

GuideApplied AI Engineer

Applied AI Engineer Interview Guide with Questions and Prep

How the applied AI engineer interview works, from RAG design to evals and live Python coding, with 8 practice questions, strong-answer notes and a 7-day plan.

Prep planApplied AI Engineer

Applied AI Engineer Interview Prep Plan for Two Weeks

How to prepare for an applied AI engineer interview in two weeks, day by day, covering what to build, what to practise aloud, stories and timed mocks.

QuestionsApplied AI Engineer

Applied AI Engineer Interview Questions and Strong Answers

28 applied AI engineer interview questions on RAG, agents, evals and design, each with why it is asked, what a strong answer does and the likely follow-up.

Practice

Say it out loud.

Reading about an interview isn't the same as doing one. Take a 30, 45 or 60-minute Applied AI Engineer interview with an AI interviewer and get scored against a real rubric.

Choose an interview