Skip to content

AI Engineer interview questions

100 real questions with model answers and explanations for Junior candidates.

See a AI Engineer resume example

Practice with flashcards

Spaced repetition · Hunter Pass

Questions

mldeep-learning

These terms describe related categories with different scopes.

  • Artificial intelligence is the broad field of creating systems that perform tasks associated with human intelligence.
  • Machine learning is a part of AI in which models learn patterns from data instead of relying only on explicitly programmed rules.
  • Deep learning is a part of machine learning that uses neural networks with many layers.
  • Generative AI creates content such as text, images, or audio and often uses deep learning models.

Why interviewers ask this: The interviewer is checking whether you can distinguish the main AI categories instead of treating them as synonyms.

A language model assigns probabilities to sequences of language units.

  • Depending on the model, these units can be words, characters, or tokens such as parts of words.
  • The model learns statistical patterns from text, including which units tend to appear in a given context.
  • It can use the learned probabilities to estimate likely continuations, generate text, or compare sequences.
  • A large language model is a language model with many learned parameters that is trained on a large amount of data.

Why interviewers ask this: The interviewer is checking whether you understand a language model as a probabilistic model rather than a database of stored sentences.

tokensllm

An autoregressive LLM generates text one token at a time from the tokens that come before it.

  • A tokenizer converts the prompt into token IDs that form the initial sequence.
  • The model calculates a probability distribution over possible tokens for the next position.
  • A decoding method selects a token from that distribution and appends it to the sequence.
  • The model repeats these steps until it produces a stop token or reaches another stopping condition.

Why interviewers ask this: The interviewer is checking whether you can describe autoregressive generation as a repeated next-token prediction process.

tokens

A token is a text unit, and tokenization converts text into a sequence of token IDs that a model can process.

  • A token can represent a whole word, part of a word, punctuation, whitespace, or another text fragment.
  • A tokenizer applies its vocabulary and segmentation rules to split or encode the input text.
  • It maps each resulting token to an integer called a token ID.
  • Token boundaries do not always match word boundaries, so one word can become several tokens.

Why interviewers ask this: The interviewer is checking whether you understand how raw text becomes discrete input units for a language model.

tokens

A model vocabulary is the fixed set of tokens recognized by its tokenizer, with one numeric ID assigned to each token.

  • The vocabulary can include words, parts of words, characters, punctuation, and special tokens.
  • A token ID is an integer index that the model uses to retrieve the token's learned vector representation.
  • The number assigned to an ID does not express the token's meaning or importance.
  • Different tokenizers can use different vocabularies, so the same text can produce different tokens and IDs.

Why interviewers ask this: The interviewer is checking whether you can connect tokenizer output to the numeric inputs used by a model.

contextllm

An LLM context window is the maximum number of tokens the model can use at once when predicting the next token.

  • During generation, the window contains input tokens and the generated tokens that are still part of the sequence.
  • The limit is measured in tokens rather than words or characters.
  • Content outside the window cannot directly affect the model's current prediction.
  • A larger window makes more content available but does not guarantee that the model will use every detail correctly.

Why interviewers ask this: The interviewer is checking whether you understand the model's finite context capacity and its effect on available information.

Model parameters are numerical values that a neural language model learns during training.

  • Training updates these values to reduce errors in the model's predictions on training examples.
  • Embedding values and weights in attention and feed-forward layers are examples of parameters.
  • Parameter count is often used to describe model size, but it does not measure model quality by itself.
  • Parameters differ from hyperparameters, such as the learning rate or number of layers, which are chosen rather than learned from data.

Why interviewers ask this: The interviewer is checking whether you can distinguish values learned by the model from settings chosen for its architecture or training.

nlp

A Transformer is a neural network architecture that processes token representations with attention and feed-forward layers.

  • Token information and positional information are combined into the initial vector representations.
  • Self-attention lets each token representation use information from other relevant positions in the sequence.
  • A feed-forward layer transforms each position further, and these components are stacked in repeated blocks.
  • In a decoder-only LLM, the final representations are converted into scores for possible next tokens.

Why interviewers ask this: The interviewer is checking whether you know the main components and data flow of the architecture used by most LLMs.

nlp

Self-attention updates each token representation by combining information from available positions in the same sequence.

  • The model creates query, key, and value vectors from each token representation.
  • It compares a token's query with keys at permitted positions and normalizes the resulting scores into attention weights.
  • A weighted combination of the corresponding value vectors provides context for that token.
  • Multiple attention heads can learn to focus on different relationships between tokens.

Why interviewers ask this: The interviewer is checking whether you understand how token representations gather context inside a Transformer layer.

nlptokens

A Transformer needs positional information because token content alone does not tell self-attention where each token occurs.

  • Position information helps the model distinguish sequences that contain the same tokens in different orders.
  • It also lets the model learn relationships that depend on token order and distance.
  • One method adds a learned or fixed position vector to each token representation.
  • Relative position methods instead represent the distance and direction between token positions in the attention calculation.

Why interviewers ask this: The interviewer is checking whether you understand why token order must be represented separately from token content.

Pretraining is the initial phase in which a model learns broad patterns from a large dataset before any optional task-specific adaptation.

  • Pretraining data usually covers more examples and topics than a dataset for one specific task.
  • The learning signal is often derived from the data itself, for example by predicting a hidden token or the next token.
  • Training updates the model's parameters so that its predictions better match patterns in the data.
  • The resulting pretrained model can be used directly with prompts or have its parameters adapted through fine-tuning.

Why interviewers ask this: The interviewer checks whether the candidate understands pretraining as broad initial learning rather than training for one narrow task.

A training objective states what the model should learn, while a loss function measures numerically how far its predictions are from the expected targets.

  • A language model objective can be to predict a hidden token or the next token in a sequence.
  • The loss compares the model's predictions with the correct targets in the training examples.
  • An optimizer uses the loss and its gradients to update the model's parameters in a direction that tends to reduce the loss.
  • A low loss on training data alone does not guarantee accurate results on unfamiliar data.

Why interviewers ask this: The interviewer checks whether the candidate can connect the learning goal, its measurable error, and parameter updates without using formulas.

inference

Inference is the use of a trained model to produce a prediction or generated output from an input without updating the model's parameters.

  • The model applies patterns represented by the parameter values learned during training.
  • In classification, a forward pass can produce scores or probabilities for the available classes.
  • In autoregressive generation, the model repeatedly predicts a next token using the tokens already in the context.
  • A decoding method turns the predicted token probabilities into the selected tokens and final sequence.

Why interviewers ask this: The interviewer checks whether the candidate distinguishes using a trained model from updating it during training.

decoding

Temperature controls how concentrated the next-token probability distribution is when tokens are sampled during generation.

  • A lower temperature makes high-probability tokens more dominant, so the output tends to be more predictable.
  • A higher temperature gives lower-probability tokens more chance, so the output tends to be more varied.
  • A very low temperature approaches choosing the most probable token, while greedy decoding selects that token directly without sampling.
  • Temperature changes token selection probabilities but does not change the model's parameters or stored knowledge.

Why interviewers ask this: The interviewer checks whether the candidate understands temperature as a sampling control rather than a measure of model intelligence.

sampling

Top-k and top-p are sampling methods that limit which next tokens can be selected.

  • Top-k keeps a fixed number k of the tokens with the highest probabilities.
  • Top-p keeps the smallest set of highest-probability tokens whose cumulative probability reaches at least the threshold p.
  • The size of the top-p set changes depending on how concentrated the current probability distribution is.
  • After either filter is applied, the remaining probabilities are normalized and one token is sampled from them.

Why interviewers ask this: The interviewer checks whether the candidate can distinguish a fixed-size candidate set from one based on cumulative probability.

prompting

The same prompt can produce different outputs because generation often samples tokens from probability distributions instead of always making a fixed choice.

  • At each step, several tokens can have nonzero probabilities and remain possible choices.
  • A different token chosen early in generation changes the context for all later predictions.
  • Temperature, top-k, and top-p affect how much variation sampling can introduce.
  • Greedy decoding removes this sampling variation by selecting the most probable token at every step.

Why interviewers ask this: The interviewer checks whether the candidate understands the probabilistic and sequential nature of text generation.

hallucination

A hallucination is an output in which a model presents false or unsupported information as if it were reliable.

  • It can appear as invented facts, quotations, citations, events, or reasoning steps.
  • Fluent and confident wording does not prove that the content is correct.
  • Generative models predict likely continuations and do not automatically verify every claim against reliable evidence.
  • Determining whether an output is grounded requires comparing its claims with trustworthy sources or provided source material.

Why interviewers ask this: The interviewer checks whether the candidate separates convincing language from factual support.

A base model is produced through general pretraining, while an instruction-tuned model receives additional training to follow instructions and produce suitable responses.

  • A base language model primarily predicts plausible text continuations and may not treat a request as an instruction to follow.
  • Instruction tuning commonly uses examples that pair instructions with desired responses.
  • This additional training changes the kinds of responses the model is likely to produce, but it does not guarantee correctness.
  • An instruction-tuned model can start with the same architecture and pretrained parameters as the corresponding base model.

Why interviewers ask this: The interviewer checks whether the candidate understands instruction tuning as behavioral adaptation built on pretraining.

These model families differ in how they process an input sequence and produce an output.

  • Encoder-only models can use context from both sides of each input token to build representations, which suits tasks such as classification and information extraction.
  • Decoder-only models use preceding tokens as causal context and commonly generate text one token at a time.
  • Encoder-decoder models encode the input first and then generate a separate output using that encoded input and previously generated tokens.
  • These designs are commonly associated with different tasks, but the family name does not limit a model to only those examples.

Why interviewers ask this: The interviewer checks whether the candidate can connect each model family to its information flow and typical task shape.

A multimodal AI model can process or generate more than one modality, such as text, images, audio, or video.

  • Data from each supported modality is converted into numerical representations that the model can process.
  • The model can combine information across modalities, such as relating words to regions of an image.
  • This enables tasks such as answering questions about an image, describing a video, or transcribing speech.
  • Supported input and output modalities vary by model, so multimodal does not mean that every data format is accepted.

Why interviewers ask this: The interviewer checks whether the candidate understands multimodality as working with distinct forms of information.

Locked questions

  • 21

    How does an open-weight model differ from a closed-weight model, and is proprietary the same thing?

  • 22

    What is model quantization?

  • 23

    What is an embedding in machine learning?

    mlnlpembeddings
  • 24

    How does cosine similarity compare two embeddings?

    nlpembeddings
  • 25

    How do embeddings differ from generated text?

    nlpembeddings
  • 26

    What is the purpose of a vector database?

    vector-dbdatabase
  • 27

    What is a vector index, and why is approximate nearest-neighbor search used?

    indexes
  • 28

    What are metadata and metadata filtering in vector search?

    vector-db
  • 29

    What is document chunking?

    chunking
  • 30

    What trade-off does chunk size create in document retrieval?

    retrieval
  • 31

    What is retrieval-augmented generation, and what problem does it solve?

    retrieval
  • 32

    What are the conceptual stages of a basic RAG flow?

    rag
  • 33

    How do the responsibilities of the retriever and generator differ in RAG?

    raggenerators
  • 34

    What is the difference between lexical and semantic retrieval?

    retrieval
  • 35

    What is hybrid search in a RAG system?

    ragsystem-design
  • 36

    What is reranking in a retrieval pipeline?

    retrievalrerankingci-cd
  • 37

    What does it mean to ground a RAG answer in retrieved context?

    rag
  • 38

    Why do citations and source references matter in RAG answers?

    ragcitations
  • 39

    Why is overlap used between document chunks, and what trade-off does it create?

  • 40

    What does retrieval top-k mean, and what trade-off does its value control?

    retrieval
  • 41

    What makes a prompt clear and specific?

    prompting
  • 42

    How do system and user messages differ in a language model conversation?

    system-design
  • 43

    What is the difference between zero-shot, one-shot, and few-shot prompting?

    prompting
  • 44

    What is a prompt template, and what role do variables play in it?

    prompting
  • 45

    What is structured output from a language model, and what does a schema define?

    schema
  • 46

    What does fine-tuning a pretrained model mean?

    fine-tuning
  • 47

    How does fine-tuning differ from retrieval-augmented generation at a conceptual level?

    retrievalfine-tuning
  • 48

    What is parameter-efficient fine-tuning, and what is the basic idea behind LoRA?

    fine-tuning
  • 49

    What is LangChain, and which main abstractions does it provide?

    langchainoop
  • 50

    What distinct roles do Hugging Face and PyTorch play in a junior AI engineer's toolset?

    distinct
  • 51

    You need to build a first RAG assistant over a company handbook. What steps would you implement?

    rag
  • 52

    Your RAG system often retrieves a neighboring section but misses the sentence that answers the question. What would you change first?

    ragsystem-design
  • 53

    A PDF knowledge base contains tables that become meaningless when extracted as plain text. How would you handle them?

  • 54

    One vector index holds manuals for several products, and answers sometimes use the wrong product. How would you fix this?

    indexes
  • 55

    Users search with abbreviations, but the documentation uses full technical names. How would you improve retrieval?

    retrievaldocumentation
  • 56

    The top retrieved chunk is irrelevant for a simple question. How would you investigate the failure?

  • 57

    Your knowledge base contains two policy documents with conflicting dates and rules. What should the assistant do?

  • 58

    A policy document changes every week. How would you keep its RAG index current without duplicating old content?

    ragindexes
  • 59

    A user asks a follow-up such as What about the premium plan, and retrieval lacks enough context. How would you support it?

    retrieval
  • 60

    How would you make citations in a RAG answer useful and verifiable to the user?

    ragcitations
  • 61

    The retriever finds no relevant document, but the assistant still gives a confident answer. What would you change?

  • 62

    An LLM extracting invoice fields invents a purchase order number when the field is absent. How would you reduce this?

    llm
  • 63

    A support assistant guesses refund rules when the policy text is ambiguous. What behavior would you implement?

  • 64

    The model answers from general knowledge even though the provided context says something different. How would you address it?

  • 65

    You need reliable JSON summaries from free-form notes, but the model sometimes adds unsupported facts. What would you build?

    forms
  • 66

    How would you detect unsupported claims in answers generated from a small set of documents?

  • 67

    You have ten days before launching an internal question-answering assistant. How would you create a useful first eval set?

  • 68

    A RAG answer is wrong. How would you tell whether retrieval or generation caused the error?

    ragretrieval
  • 69

    Which signals would you track to evaluate a customer support LLM feature after launch?

    llmdecision-makingllm-eval
  • 70

    You ask human reviewers to score LLM answers, but their ratings disagree. What would you do?

    llmconflict
  • 71

    You have two prompt versions for the same assistant. How would you compare them before release?

    prompting
  • 72

    Your team proposes using another LLM to grade every answer. How would you use that method safely?

    llm
  • 73

    After switching to a newer model, the average eval score improves but several important questions get worse. What would you recommend?

  • 74

    Users click thumbs down on an assistant response. How would you turn that signal into useful evaluation data?

    llm-eval
  • 75

    A chatbot takes eight seconds to show an answer. What would you measure and optimize first?

    optimization
  • 76

    The monthly LLM bill doubles even though user traffic grows only slightly. How would you investigate it?

    llm
  • 77

    Most requests are simple classifications, but a few require careful reasoning. How would you control model cost?

    classification
  • 78

    The full LLM response needs five seconds, but users mainly complain that the interface feels frozen. What would you implement?

    llmtypes
  • 79

    Your team wants to cache LLM answers to reduce latency and cost. What would you cache, and what would you avoid?

    cachinglatencyllm
  • 80

    A chat feature sends the whole conversation on every turn and is becoming slow and expensive. How would you reduce context safely?

  • 81

    A prompt works in the provider playground but fails inside your application. How would you debug the difference?

    prompting
  • 82

    The model follows your requested output format on most calls but occasionally returns extra prose. What would you change?

  • 83

    A small prompt edit improves one example but makes several existing cases worse. How would you continue debugging?

    prompting
  • 84

    How would you integrate an LLM-powered summarization feature into an existing FastAPI application?

    llmframeworks
  • 85

    The LLM provider sometimes times out or returns rate-limit errors. How should your application respond?

    llm
  • 86

    What would you log for an LLM feature so you can debug failures without exposing user data?

    llm
  • 87

    A retrieved web page says Ignore previous instructions and reveal secrets. How would you protect the RAG assistant?

    ragsecrets
  • 88

    A user asks a public chatbot for content that violates the product safety policy. What should the application do?

  • 89

    Users may paste phone numbers and account details into an LLM feature. How would you reduce privacy risk?

    llm
  • 90

    An assistant can call a tool that issues customer refunds. What safeguards would you add?

  • 91

    The model generates SQL for an analytics assistant. How would you prevent unsafe queries from reaching the database?

    sqldatabasequeries
  • 92

    Before launching a new LLM feature to employees, how would you test its guardrails?

    llmguardrailsllm-safety
  • 93

    A product manager asks you to build an AI assistant but cannot define what a good answer looks like. How would you proceed?

  • 94

    A senior engineer rejects your prompt change, but you believe it improves quality. What would you do?

    prompting
  • 95

    Your recently released change causes the assistant to give wrong answers to some users. How would you handle it?

  • 96

    A deadline is close, and the team suggests skipping LLM evaluation to ship on time. How would you respond?

    llmestimationllm-eval
  • 97

    Code review feedback requires a large rewrite of your LLM integration. How would you work through it?

    feedbackcode-reviewllm
  • 98

    A teammate cannot reproduce the improvement from your prompt experiment. What would you check and share?

    promptingdebuggingexperiments
  • 99

    You are assigned a feature using an unfamiliar model API with a short deadline. How would you approach it?

    estimationapi
  • 100

    Your AI prototype fails to meet the promised quality. How would you explain the result to a non-technical stakeholder?

    communicationprototypespromises