NLP interview questions and answers, classic and LLM
NLP interview questions now span two eras: classic text processing (tokenization, TF-IDF, n-grams, named entity recognition) and large language models (subword tokenizers, embeddings, pretraining, fine-tuning, retrieval-augmented generation and evaluation). Interviewers want to see that you can pick the simplest method that works, measure it with a metric that fits the task, and explain where a model will fail, including hallucination. Expect concept questions, a small coding task on text, and a design case such as a search or support assistant.
By Evin JohnPublished 8 min read
How NLP shows up in interviews today
NLP questions appear in loops for NLP engineers, ML engineers, applied scientists, search and ranking teams, and AI engineers who build on large language models. Older topics have not disappeared: a team classifying support tickets may still get the best value from TF-IDF and logistic regression, and interviewers like candidates who know that. The neural details behind transformers, such as how attention is computed, are covered in deep learning interview questions; this page stays with language-specific topics.
- Concept roundTokenization, embeddings, language model objectives and metrics, often mixed with classical ML questions.
- Coding on textBuild a TF-IDF classifier, compute a metric, write a tokenizer step, or call an embedding model and rank results.
- Design case"Build a support assistant over our help docs" or "detect toxic comments": data, model choice, evaluation and failure handling.
- Research or paper discussionFor research-leaning roles, walk through a paper you know well and its weaknesses.
Classic NLP questions
| Question | What it tests | What a strong answer shows |
|---|---|---|
| What is tokenization and why is it harder than splitting on spaces? | Text processing | Turning text into units a model uses. Punctuation, contractions, URLs, emoji and languages without spaces such as Chinese or Japanese all break naive splitting. |
| Stemming versus lemmatization? | Normalization | Stemming chops suffixes by rules and can produce non-words. Lemmatization maps a word to its dictionary form using vocabulary and part of speech. Both matter less for neural models that use subwords. |
| Should you always remove stop words? | Judgement | No. They add little to keyword search and topic models, but words like "not" and "no" carry meaning for sentiment, and neural models use them as context. |
| What is a bag-of-words model and what does it lose? | Representation | A vector of word counts per document. It is simple and strong for many classification tasks, but discards order, so "dog bites man" and "man bites dog" look the same. |
| Explain TF-IDF. | Weighting | Term frequency in the document times inverse document frequency across the corpus, so words common everywhere get low weight and distinctive words get high weight. |
| What do n-grams add? | Local order | Pairs or triples of adjacent words capture short phrases such as "not good" or "New York", at the cost of a much larger, sparser vocabulary. |
| What is named entity recognition and how is it framed? | Sequence labeling | Finding spans such as people, organizations and dates. It is usually framed as tagging each token with a BIO scheme (begin, inside, outside) and evaluated on exact span matches. |
| How would you build a sentiment classifier quickly? | Baselines | TF-IDF with word and character n-grams plus logistic regression as a baseline, then a fine-tuned pretrained encoder if the baseline falls short. Compare both on the same held-out set. |
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import cosine_similarity
docs = [
"How do I reset my password?",
"Refunds are issued to the original payment method.",
"Change the email address on your account in settings.",
]
query = ["I forgot my password and cannot log in"]
vec = TfidfVectorizer(stop_words="english") # fit on the documents only
doc_matrix = vec.fit_transform(docs)
query_vec = vec.transform(query) # same vocabulary and IDF weights
sims = cosine_similarity(query_vec, doc_matrix)[0]
best = sims.argmax()
print(best, docs[best]) # 0 How do I reset my password?
# Note: "forgot" and "log" are not in the fitted vocabulary, so they add nothing.
# Lexical matching misses synonyms; embeddings capture them, which is why
# many search systems combine both.Tokenizers and embeddings
- Why do modern models use subword tokenization? A word vocabulary cannot cover rare words, typos and new names, and a character vocabulary makes sequences long. Subwords such as BPE, WordPiece or unigram pieces keep common words whole and split rare ones into known parts.
- How does byte-pair encoding build its vocabulary? Start from characters or bytes, count adjacent pairs across the corpus, merge the most frequent pair into a new symbol, and repeat until the vocabulary reaches the target size. Encoding new text replays the learned merges in order.
- What is the trade-off in vocabulary size? Larger vocabularies give shorter sequences but a bigger embedding table and rarer tokens with less training signal. Smaller ones give longer sequences and more compute per sentence.
- Why can the same sentence cost more tokens in some languages? Tokenizers trained mostly on English text split other languages, and especially other scripts, into more pieces. That raises cost and uses up the context window faster.
- Static versus contextual embeddings? Word2vec and GloVe give each word one vector, so "bank" means the same in every sentence. Contextual models produce a different vector for each occurrence based on its surroundings.
- How does word2vec learn vectors? By predicting a word from its neighbors (CBOW) or neighbors from a word (skip-gram), typically with negative sampling. Words used in similar contexts end up close together.
- How do you get one embedding for a whole sentence? Use a model trained for sentence similarity, often with mean pooling over token vectors and a contrastive objective. Averaging raw word vectors works as a weak baseline.
from collections import Counter
# Words as symbol tuples, mapped to their counts in the corpus
corpus = {("l", "o", "w"): 5, ("l", "o", "w", "e", "r"): 2, ("n", "e", "w", "e", "s", "t"): 6, ("w", "i", "d", "e", "s", "t"): 3}
def most_frequent_pair(corpus):
pairs = Counter()
for word, freq in corpus.items():
for a, b in zip(word, word[1:]):
pairs[(a, b)] += freq
return pairs.most_common(1)[0]
def merge(corpus, pair):
merged = {}
for word, freq in corpus.items():
out, i = [], 0
while i < len(word):
if i + 1 < len(word) and (word[i], word[i + 1]) == pair:
out.append(word[i] + word[i + 1])
i += 2
else:
out.append(word[i])
i += 1
merged[tuple(out)] = freq
return merged
pair, count = most_frequent_pair(corpus)
print(pair, count) # ('e', 's') 9, tied with ('s', 't')
corpus = merge(corpus, pair)
print(list(corpus)[2]) # ('n', 'e', 'w', 'es', 't')Language model and LLM questions
| Question | What it tests | What a strong answer shows |
|---|---|---|
| What is a language model and what is perplexity? | Foundations | A model of the probability of the next token given the previous ones. Perplexity is the exponential of the average negative log-likelihood on held-out text; lower is better, and it is only comparable between models with the same tokenizer. |
| Masked versus causal language modeling? | Pretraining | Masked models such as BERT predict hidden tokens using context on both sides, which suits understanding tasks and embeddings. Causal models predict the next token from the left only, which suits generation. |
| What happens after pretraining to make a chat model? | Post-training | Supervised fine-tuning on instruction and response examples, then preference tuning with methods such as RLHF or DPO so outputs follow instructions and match what reviewers prefer. |
| Full fine-tuning versus LoRA? | Adaptation | Full fine-tuning updates every weight and needs memory for all of them and their optimizer state. LoRA freezes the base model and trains small low-rank matrices added to some layers, which is far cheaper and easy to swap per task. |
| Prompting, RAG or fine-tuning: how do you choose? | Design judgement | Prompting first. Add retrieval when the model needs facts it does not have or that change often. Fine-tune when you need a consistent format, style or skill that prompts cannot reliably produce. They combine well. |
| What do temperature and top-p do? | Decoding | Temperature rescales logits before softmax: low values sharpen toward the top token, high values flatten. Top-p samples only from the smallest set of tokens whose probability adds up to p. Greedy decoding always takes the top token. |
| What is a context window and what happens when input exceeds it? | Limits | The maximum number of tokens the model attends to at once. Longer input must be truncated, summarized or retrieved selectively, and models can also use information in the middle of long contexts less reliably. |
| Why do LLMs hallucinate? | Failure modes | They are trained to produce plausible continuations, not verified facts, so they can generate confident text without support, especially for rare facts or questions outside their training data. |
RAG and applied NLP questions
- Walk through a retrieval-augmented generation pipeline. Split documents into chunks, embed them into an index, embed the query, retrieve the top matches (often hybrid keyword plus vector), optionally rerank, then put the best passages in the prompt with instructions to answer from them and cite them.
- How do you choose chunk size? Small chunks retrieve precisely but lose context; large ones keep context but dilute similarity and use the context window. Split on document structure such as headings, add a little overlap, and tune on real questions.
- Retrieval looks fine but answers are wrong. Where do you look? Measure the two halves separately: is the right passage in the top results (recall at k), and given the right passage, does the model answer from it? Fix whichever half fails.
- How do you reduce hallucination? Ground answers in retrieved sources, instruct the model to say when the sources do not contain the answer, ask for citations and check them, lower temperature for factual tasks, and evaluate on questions whose answers you know.
- What is prompt injection and why does it matter for RAG? Text inside retrieved documents or user input that tries to override your instructions. Treat retrieved content as data, limit what tools the model can call, and validate outputs before acting on them.
- How would you classify thousands of support tickets with an LLM? Start with a labeled sample, compare a zero-shot prompt, a few-shot prompt and a small fine-tuned classifier on cost, latency and accuracy, and route uncertain cases to people.
NLP evaluation questions
| Question | What it tests | What a strong answer shows |
|---|---|---|
| How do you evaluate NER? | Extraction metrics | Precision, recall and F1 on entity spans, usually requiring the exact boundaries and type to match, reported per entity type as well as overall. |
| What does BLEU measure and what are its limits? | Generation metrics | N-gram precision against one or more reference translations, with a brevity penalty. It rewards surface overlap, so a correct paraphrase can score low, and it says little about a single sentence. |
| What is ROUGE and where does it fall short? | Summarization | N-gram and longest-common-subsequence overlap with reference summaries, recall-oriented. A summary can score well while containing a factual error, or poorly while being accurate and well phrased. |
| How do you evaluate an LLM feature without reference answers? | Modern evaluation | A fixed test set of real inputs, rubric-based human review, model-based grading checked against human labels, and task metrics such as whether the cited passage supports the answer. |
| What are the risks of using an LLM as a judge? | Evaluation bias | Judges can prefer longer answers, answers in a certain position or their own model family's style. Calibrate them on a human-labeled sample and keep a human spot check. |
| How do you compare two prompts or models fairly? | Experimentation | Same test set, blind side-by-side review, enough examples to see a real difference, and a look at the failures rather than only the average. |
Fictional example
- Interviewer
- Our help-center chatbot uses retrieval over articles, and users report confident wrong answers. How do you approach it?
- Candidate
- First I would collect the reported failures and a sample of normal traffic into a test set with correct answers and the article each should come from. Then I would split the problem. For retrieval I would measure whether the right article appears in the top five results. If it often does not, I would look at chunking, add keyword search next to vector search for product names and error codes, and try a reranker. For generation, given the right passage, I would check whether the answer stays within it. If not, I would tighten the instructions so the assistant says when the articles do not cover a question and links the source it used. I would rerun the same test set after each change, and route low-confidence questions to a human agent.
A two-week NLP practice plan
- Days 1 to 3: build a TF-IDF and logistic regression classifier on a public text dataset, then read through fifty mistakes and group them.
- Days 4 and 5: implement BPE training on a small corpus and tokenize a few sentences with a real tokenizer to compare token counts across languages.
- Days 6 to 8: fine-tune a small pretrained encoder on the same dataset and compare it with your baseline on the same split.
- Days 9 to 11: build a small RAG prototype over a few documents, write twenty test questions and measure retrieval and answer quality separately.
- Days 12 to 14: practice spoken answers on perplexity, BLEU and ROUGE limits, LoRA and hallucination, then one full design case out loud.
Next steps: machine learning interview questions for metrics and validation, and AI engineer interview questions for building products on large language models.
NLP design cases reward a clear order: test set first, then retrieval, then generation. Natively, an AI interview assistant for Mac and Windows, transcribes mock design and concept rounds on your computer, so you can check afterwards whether you skipped the evaluation step. In practice it can draft answer suggestions, read a code task or an error from a screenshot, and, with Pro or the free trial, draw on the résumé and job description you add. You keep the transcript and notes to study.
Questions people ask
What NLP questions are asked in interviews?
Tokenization and subword vocabularies, stemming versus lemmatization, bag of words and TF-IDF, word embeddings, NER, language model objectives, fine-tuning and LoRA, retrieval-augmented generation, decoding settings, evaluation metrics such as BLEU and ROUGE, and hallucination.
Are classic NLP methods still asked about now that LLMs exist?
Yes. TF-IDF, n-grams and NER still come up, both as fundamentals and because a simple baseline is often the right answer for classification or keyword search.
What are the limits of BLEU and ROUGE?
Both measure word overlap with reference texts, so they penalize correct paraphrases and can reward fluent outputs that contain factual errors. Pair them with human review or task-specific checks.
What LLM questions come up in NLP interviews?
Masked versus causal pretraining, instruction tuning and preference tuning, LoRA, prompting versus RAG versus fine-tuning, temperature and top-p, context windows, hallucination and how to evaluate an LLM feature.
Where to go next
Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.
Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.
