This interview guide is for educational and informational purposes only. It is designed to help readers prepare, but it does not guarantee any interview result, hiring decision, offer, or outcome. Interview questions, hiring criteria, and preferred answers can vary by employer, interviewer, industry, location, and time. The examples and explanations reflect the authors' research and judgment, are provided without warranties of any kind, and should not be treated as the only correct approach. Diagrams are simplified illustrations intended to highlight the main components and their interactions; actual systems and implementations may be more complex. Alternative approaches may be equally valid or better suited to a particular question, context, or interviewer. To the fullest extent permitted by applicable law, the author, contributors, and publisher are not liable for decisions made, actions taken, or losses incurred based on this guide.
Identity, Image, and Privacy Notice
To respect individual privacy, some names, profile photographs, avatars, biographical details, and other identifying information displayed in this guide may be replaced with pseudonyms, licensed stock images, illustrative avatars, composite images, or representative descriptions. Unless a person is expressly identified as an actual contributor, a displayed name, image, or profile should not be understood as depicting or identifying a specific candidate, interviewer, employee, or other real individual. These representations are provided for editorial and illustrative purposes only and do not imply endorsement, employment, participation, or affiliation with this guide or any company mentioned in it. Any resemblance to an actual person is coincidental.
Company Notice
This guide is an independent educational resource and is not affiliated with, endorsed by, sponsored by, or approved by the company named in this guide. Company names are used only to identify interview experiences commonly reported by candidates. Interview practices can change without notice, and inclusion of company-specific content does not mean these questions are official, complete, or guaranteed to be asked. To the fullest extent permitted by law, the author, contributors, and publisher are not responsible for outcomes related to use of this material.
Questions or comments?
Contact us for general questions, or share feedback, technical corrections, and comments with the community.
1. What is Artificial Intelligence (AI)?Llm FundamentalsEasy
i Question Details
Define artificial intelligence in simple terms, distinguish AI systems from ordinary rule-based software, explain learning and inference, give common examples, and state important limits such as errors, bias, and the absence of human understanding.
Short Interview Answer (30-60 seconds)
Artificial intelligence is the ability of a computer system to use data to perform tasks that normally need some form of human intelligence, such as recognizing patterns, making predictions, or choosing an action. Ordinary rule based software follows explicit instructions written by people. Many AI systems instead learn useful patterns from examples. During inference, a trained model uses those patterns on new input. AI can be very useful, but its output can be wrong or biased, and the system does not understand the world like a human.
Detailed Explanation
Artificial intelligence means using computers to do tasks that normally need some form of human intelligence. For example, an AI system can identify spam, recommend a video, recognize speech, or help analyze an image. Many AI systems learn patterns from examples instead of receiving an exact rule for every possible case. After learning, the system can use those patterns on new input and produce a prediction, decision, or answer. The result is not guaranteed to be correct. AI can make errors, reflect bias in its data, and does not have human understanding.
Useful Questions to Ask the Interviewer
Would you like me to focus on AI systems that learn from data?
Would you like a simple example that compares AI with ordinary rule based software?
How to Explain It in an Interview
Start with a simple example. A traditional spam filter might use rules written by a programmer, such as marking a message when certain words appear. The software follows those fixed instructions. It does not learn new patterns by itself.
An AI based spam filter can instead learn from many examples of spam and normal email. During learning, also called training, the system finds patterns in the data and adjusts a model. A model is the learned representation that the system later uses to make predictions.
After training comes inference. Inference means using the trained model on new input. A new email enters the system, the model applies what it learned, and the system produces a prediction such as spam or not spam. The same basic idea appears in chatbots, recommendations, speech recognition, self driving perception, and medical image analysis.
The important difference is that ordinary rule based software usually follows explicit instructions written by people. An AI model can learn patterns from data and may produce probabilistic output. Probabilistic means the result can contain uncertainty instead of being guaranteed. AI is useful when the task contains many patterns that are difficult to describe with fixed rules.
The limits matter in production. AI can make mistakes. Poor or unbalanced data can create biased results. New situations can also differ from the training data. Most importantly, a model does not possess human understanding simply because its output looks intelligent. Engineers still need evaluation, monitoring, suitable application controls, and human review when errors could cause serious harm.
Technical Approach
Collect examples or other useful data for the task.
Train a model so it can learn patterns from that data.
Give the trained model a new input during inference.
Let the model use learned patterns to produce a prediction, decision, or answer.
Evaluate the result because AI output can be uncertain, wrong, or biased.
Use application rules, monitoring, or human review when the cost of an error is important.
Why Interviewers Ask This
Interviewers ask this question to check whether a candidate understands the basic idea behind AI systems. They want to hear the difference between software that follows fixed rules and systems that learn patterns from data. They also test whether the candidate understands training, inference, uncertain outputs, and practical limits such as errors, bias, dependence on data, and the lack of human understanding.
Common interview mistakes
A common mistake is saying that all AI systems think or understand like humans. They do not. Another mistake is saying that AI always learns while it is being used. Training and inference are normally separate stages unless the surrounding system is specifically designed for continued learning. Candidates also sometimes claim that AI is always better than fixed rules. Rule based software can be simpler and more reliable when the logic is stable and easy to define. Another mistake is assuming that more data always makes a model correct. Data quality, coverage, bias, model design, and evaluation still matter.
Interview tip
Give the definition first, then use one simple example. Compare a learned spam filter with fixed rules. Explain training and inference in that order. Finish with the main limits: errors, bias, dependence on data, and no human understanding.
Interviewer may ask next
Can an AI model still be wrong after it has been trained on a large amount of data?
Yes. A trained AI model can still produce a wrong result. The exact behavior is a prediction based on learned patterns, not guaranteed truth. Errors can appear when the training data is incomplete, biased, noisy, or different from the new input. This matters because a confident looking result can still be incorrect. In important applications, engineers evaluate the model, monitor failures, add application controls, and use human review when the cost of a mistake is high.
When would ordinary rule based software be a better choice than AI?
Rule based software can be better when the required behavior is simple, stable, and can be written clearly as explicit rules. The exact change is replacing learned probabilistic behavior with deterministic application logic. Deterministic means the same input follows the same fixed rules and gives the same output. This can be easier to test and control. The tradeoff is that fixed rules become difficult to maintain when the problem contains many complex or changing patterns, while AI can learn such patterns from data but introduces uncertainty and additional evaluation needs.
2. What is a foundation model?Llm FundamentalsEasy
i Question Details
Require a mechanism-level account of pretraining objectives, transfer to downstream tasks, and the engineering consequences of adapting a general model.
Short Interview Answer (30-60 seconds)
A foundation model is a large model pretrained on broad and diverse data so it learns general patterns that can transfer to many tasks. Instead of training a new model from the beginning for every task, an AI engineer can start with the pretrained model and adapt it with prompting or fine tuning. The main benefit is reuse. Important engineering concerns include adaptation cost, data needs, model quality, and safety.
Detailed Explanation
A foundation model is a large general model that first learns from a very large and varied collection of data. The goal is to learn useful patterns before the model is given one narrow job. After this broad learning stage, the same model can become a starting point for tasks such as answering questions, classifying text, judging sentiment, or working with images. Engineers can guide it with instructions or train it further on a smaller task focused data set. This reduces repeated training work, but it still requires careful testing, cost control, and safety checks.
Useful Questions to Ask the Interviewer
Should I focus on language foundation models, or include models that also learn from images and audio?
Do you want me to compare prompting with fine tuning?
How to Explain It in an Interview
A useful way to think about a foundation model is as a general starting point rather than a finished task model.
First comes pretraining. The model sees broad and diverse data such as text, code, images, or audio. A common pretraining objective asks the model to predict a missing part of the input. For example, it might see a sentence with one hidden word and learn to predict the likely word. Repeating this prediction task across large amounts of data changes the model weights so they capture broad statistical patterns and useful knowledge.
The result is the foundation model. It is not limited to one task. Its pretrained weights provide a strong starting point that can transfer to downstream tasks such as question answering, text classification, sentiment analysis, or image related tasks.
Next comes adaptation. Prompting gives the model instructions and examples as input without changing its weights. Fine tuning trains the model on smaller task specific data and updates model weights. Fine tuning can produce more specialized behavior, but it requires training compute, suitable data, evaluation, and model management.
The main engineering benefit is reuse. A strong base model can make new systems faster to build, can reduce the amount of task specific training data needed, and can support many different tasks. The tradeoffs are adaptation cost and ongoing quality and safety work. Foundation models can still produce biased, incorrect, or harmful outputs. Production systems therefore need evaluation and monitoring. The model also does not automatically search, verify facts, cite sources, remember users, or call tools unless the surrounding application provides those mechanisms.
Technical Approach
Pretrain one large general model on broad and diverse data such as text, code, images, or audio.
Use a prediction objective, such as predicting a missing part of the input, to update model weights and learn broad patterns.
Keep the resulting pretrained model as a general foundation model rather than a model for only one task.
Transfer the pretrained model to a downstream task such as question answering, text classification, sentiment analysis, or an image related task.
Adapt it with prompting when model weight changes are not needed, or use fine tuning on smaller task specific data when the weights should be updated.
Evaluate the adapted system for task quality, cost, bias, errors, misuse risk, and safety before and during production use.
Why Interviewers Ask This
Interviewers ask this to check whether you understand why one large pretrained model can become a useful starting point for many AI tasks. They want to see if you can separate pretraining from later adaptation, explain how prompting differs from fine tuning, and discuss practical costs, quality risks, and safety work when a general model is used in production.
Common interview mistakes
A common mistake is saying a foundation model is already specialized for one task. It is a general starting point. Another mistake is treating prompting and fine tuning as the same thing. Prompting changes the input while keeping model weights unchanged. Fine tuning updates model weights using task specific training data. It is also wrong to assume the model automatically searches the web, verifies facts, cites sources, remembers users, or uses tools. Those abilities require surrounding system components. Broad pretraining also does not make the model always correct or safe.
Interview tip
Start with the simple idea that a foundation model is pretrained on broad data and then reused for many tasks. Explain the flow in order: pretraining objective, foundation model, knowledge transfer, prompting or fine tuning, then engineering consequences such as faster development, lower task data needs, adaptation cost, quality, and safety.
Interviewer may ask next
Does a foundation model automatically know the correct answer for every downstream task?
No. Pretraining gives the model broad learned patterns, not guaranteed correctness. Its output can still be wrong, biased, or unsafe. The adapted system must be evaluated on the real downstream task and monitored in production. This matters because transfer gives engineers a strong starting point, but it does not remove the need for task specific testing and safety controls.
When would you use prompting instead of fine tuning a foundation model?
Use prompting when instructions and examples are enough and you do not need to change model weights. It is faster to try and avoids an additional training process. Use fine tuning when you need more specialized task behavior and have suitable task specific data. Fine tuning can give stronger specialization, but it adds training compute, data work, evaluation, and model management.
3. What is a Large Language Model (LLM)?Llm FundamentalsEasy
i Question Details
Define the concept through next-token prediction, Transformer computation, the distinction between training and inference, and known limitations.
Short Interview Answer (30-60 seconds)
A Large Language Model is a neural network trained on large amounts of text to predict the next token from the context it receives. A Transformer processes the input tokens and produces scores for possible next tokens. Those scores become probabilities, and a decoding method selects a token. During training, the model changes its weights to reduce prediction error. During inference, the weights are normally fixed and the model generates text one token at a time. Its output is probabilistic, so it can be wrong, reflect bias, and lack current knowledge unless an external system supplies it.
Detailed Explanation
A Large Language Model learns patterns from large collections of text. Its main job is simple: given some text, predict what token could come next. A token is a small piece of text. The model repeats this process to create longer responses. Training is when the model learns by changing its internal weights after comparing predictions with the real next tokens. Inference is when we use the trained model. Its weights normally stay fixed. The model can produce useful text, but its answers are not guaranteed to be correct or current.
Useful Questions to Ask the Interviewer
Would you like the explanation to focus only on basic model behavior, or also on production concerns?
Should I explain the Transformer internals in detail, or keep them at a high level?
How to Explain It in an Interview
Start with a small example. Suppose the context is "The cat sat on the". The model produces a probability distribution over possible next tokens. In the diagram, "roof" has a stronger probability than alternatives such as "sofa" or "floor". A decoding method then selects a token from that distribution, for example by sampling.
The Transformer performs the main computation. Input tokens are first converted into numeric representations that include token information and position information. Masked self attention lets each position use the available earlier context while blocking future positions. The result passes through an add and normalization step, then a feed forward network, followed by another add and normalization step. These Transformer blocks can be repeated several times. The output layer then produces scores for the vocabulary, and those scores are converted into probabilities for the next token.
Training and inference are different. During training, the model sees large collections of text. At each position, it predicts the next token, compares that prediction with the actual next token, and changes its weights to reduce prediction loss. During inference, the model parameters are normally fixed. The model receives a prompt, computes probabilities for the next token, selects one token, appends it to the text, and repeats the process.
This behavior matters because an LLM is a probabilistic pattern model, not a guaranteed source of truth. It can confidently generate incorrect or made up information. It can reflect bias in its training data. Its knowledge is limited by its training data and surrounding system. It does not automatically know live events, search the web, verify claims, remember information across sessions, or use tools unless the surrounding application provides those capabilities.
Technical Approach
Split the input text into tokens.
Convert the tokens into numeric representations with position information.
Pass the representations into a Transformer block.
Use masked self attention so each position can use the available earlier context without using future positions.
Combine the attention result with the residual path and apply normalization.
Pass the result through the feed forward network.
Combine that result with its residual path and apply normalization again.
Repeat the Transformer block for the configured number of layers.
Pass the final representation through the vocabulary output layer.
Convert the vocabulary scores into probabilities for possible next tokens.
Select one token using the configured decoding method.
Append that token to the context and repeat during generation.
During training, compare predictions with the actual next tokens and update model weights to reduce prediction loss.
During inference, normally keep the trained weights fixed and run only the prediction and decoding process.
Why Interviewers Ask This
Interviewers ask this to check whether I understand the basic behavior behind modern language models. They want to know if I can explain next token prediction, Transformer computation, training, inference, and important limitations without treating the model as a search engine or a source of guaranteed facts.
Common interview mistakes
A common mistake is saying that an LLM searches a database for the answer. The base model instead predicts tokens from its context and learned weights. Another mistake is saying that it always chooses the most likely token. A decoding method may sample from the probability distribution. Candidates also sometimes mix training with inference. Training changes the model weights, while normal inference does not. Another mistake is forgetting masking and claiming that next token prediction can use future tokens. Candidates may also assume the model automatically has current information, verifies facts, remembers past conversations, or uses tools. Those behaviors require support from the surrounding system.
Interview tip
Start with the one sentence definition, then walk through the small next token example. After that, explain the Transformer flow from tokens to probabilities, clearly separate training from inference, and finish with limitations. Keep the model itself separate from external retrieval, memory, search, verification, and tools.
Interviewer may ask next
Why can an LLM produce a confident answer that is still wrong?
Because the model predicts tokens that fit learned patterns and the current context. It does not automatically verify whether each generated statement is true. A likely sequence can still contain incorrect or made up information. This matters in production because applications that require reliable facts may need retrieval, validation, human review, or other external checks.
Why might we sample from the next token probabilities instead of always choosing the highest probability token?
Sampling allows different plausible tokens to be selected instead of always taking the single highest probability choice. This can make generation more varied and useful for open ended tasks. The tradeoff is that more randomness can also increase inconsistency or lower quality output. The application chooses a decoding strategy based on how much variety and predictability it needs.
4. What is the Transformer architecture?Llm FundamentalsEasy
i Question Details
Define the concept through token embeddings, attention blocks, feed-forward blocks, residual paths, normalization, and the output projection.
Short Interview Answer (30-60 seconds)
A Transformer turns tokens into contextual representations by combining token embeddings with position information, then passing them through repeated blocks of self attention and feed forward processing. Each sublayer uses a residual path and LayerNorm, which is a normalization step. After the repeated blocks, a final LayerNorm and linear output projection produce vocabulary logits. Softmax converts those logits into next token probabilities. In the causal decoder style shown in the diagram, each token can attend to itself and earlier tokens, but not future tokens.
Detailed Explanation
A Transformer is a model design that takes a sequence of text pieces and gradually builds a richer representation of what each piece means in context. It first turns every piece into numbers and adds information about its position in the sequence. It then repeats two main processing steps several times. One step lets each position gather useful information from allowed positions. The other transforms each position separately. Extra paths help keep earlier information. At the end, the model produces scores for possible next pieces and converts them into probabilities.
Useful Questions to Ask the Interviewer
Are you asking about the causal decoder style Transformer used for next token generation?
Should I explain the attention calculations, or focus on the main data flow and purpose of each block?
How to Explain It in an Interview
Start with the input tokens. Each token is mapped to a learned embedding vector. Position information is added so the model can represent token order. The resulting sequence representation enters a Transformer block, and that block is repeated L times.
The first main part of each block is multi head self attention. The current representation is projected into query, key, and value matrices. Query and key values produce attention scores. Scaled dot product attention uses those scores to mix the value information. In the causal version shown in the diagram, a mask blocks future positions, so a token can attend only to itself and earlier tokens. The attention heads are concatenated, then a linear projection maps the result back to the model hidden size.
A residual path adds the original sublayer input to the attention output. LayerNorm then normalizes the hidden values. The second main part is the position wise feed forward network. It applies a linear transformation, GELU activation, and a second linear transformation independently at every sequence position. A second residual path and LayerNorm follow.
After the final repeated block, a final LayerNorm produces the final hidden states. A linear output projection maps each hidden state from the model hidden size to vocabulary logits. Logits are unnormalized scores for vocabulary items. Softmax converts them into probabilities. During generation, the system selects or samples a token from that probability distribution and repeats the process for the next position.
A practical tradeoff is attention cost. Standard self attention becomes much more expensive as sequence length grows because every position compares with many other positions. This increases compute and memory use for long contexts.
Technical Approach
Split the input text into tokens.
Map each token to a learned embedding vector.
Add position information so token order is represented.
Send the sequence representation through L repeated Transformer blocks.
In each block, project the representation into query, key, and value matrices.
Compute scaled dot product self attention and apply the causal mask so each token can use only itself and earlier tokens.
Concatenate the attention heads and apply the output projection for the attention sublayer.
Add the residual path and apply LayerNorm.
Apply the position wise feed forward network using a linear transformation, GELU, and a second linear transformation.
Add the second residual path and apply LayerNorm.
After the final block, apply a final LayerNorm.
Apply a linear output projection from the model hidden size to the vocabulary size to produce logits.
Apply Softmax to convert logits into next token probabilities.
Why Interviewers Ask This
Interviewers ask this to check whether you understand the main parts of a Transformer and how data moves through them. They want to see that you can connect token embeddings, position information, self attention, feed forward processing, residual paths, normalization, and the final output projection into one clear model mechanism. They also want to know whether you understand causal masking and the practical cost of attention as the input sequence grows.
Common interview mistakes
A common mistake is saying attention alone is the whole Transformer. A Transformer block also contains the feed forward network, residual paths, and normalization. Another mistake is forgetting position information. Token embeddings alone do not represent token order. Candidates also often confuse logits with probabilities. The linear output projection produces logits, while Softmax converts those logits into probabilities. In the causal architecture shown here, another mistake is allowing a token to attend to future positions during next token prediction.
Interview tip
Explain the flow in order: tokens, embeddings plus position information, repeated self attention and feed forward blocks, residual paths plus LayerNorm, final LayerNorm, vocabulary logits, then Softmax. State the purpose of each part in one short sentence. Also make clear that the diagram shows a causal decoder style Transformer for next token prediction.
Interviewer may ask next
What changes if the causal mask is removed?
Removing the causal mask lets each token attend to future positions as well as earlier positions. That breaks the next token prediction rule shown in the diagram because a position could use information that should still be hidden. For causal generation, the mask is required so each prediction depends only on the allowed context.
What is the main performance tradeoff of self attention as the sequence becomes longer?
The main tradeoff is increasing compute and memory use. Standard self attention compares every sequence position with many other positions, so its cost grows quickly as sequence length increases. The benefit is that attention can connect distant tokens directly, but long contexts make the attention step a major production cost.
5. What are the main parts of a Transformer?Llm FundamentalsEasy
i Question Details
Define the concept through the ordered responsibilities of token embeddings, attention, feed-forward layers, residual connections, normalization, and the language-model head.
Short Interview Answer (30-60 seconds)
A Transformer first turns tokens into embedding vectors and adds position information. It then passes those vectors through repeated Transformer blocks. Inside each block, self attention lets each token gather useful context, while a feed forward network transforms each token representation. Residual connections carry earlier information around both parts, and normalization keeps the representations well behaved. After the final block, the language model head projects the final hidden representation to vocabulary logits. Softmax can then turn those logits into probabilities for the next token.
Detailed Explanation
A Transformer changes a sequence of text pieces into a prediction in several ordered steps. First, the text is split into tokens. Each token becomes a vector of numbers that represents learned information about that token. Position information is added so the model can tell which token came first, second, and so on. The model then passes these representations through repeated processing blocks. Each block lets tokens use information from other allowed tokens, transforms the result, and keeps useful earlier information. At the end, the model converts the final representation into scores for possible next tokens.
Useful Questions to Ask the Interviewer
Should I explain a decoder style Transformer used for next token prediction?
Would you like the explanation to include the internal attention steps such as queries, keys, and values?
How to Explain It in an Interview
Start with token embeddings. An embedding maps each token to a learned vector. Position information is added because attention alone does not know token order.
The vectors then enter repeated Transformer blocks. The first major part is multi head self attention. Self attention lets each token gather context from other allowed token positions. In an autoregressive language model, a causal mask blocks attention to future tokens. Multiple heads let the model learn different attention patterns at the same time.
Attention forms queries, keys, and values from the block input. A query represents what a position is looking for. A key represents what another position can match against. A value carries the information that can be collected. Scaled dot product attention uses the query and key relationship to weight the values. The outputs from the attention heads are combined and projected.
After attention, a residual connection adds the attention output back to the sublayer input. Normalization then keeps the representation well scaled. The block next applies a position wise feed forward network. This is a small neural network applied separately to every token position. Another residual connection adds that output back to its input, followed by normalization.
The output then moves to the next Transformer block. After the final block, the language model head uses a linear projection to produce one logit for each vocabulary token. A logit is an unnormalized score. Softmax can convert those logits into probabilities used to choose or sample the next token.
Technical Approach
Split the input text into tokens.
Map each token to a learned embedding vector.
Add position information so token order is represented.
Send the representations into a Transformer block.
Form queries, keys, and values for multi head self attention.
Apply the causal mask so each position uses only allowed token positions.
Combine the attention outputs, add the result back to the sublayer input through a residual connection, and normalize.
Apply the position wise feed forward network to each token representation.
Add the feed forward output back to its sublayer input through another residual connection, and normalize.
Repeat the Transformer block for the remaining layers.
Send the final hidden representations through the language model head.
Produce vocabulary logits and use softmax when next token probabilities are needed.
Practical Insights
The main expensive part shown here is standard self attention. For a sequence with n tokens, attention compares token positions with other token positions, so the attention score work grows roughly with n squared. Longer context can therefore require much more computation and memory.
Why Interviewers Ask This
Interviewers ask this to check whether you understand how a language model turns tokens into useful internal representations and then into a prediction. They want to see whether you can explain embeddings, attention, feed forward processing, residual connections, normalization, and the language model head as one ordered flow. A strong answer also shows that you understand why position information matters and why attention must respect token order during next token prediction.
Common interview mistakes
A common mistake is saying that attention alone is the whole Transformer. Attention is only one sublayer inside each repeated block. Another mistake is forgetting position information, which is needed because the model must represent token order. Candidates also sometimes omit the feed forward network or treat it as part of attention. Residual connections do not replace a sublayer output. They add the sublayer output back to its input. Another mistake is saying that softmax is part of every Transformer block. In this diagram, softmax comes after the language model head when vocabulary logits are converted into next token probabilities.
Interview tip
Explain the Transformer as one flow from tokens to probabilities. Start with embeddings and position information. Then describe one repeated block using self attention, a residual connection, normalization, feed forward processing, another residual connection, and normalization. Finish with the language model head, vocabulary logits, and softmax. This order makes each responsibility easy to follow.
Interviewer may ask next
Why does a language model use a causal mask in self attention?
A causal mask prevents a token position from attending to future tokens during next token prediction. Each position may use only the current and earlier allowed positions. This matters because training should match the information available when the model generates text one token at a time. Without the mask, a position could use future tokens while learning, which would break the intended autoregressive behavior.
What becomes expensive as the input sequence gets longer?
Standard self attention becomes increasingly expensive because token positions compare with other token positions. With n tokens, the attention score work grows roughly with n squared. This matters in production because longer context can increase computation, memory use, and latency. The tradeoff is that more context can provide useful information, but it also makes the attention step more costly.
6. What is tokenization?Llm FundamentalsEasy
i Question Details
The explanation should make vocabulary construction, subword boundaries, token IDs, unknown text, and the effect of token counts on context usage explicit.
Short Interview Answer (30-60 seconds)
Tokenization breaks text into smaller units called tokens and maps those tokens to integer IDs that a model can process. Modern tokenizers often use subword pieces, so rare or unseen words can often be represented by combining known pieces. The number of resulting tokens also matters because the model context limit is measured in tokens, not characters.
Detailed Explanation
Tokenization is the step that turns written text into small pieces before a language model works with it. A short sentence may become several pieces, and a long or unusual word may become more than one piece. Each piece is also linked to a number that the model uses internally. The way text is divided depends on the set of pieces learned for that model. This matters because the model has a limited amount of text it can handle at one time, and that limit is counted using these pieces.
Useful Questions to Ask the Interviewer
Should I explain a specific tokenizer or keep the answer provider neutral?
Would you like me to cover how rare or unknown text is handled?
How to Explain It in an Interview
A tokenizer has a vocabulary. The vocabulary is a set of token pieces, and each piece has an integer ID. During vocabulary construction, a tokenizer can learn useful character or subword patterns from a large text collection. One common method is byte pair encoding, which repeatedly combines frequent neighboring pieces to form useful vocabulary entries.
At inference time, the tokenizer reads the input text and produces an ordered sequence of vocabulary pieces. These pieces can be whole words, parts of words, punctuation, spaces, bytes, or other text units. In the diagram, the text "I love ice cream!" becomes several tokens. Each token then maps to an integer ID. Those IDs are used for embedding lookup before the model processes the sequence.
Subword tokenization helps because the vocabulary does not need a separate entry for every possible word. A rare or unseen word can often be represented by combining smaller known pieces. For example, a word such as "microchips" may be split into several known parts. Some tokenizers use a special unknown token when text cannot be represented. Byte based tokenizers can often avoid that fallback because they can represent text with smaller byte units.
Token count also affects context usage. A model has a maximum context length measured in tokens. More input tokens consume more of that capacity and leave less space for other context or generated output. More tokens also generally require more computation. The exact effects on latency and API cost depend on the model and serving system.
Technical Approach
Build or load the tokenizer vocabulary, where each token piece has an integer ID.
Read the input text and split it into vocabulary pieces according to the tokenizer rules.
Use subword pieces when a whole word is not represented as one token.
If the tokenizer supports an unknown token and some text still cannot be represented, map that case to the unknown token. Byte based tokenizers can often avoid this fallback.
Convert every resulting token to its integer ID while keeping token order unchanged.
Use the token IDs for embedding lookup before the model processes the sequence.
Count the resulting tokens because that count consumes part of the model context capacity.
Why Interviewers Ask This
Interviewers ask this question to check whether you understand how text becomes model input. They want to see whether you understand vocabulary construction, token boundaries, token IDs, rare or unseen text, and context usage. This knowledge matters because tokenization affects what the model receives, how much context capacity an input uses, and how much computation may be required.
Common interview mistakes
A common mistake is saying that one token always equals one word. Tokens can be whole words, parts of words, punctuation, spaces, bytes, or other units. Another mistake is assuming that every tokenizer handles unknown text in the same way. Some use an unknown token, while byte based tokenizers can often represent text using smaller units. Candidates also sometimes confuse token IDs with embeddings. A token ID is an integer lookup key, while an embedding is the numeric vector obtained through embedding lookup. Finally, character count is not the same as token count, so prompt length should be checked in tokens.
Interview tip
Start with the simple flow: text becomes token pieces, token pieces become integer IDs, and those IDs are used for embedding lookup before model processing. Then explain why subwords help with rare text and finish by connecting token count to context usage. Make it clear that exact token boundaries and IDs depend on the tokenizer.
Interviewer may ask next
What happens when the tokenizer sees a word that is not in its vocabulary?
The tokenizer usually tries to represent the text using smaller known pieces instead of requiring the whole word to exist as one token. With subword tokenization, a rare or unseen word can often be split into known subword units. Some tokenizers use a special unknown token when the text still cannot be represented. Byte based tokenizers can often avoid that fallback by representing the text with smaller byte units. This matters because the fallback behavior affects whether the text can be represented and how many tokens are produced.
Why does token count matter in production LLM systems?
Token count matters because the model context limit is measured in tokens. A longer input uses more context capacity and leaves less room for other prompt content or generated output. More tokens also generally require more computation, which can affect latency and throughput. API cost can also depend on token usage, but the exact pricing rule depends on the provider and model. In production, engineers therefore measure tokens rather than characters when checking prompt size and planning context usage.
7. What is Byte Pair Encoding (BPE)?Llm FundamentalsEasy
i Question Details
Explain the mechanism by working through iterative merge rules, vocabulary size, segmentation behavior, and treatment of rare words.
Short Interview Answer (30-60 seconds)
Byte Pair Encoding, or BPE, is a subword tokenization method. It starts with small symbols such as characters or bytes. It repeatedly counts adjacent pairs and merges the most frequent pair into a new token. Each merge grows the vocabulary. After training, the learned vocabulary and merge rules are used to split new text into known tokens. Frequent patterns can become larger tokens, while rare words can fall back to smaller known pieces.
Detailed Explanation
Byte Pair Encoding is a way to turn text into reusable pieces before an LLM processes it. Imagine the training words low, lower, and newest. We first split them into small symbols. Then we look for neighboring symbols that occur often and join them. A pair such as l followed by o can become lo. Later, lo followed by w can become low. Repeating this process creates a vocabulary containing useful pieces of different sizes. Common patterns often become larger tokens. Rare words can still be represented with smaller known pieces when the base symbol set covers their text.
Useful Questions to Ask the Interviewer
Should I explain BPE starting from characters or from bytes?
Would you like me to walk through the low, lower, and newest example?
How to Explain It in an Interview
BPE learns its vocabulary through repeated pair merges. Start with the training text split into small symbols. In the diagram, the example contains low, lower, and newest. A word boundary marker may also be kept so the tokenizer can distinguish positions around word endings.
At each learning step, count every adjacent pair in the current tokenized training data. Choose the pair with the highest frequency. Replace its applicable occurrences with one new token, then add that token to the vocabulary. For example, l followed by o can become lo. A later merge can combine lo with w to create low. The process repeats. If several pairs have the same frequency, the tokenizer implementation needs a deterministic tie rule so the learned merge order is reproducible.
Training stops when the requested vocabulary size or merge limit is reached. Numbers such as 30000 or 50000 tokens are examples rather than universal values. Each additional merge can create a larger reusable token.
For new text, the tokenizer uses the learned vocabulary and merge order to produce subword tokens. Common patterns may be represented by larger pieces. Rare text can use smaller pieces instead. For example, lowest can reuse low and represent the remaining characters with smaller known tokens.
Vocabulary size creates an important tradeoff. A larger vocabulary can represent some text with fewer tokens, but the model must keep representations for more token entries. A smaller vocabulary uses fewer entries, but the same text may require a longer token sequence. With byte level BPE, every byte sequence can be represented from the base byte vocabulary. With character level BPE, coverage depends on which base characters are included.
Technical Approach
Split the training text into initial symbols such as characters or bytes.
Count the frequency of every adjacent symbol pair.
Select the most frequent pair. If frequencies tie, use the tokenizer implementation's deterministic tie rule.
Replace applicable occurrences of that pair with one merged token.
Add the merged token to the vocabulary.
Repeat the counting and merging steps until the target vocabulary size or merge limit is reached.
Save the learned vocabulary and ordered merge rules.
Use those learned rules to segment new text into known subword tokens.
Represent rare text with smaller known pieces when a larger learned token is unavailable.
Why Interviewers Ask This
Interviewers ask this to check whether I understand how a tokenizer builds reusable subword tokens from repeated text patterns. They also want to see whether I understand iterative pair merging, vocabulary growth, segmentation of later text, treatment of rare words, and the tradeoff between vocabulary size and token sequence length.
Common interview mistakes
One common mistake is saying that BPE stores every complete word. It does not. It learns reusable subword tokens by merging repeated adjacent symbol pairs. Another mistake is saying that rare words always become an unknown token. With byte level BPE, arbitrary input bytes can fall back to the base byte tokens. With character level BPE, this depends on the base character vocabulary covering the input. Another mistake is assuming the model relearns merges during each response. The tokenizer uses merge rules learned earlier. Candidates also sometimes ignore tie handling when several pairs have the same frequency or assume that a larger vocabulary is always better.
Interview tip
Start with the main idea: BPE repeatedly merges frequent adjacent symbol pairs into reusable subword tokens. Then use the low, lower, and newest example to show one or two merges. Finish with the two practical points the interviewer is likely testing: rare text can fall back to smaller known pieces, and vocabulary size trades a larger token table for potentially shorter token sequences.
Interviewer may ask next
What happens when BPE sees a rare or unseen word?
It can represent the word with smaller known tokens when the base symbol vocabulary covers the input. For example, lowest may reuse the learned token low and represent the remaining text with smaller pieces. With byte level BPE, the base byte vocabulary can represent arbitrary byte sequences, so an unknown whole word is not required. With character level BPE, coverage depends on the available base characters. The main tradeoff is that rare words may require more tokens than common words.
How does vocabulary size affect a BPE tokenizer?
A larger vocabulary allows more merged patterns to become individual tokens, so some text can use fewer tokens. A smaller vocabulary keeps fewer token entries but may produce longer token sequences. This matters because sequence length affects how much token level work the model performs, while vocabulary size affects structures such as the token embedding table and output vocabulary. The best size is therefore a practical balance rather than a value that should always be increased.
8. What are WordPiece and SentencePiece?Llm FundamentalsEasy
i Question Details
Clarify the scoring or segmentation differences between WordPiece and SentencePiece and their handling of open vocabularies.
Short Interview Answer (30-60 seconds)
WordPiece and SentencePiece both break text into reusable subword pieces so many rare or unseen words can still be represented. WordPiece tokenization commonly uses greedy longest match against a learned vocabulary, with "##" marking continuation pieces. SentencePiece works directly with raw text and is a framework that can use models such as Unigram or BPE. Unigram scores possible segmentations probabilistically, while BPE follows learned merge rules. Neither approach guarantees that an unknown token can never occur.
Detailed Explanation
Both methods help a language model handle words that are not stored as complete entries. They break text into smaller reusable pieces instead of needing one stored entry for every possible word. WordPiece usually chooses matching pieces from a learned list. SentencePiece can learn from the original text directly and supports more than one way to choose pieces. This difference matters because the same input can be split differently. Both methods often handle rare words well, but neither guarantees that every possible input will avoid an unknown result.
Useful Questions to Ask the Interviewer
Do you want the comparison to focus on WordPiece tokenization versus SentencePiece Unigram, or SentencePiece as a framework?
Should I also explain what happens when the vocabulary cannot represent part of the input?
How to Explain It in an Interview
Start with the shared goal. A tokenizer has a fixed vocabulary, but real text contains many rare or new words. Subword tokenization reduces this problem by breaking text into smaller pieces that are already in the vocabulary.
For WordPiece, imagine the word "playing". If the vocabulary contains "play" and "##ing", tokenization can produce those two pieces. The "##" marker commonly means that the second piece continues a word. At tokenization time, WordPiece commonly uses greedy longest match. At each position, it chooses the longest vocabulary token that matches the remaining characters. If no valid sequence of pieces can cover a word, an unknown token such as "[UNK]" may be produced.
SentencePiece is different because it is a tokenizer framework rather than one scoring rule. It can train directly from raw text without requiring external pretokenization. A visible "▁" marker commonly represents a preceding space or word boundary. SentencePiece can use Unigram or BPE. Unigram assigns probabilities to candidate pieces and scores possible segmentations. BPE instead uses learned merge rules.
In production, the important point is not to assume that either method can represent every possible input. Rare text is often decomposed into known pieces, but unknown tokens can still occur unless another fallback mechanism, such as byte fallback, is configured.
Technical Approach
Start with input text.
Use the tokenizer vocabulary learned during training.
With WordPiece, scan the text and choose the longest matching vocabulary piece at each position. Continuation pieces commonly use "##".
With SentencePiece, process raw text directly and apply the configured subword model.
If the model is Unigram, score candidate segmentations probabilistically. If it is BPE, apply learned merge rules.
Convert the selected pieces into token IDs for the language model.
If the input cannot be covered by available pieces, an unknown token may appear unless another fallback mechanism is configured.
Why Interviewers Ask This
Interviewers ask this to check whether a candidate understands how text becomes model input. They want to see whether the candidate can explain how WordPiece chooses pieces, why SentencePiece is a framework rather than one scoring rule, and how both approaches handle rare or unseen text. This also tests whether the candidate understands important limits, including when an unknown token can still appear.
Common interview mistakes
A common mistake is saying that SentencePiece always uses one probabilistic algorithm. It can use different subword models, including Unigram and BPE. Another mistake is treating WordPiece vocabulary learning as the same process as runtime tokenization. Runtime WordPiece tokenization commonly uses greedy longest match. It is also wrong to claim that either approach always represents every possible input without an unknown token. Another mistake is treating "##" and "▁" as universal syntax rather than conventions used by particular tokenizer representations.
Interview tip
Explain the shared goal first, then give one small example. Say that WordPiece commonly uses greedy longest match and "##" continuation pieces. Then explain that SentencePiece works on raw text and is a framework that may use Unigram or BPE. Finish by mentioning that rare text is often split into known pieces, but unknown tokens are still possible depending on the tokenizer configuration.
Interviewer may ask next
What happens if a rare word cannot be fully represented by the tokenizer vocabulary?
An unknown token may be produced if no valid sequence of vocabulary pieces covers the input. With WordPiece, this can happen when the matching process cannot complete a word using known pieces. SentencePiece can also have an unknown token depending on its model and configuration. A system may use another fallback mechanism, such as byte fallback, when supported. This matters because an unknown token removes some of the original text detail before the language model sees it.
What is the main tradeoff between WordPiece segmentation and SentencePiece Unigram segmentation?
WordPiece commonly makes a local greedy longest matching choice, while SentencePiece Unigram evaluates candidate segmentations using learned probabilities. The WordPiece rule is simple and deterministic for a fixed vocabulary. Unigram can compare alternative segmentations according to its probabilistic model. The tradeoff is that the two methods can create different token boundaries and different token counts for the same text. In production, the tokenizer must exactly match the vocabulary and tokenization method expected by the model.
9. What is positional encoding?Llm FundamentalsEasy
i Question Details
A complete explanation should cover how sequence order enters attention, the difference between absolute and relative position information, and long-sequence behavior.
Short Interview Answer (30-60 seconds)
Positional encoding gives self attention access to token order. For example, the tokens in "The cat sat" have both content and position information, so the model can distinguish that order from another ordering of the same tokens. Absolute methods represent where a token is in the sequence. Relative methods represent the distance or offset between token positions and can influence attention scores. For long sequences, behavior depends on the position method and how the model was trained.
Detailed Explanation
Think about the sentence "The cat sat." The words have meaning, but their order also matters. A Transformer therefore needs information that tells it where tokens appear in the sequence. Positional encoding provides that information. It allows self attention to use token content together with token order when building contextual representations. Absolute methods describe where a token is. Relative methods describe how far token positions are from each other. The choice matters because different methods behave differently when sequences become longer than those commonly seen during training.
Useful Questions to Ask the Interviewer
Do you want me to compare absolute and relative position methods?
Should I also explain behavior beyond the sequence lengths used during training?
How to Explain It in an Interview
Start with the input sequence. Tokenization creates tokens such as "The", "cat", and "sat". Each token gets an embedding that represents its content. The Transformer also receives position information before or during attention.
With an absolute method, each token receives information about where it is in the sequence. One common approach adds an absolute position representation to the token embedding. Sinusoidal encoding is one example. Learned absolute position embeddings are another example.
With a relative method, the model represents the distance or offset between token positions. This information can influence attention scores, for example through a relative bias or relative key representation. The model can then reason about relationships such as one token being two positions before another.
This information is needed because self attention without position information is permutation equivariant. If the input tokens are reordered, the corresponding outputs are reordered in the same way. Attention alone therefore does not assign sequence meaning to that ordering.
Long sequence behavior depends on the chosen method. Learned absolute embeddings may have a fixed trained position range. Some relative or functional schemes can extrapolate more naturally, but good long context quality is not guaranteed. Standard self attention also becomes more expensive as sequence length grows, and modeling very long range relationships can remain difficult.
Technical Approach
Tokenize the input while keeping the sequence order.
Create a content embedding for each token.
Supply position information. Absolute methods describe where a token appears. Relative methods describe the distance or offset between token positions.
Let self attention use the position aware information when computing relationships between tokens.
Produce contextual representations that reflect both token content and sequence order.
For long inputs, consider the position method, the sequence lengths used during training, and the cost of standard self attention.
Why Interviewers Ask This
Interviewers ask this to check whether you understand how a Transformer gets sequence order information. They want to see if you know why self attention needs position information, how absolute and relative position methods differ, and why the chosen method matters for long sequences. A strong answer also shows that you can separate token meaning from position information and explain how both affect attention.
Common interview mistakes
A common mistake is saying that every position method is simply added to token embeddings. That is true for some absolute methods, but relative methods can influence attention scores instead. Another mistake is saying that self attention already knows token order. Without position information, self attention does not assign sequence meaning to different orderings. It is also wrong to assume that a position method guarantees good performance on arbitrarily long inputs. Long context behavior depends on the position scheme, training, architecture, and attention cost.
Interview tip
Start with a small sentence such as "The cat sat" and explain that token meaning alone is not enough because order matters. Then explain absolute position as where a token is, relative position as the distance or offset between positions, and finish with the long sequence limitation.
Interviewer may ask next
What happens if a Transformer has no positional information?
Self attention does not assign sequence meaning to token order by itself. Without position information, self attention is permutation equivariant, so reordering the input reorders the corresponding outputs. Position information breaks this symmetry and lets the model use sequence order when building contextual representations.
Why can relative position methods be useful for long sequences?
Relative position methods represent distances or offsets between token positions instead of depending only on fixed absolute indexes. Some relative methods can therefore extrapolate more naturally beyond lengths seen during training. The tradeoff is that the mechanism can be more complex, and relative position information does not guarantee good long context quality. Training behavior, architecture, and attention cost still matter.
10. What are query, key, and value in attention?Llm FundamentalsEasy
i Question Details
Clarify Q, K, and V projections, attention-score formation, normalization, and weighted value aggregation.
Short Interview Answer (30-60 seconds)
Query, key, and value are three learned projections of the same token representations. The query represents what a token is looking for. Each key represents what a token can match against. Each value carries the information that can be collected. Attention compares queries with keys, scales the scores, applies softmax to get normalized weights, and uses those weights to combine the values into a new representation for each token.
Detailed Explanation
Attention helps each word choose which other words matter when building its new representation. Think about the sentence "I love NLP !" and focus on the word "love". The model creates three different views of every word. One view represents what the current word wants to find. Another represents what each word can match with. The third carries the information that can be gathered. The model compares the first two views, turns the results into importance weights, and mixes information from the third view using those weights.
Useful Questions to Ask the Interviewer
Should I explain one attention head or also discuss multiple heads?
Should I include the tensor shapes and the scaling term in the score calculation?
How to Explain It in an Interview
Start with input token representations X with shape (n, d_model), where n is the number of tokens and d_model is the embedding size. Attention applies three learned linear projections. These create Q, K, and V.
Q is the query matrix. A query represents what each token position is looking for. K is the key matrix. A key represents what each token position can match against. V is the value matrix. A value contains the information that can be passed into the output.
For one attention head, Q has shape (n, d_k), K has shape (n, d_k), and V has shape (n, d_v). Their learned projection matrices map the input representation into these dimensions.
The model compares every query with every key using dot products. It forms the score matrix as QK^T divided by the square root of d_k. Dividing by the square root of d_k keeps the dot product scale more controlled as the key dimension grows.
The score matrix has shape (n, n). Each row contains the scores from one query token to all key tokens. A row wise softmax converts each row into normalized attention weights. Every row sums to 1. A larger weight means the query gives more importance to that key position.
Finally, the attention weight matrix multiplies V. The result has shape (n, d_v). Each output token is therefore a weighted mixture of all value vectors.
For the "love" example, the query for "love" is compared with the keys for "I", "love", "NLP", and "!". Softmax turns those scores into weights. Those weights decide how much information to take from each value vector. The weighted sum becomes the new representation for "love".
The important limitation is that Q, K, and V do not have fixed human meanings. They are learned numerical representations. The phrases "what I am looking for", "what I can match against", and "what information I carry" are useful intuition, not literal stored questions or facts.
Technical Approach
Start with token representations X of shape (n, d_model).
Apply three learned linear projections to create Q, K, and V.
Compute the score matrix as QK^T divided by the square root of d_k.
Apply row wise softmax to convert each score row into normalized attention weights.
Multiply the attention weights by V.
Return one weighted mixture of value vectors for each token, with shape (n, d_v).
Practical Insights
For one attention head with n tokens, every query is compared with every key. This creates an (n, n) score matrix, so this part of the work grows roughly with n squared. The score matrix also uses memory that grows roughly with n squared. The exact computation also depends on the query, key, and value dimensions.
Why Interviewers Ask This
Interviewers ask this to check whether you understand the core calculation inside attention. They want to see if you can explain how the model decides which token positions are relevant, how it turns relevance scores into normalized weights, and how it uses those weights to combine information. A strong answer also shows that you understand tensor shapes and the difference between deciding what is relevant and deciding what information is collected.
Common interview mistakes
A common mistake is saying that query, key, and value are separate input tokens. They are learned projections of token representations. Another mistake is saying that attention directly mixes keys. Keys are used to compute relevance scores, while values provide the information that is mixed. It is also incorrect to skip softmax because the raw scores are not yet normalized attention weights. Another mistake is forgetting the division by the square root of d_k. Finally, the simple descriptions of Q, K, and V are intuition. The learned vectors do not literally contain natural language questions, labels, or facts.
Interview tip
Explain the flow in four steps: project X into Q, K, and V, compare Q with K, normalize the scores with softmax, then use those weights to combine V. Mention the tensor shapes if the interviewer wants more detail. A simple phrase helps: Q says what to look for, K says what can match, and V carries the information to collect.
Interviewer may ask next
What happens if one attention score is much larger than the others before softmax?
Softmax gives that position a much larger attention weight, so its value vector has more influence on the output for that query. This matters because attention can become strongly concentrated on a small number of positions. Dividing the scores by the square root of d_k helps control score scale as the key dimension grows, but it does not guarantee evenly distributed attention weights.
Why does attention become expensive when the sequence gets longer?
The costly part is comparing queries with keys. With n tokens, every query is compared with every key, producing an (n, n) score matrix. The comparison work and score matrix memory therefore grow roughly with n squared. This matters in production because longer sequences can require much more compute and memory even though the query, key, value, softmax, and weighted value flow stays the same.
More questions load as you scroll
AI Engineer Resume Examples
Explore the resume examples below to find the one that best matches your target AI Engineer role.
Disclaimer: This interview guide is for educational and informational purposes only. It is designed to help readers prepare, but it does not guarantee any interview result, hiring decision, offer, or outcome. Interview questions, hiring criteria, and preferred answers can vary by employer, interviewer, industry, location, and time. The examples and explanations reflect the authors' research and judgment, are provided without warranties of any kind, and should not be treated as the only correct approach. Diagrams are simplified illustrations intended to highlight the main components and their interactions; actual systems and implementations may be more complex. Alternative approaches may be equally valid or better suited to a particular question, context, or interviewer. To the fullest extent permitted by applicable law, the author, contributors, and publisher are not liable for decisions made, actions taken, or losses incurred based on this guide.