Skip to content

NLP Engineer interview questions

100 real questions with model answers and explanations for NLP Engineer II candidates.

See a NLP Engineer resume example

Practice with flashcards

Spaced repetition · Hunter Pass

Questions

queries

The scaling keeps attention logits in a range where softmax still has useful gradients as the key dimension grows.

  • Unscaled dot products have variance proportional to the key dimension, so large dimensions produce extreme logits.
  • Extreme logits make softmax nearly one-hot, causing most derivatives to approach zero.
  • Dividing by the square root of the key dimension normalizes the variance without changing the learned ranking of keys.

Why interviewers ask this: The interviewer is checking whether the candidate can connect the attention formula to numerical stability and optimization behavior.

distinct

Multiple heads let the model represent different token relationships in parallel rather than forcing one attention map to carry every pattern.

  • One head may emphasize local syntactic links such as adjective-to-noun agreement while another follows long-range coreference.
  • Separate learned query, key, and value projections give each head its own lower-dimensional representation subspace.
  • Head roles are not guaranteed or perfectly interpretable, and redundant heads can often be pruned with little quality loss.

Why interviewers ask this: A strong answer distinguishes representational capacity from unsupported claims that every head has a fixed linguistic meaning.

nlpbert

I would benchmark task-appropriate checkpoints because RoBERTa and DeBERTa often improve quality over BERT but can cost more memory or latency.

  • BERT is a stable baseline with broad checkpoint and tooling support, especially when compatibility matters.
  • RoBERTa changed pretraining through more data, dynamic masking, and removal of next-sentence prediction, usually yielding stronger representations at comparable size.
  • DeBERTa separates content and position attention and often scores higher, but its implementation and serving profile must fit the production stack.
  • I compare validation quality, p95 latency, memory, tokenizer coverage, and domain-specific checkpoint availability rather than choosing from benchmark rank alone.

Why interviewers ask this: The interviewer wants a practical model-family comparison grounded in both pretraining differences and deployment constraints.

An encoder-decoder model is the natural choice when the output is a new variable-length sequence, while an encoder-only model is simpler for labels, spans, or embeddings.

  • Translation and abstractive summarization require autoregressive decoding conditioned on an encoded source, which models such as T5 or BART provide.
  • Classification and token labeling usually need only an encoder plus a small task head, avoiding decoder latency and exposure to generation errors.
  • Extractive summarization can also remain encoder-only because it selects source sentences instead of generating text.

Why interviewers ask this: The question tests whether the candidate matches model architecture to output structure rather than treating all NLP tasks as generation.

nlptokenscrf

A linear-chain CRF scores the whole label sequence and learns transition scores between adjacent tags instead of predicting each token independently.

  • An ordinary CRF with Viterbi does not guarantee valid BIO output; I add a transition mask or set illegal transition scores to negative infinity before decoding.
  • The gain is most useful when label transitions are strong and training data is limited; large encoders may already learn much of this structure.
  • A CRF adds training and decoding complexity and does not solve nested or discontinuous entities because it still emits one linear tag per token.

Why interviewers ask this: The interviewer is evaluating whether the candidate understands both the sequence-level benefit and structural limits of a CRF.

classificationtokensner

Token classification assigns BIO-style labels to tokens, while a span model scores candidate start-end ranges and their entity types.

  • Token labeling is computationally efficient and works well for flat entities, but subword alignment and invalid tag transitions need care.
  • Span scoring represents entity boundaries directly and can classify overlapping candidates, which makes nested NER more natural.
  • Enumerating all spans is quadratic in sequence length, so practical systems cap span width or prune candidates.
  • I choose using the annotation structure and latency budget, then evaluate exact entity spans rather than token accuracy.

Why interviewers ask this: A strong answer links the output representation to overlap support, computational cost, and evaluation.

bio-tags

A single BIO label per token cannot represent overlapping entity layers or one entity split across nonadjacent text segments.

  • Nested entities, such as New York inside New York University, need span classification, layered taggers, or hypergraph-style decoding.
  • Discontinuous mentions, common in clinical text, need models that link multiple spans or predict mention fragments and their relations.
  • The annotation schema must define whether inner entities and split mentions are required, because architecture and scoring follow that decision.

Why interviewers ask this: The interviewer is checking whether the candidate recognizes a representation limitation rather than blaming these cases on model capacity.

The encoder produces a score for every token as a possible start and another as a possible end, then selects a valid high-scoring pair.

  • Training commonly applies cross-entropy to the gold start and end positions using contextual token representations.
  • Inference considers pairs where end is not before start and often enforces a maximum answer length.
  • Independent start and end heads are efficient but can favor incompatible boundaries, so joint span scoring or reranking can improve difficult cases.

Why interviewers ask this: The question tests whether the candidate can explain the concrete prediction and decoding mechanics of extractive QA.

system-design

The model needs an explicit no-answer score that is compared with the best candidate span using a tuned threshold.

  • BERT-style systems often use the classification token as the null span and compare its score with the best non-null start-end score.
  • I tune the score difference threshold on a validation set to balance unanswered-question recall against false answers.
  • Evaluation must include answerable and unanswerable slices because aggregate exact match can hide a model that refuses too often.
  • Calibration and passage retrieval coverage should be checked separately before changing the threshold.

Why interviewers ask this: The interviewer wants to see that abstention is treated as a scored decision with explicit validation rather than a heuristic afterthought.

design

I would preserve the taxonomy structure in prediction and loss so that a child label cannot be emitted without a compatible parent.

  • A top-down cascade narrows candidates at each level and is interpretable, but an early parent error blocks every descendant.
  • A single model with hierarchical constraints can share evidence across levels and enforce valid paths during decoding.
  • I report metrics at each depth plus path accuracy because a correct parent and wrong leaf is different from a completely wrong branch.

Why interviewers ask this: The interviewer is assessing whether the candidate can exploit label structure and evaluate errors at the right granularity.

classification

Multilabel classification predicts each label independently or with modeled dependencies because several labels may be correct for one document.

  • The output normally uses one sigmoid per label with binary cross-entropy, not a softmax that forces probabilities to sum to one.
  • Thresholds should be tuned globally or per label because rare labels often need a different operating point.
  • Micro F1 emphasizes common labels, while macro F1 exposes weak performance on rare labels.
  • If labels co-occur systematically, classifier chains or a shared representation with dependency modeling can capture that signal.

Why interviewers ask this: A strong answer covers the changed output layer, decision rule, and metrics rather than merely defining multilabel data.

context

I would split the document into meaningful chunks, encode them, and aggregate chunk evidence while preserving enough document structure for the label.

  • For sparse evidence, max pooling or top-k attention over chunk logits can surface one decisive paragraph.
  • For distributed evidence, a second-level transformer or recurrent aggregator can model the ordered chunk representations.
  • Training should sample complete documents, not treat chunks as independently labeled examples when the label only applies globally.
  • I validate chunk size, overlap, and truncation on long-document slices because random short examples hide coverage failures.

Why interviewers ask this: The interviewer is testing whether the candidate can avoid naive truncation and choose aggregation that matches how evidence appears.

chunkinglong-context

I would use a sparse-attention encoder when decisions depend on interactions across distant sections that chunk aggregation loses.

  • Sliding-window attention reduces quadratic cost for local context, while selected global tokens connect document-wide information.
  • Longer input still raises memory and latency, and pretrained checkpoints may be weaker or less domain-specific than standard encoders.
  • Chunking remains simpler for independently informative sections and supports selective processing of only relevant parts.
  • I compare quality on cross-section examples and p95 serving cost rather than assuming a larger context is automatically better.

Why interviewers ask this: The question evaluates whether the candidate understands the quality and systems trade-offs behind long-document architectures.

nlpembeddingstokens

I use a pooling strategy that was aligned with the model's training objective rather than assuming the first token is always a semantic sentence vector.

  • Mean pooling over non-padding tokens is a strong baseline for sentence-transformer models and uses information from the whole sequence.
  • First-token pooling can work when the checkpoint was explicitly trained around that representation, but vanilla masked-language pretraining does not guarantee it.
  • I usually L2-normalize vectors for cosine search and verify performance on domain pairs, including short and long sentence slices.

Why interviewers ask this: The interviewer is checking whether the candidate understands that pooling and training objective jointly determine embedding quality.

retrievalbi-encodercross-encoder

I use a bi-encoder to retrieve or compare many candidates cheaply and a cross-encoder when a smaller candidate set needs more accurate pairwise scoring.

  • A bi-encoder computes reusable vectors independently, so millions of documents or deduplication candidates can be indexed and searched efficiently.
  • A cross-encoder jointly attends to both texts and captures fine token interactions, but it must run once per pair.
  • A practical search stack retrieves top candidates with a bi-encoder and reranks perhaps 20 to 100 with a cross-encoder.
  • For offline deduplication, blocking rules or approximate search first prevent quadratic all-pairs cross-encoding.

Why interviewers ask this: A strong answer confines the comparison to discriminative matching and quantifies the computational reason for a two-stage design.

retrievalbm25dense-retrieval

BM25 rewards lexical term overlap, while dense retrieval matches learned semantic representations, so each fails on different query types.

  • BM25 is strong for exact product codes, rare names, and newly indexed terms without model retraining.
  • Dense retrieval handles paraphrases such as waterproof hiking shoes versus rain-resistant trail footwear, but can miss exact identifiers.
  • BM25 scores depend on term frequency, inverse document frequency, and length normalization; dense quality depends on training pairs and domain coverage.
  • I evaluate them by query slice and often fuse ranked results when both semantic and exact-match intent matter.

Why interviewers ask this: The interviewer is looking for search-specific strengths and failure modes rather than a generic sparse-versus-vector definition.

nlpembeddingsbatch

Contrastive training pulls matched text pairs together and pushes mismatched pairs apart in embedding space using a similarity-based objective.

  • With a multiple-negatives ranking loss, the other targets in the batch act as negatives for each query, providing many comparisons without extra encoding.
  • Larger batches usually strengthen the signal, but false negatives arise when another batch item is actually relevant or equivalent.
  • Temperature controls how sharply the loss emphasizes close competitors and must be tuned with embedding normalization.
  • Batch construction should avoid grouping duplicate positives as negatives and should reflect the production matching task.

Why interviewers ask this: The question tests whether the candidate understands the mechanics and data assumptions behind efficient embedding training.

retrieval

A useful hard negative looks plausible to the current retriever but is truly irrelevant under the task's labeling policy.

  • BM25 or an earlier dense model can mine top-ranked nonpositive results that share vocabulary or topic with the query.
  • Random negatives are often too easy and teach little once the model separates unrelated documents.
  • Unverified top results can be false negatives, so I filter known positives and manually audit or cross-encode a sample.
  • I refresh mined negatives during training because examples that were hard for the initial model may stop being informative.

Why interviewers ask this: A strong answer shows how to increase training difficulty without corrupting the objective with mislabeled relevant pairs.

Domain-adaptive pretraining continues the encoder's original self-supervised objective on unlabeled in-domain text before supervised fine-tuning.

  • Masked-language modeling on clinical notes or legal filings teaches domain terminology and usage without requiring task labels.
  • It is most useful when the target corpus differs substantially from general pretraining data and labeled examples are limited.
  • I hold out downstream validation data, mix some general text if forgetting appears, and compare against simply adding more labeled examples.
  • The tokenizer remains a constraint, so severe fragmentation of domain terms may justify vocabulary adaptation with careful embedding initialization.

Why interviewers ask this: The interviewer is checking whether the candidate can place continued encoder pretraining in a cost-effective adaptation workflow.

fine-tuning

Layer-wise decay gives lower encoder layers smaller updates and upper layers plus the task head progressively larger ones.

  • For example, I might start the head at 2e-5 and multiply the rate by 0.8 for each layer toward the embeddings, so general lexical features move less than task-specific features.
  • It often helps with a small labeled dataset or a task close to pretraining, where large updates to lower layers can erase useful representations.
  • It can hurt under a strong domain shift if the lower layers also need to adapt, so I compare it with one uniform learning rate rather than assuming decay always wins.
  • I tune the head rate and decay factor together, then choose them on held-out task quality and training stability across more than one seed.

Why interviewers ask this: The interviewer is checking whether the candidate understands the update hierarchy, its preservation-versus-adaptation trade-off, and how to validate it.

Locked questions

  • 21

    When does freezing encoder layers help during task fine-tuning?

    fine-tuning
  • 22

    When can multi-task learning improve an NLP encoder, and how can it hurt?

    nlp
  • 23

    How would you distill a large text classifier into a smaller encoder?

  • 24

    What are the main trade-offs when pruning an encoder model?

    model-compression
  • 25

    How does INT8 quantization affect encoder inference?

    inferencemodel-compression
  • 26

    How would you choose between ONNX Runtime and TensorRT for serving an encoder?

    model-servingserving-runtimes
  • 27

    How does dynamic batching improve encoder serving, and what latency cost does it introduce?

    batchmodel-servinglatency
  • 28

    How would you calibrate the confidence scores of a text classifier?

    calibration
  • 29

    How would you set decision thresholds for a multilabel classifier?

    thresholding
  • 30

    When would you use focal loss instead of resampling for an imbalanced text classification task?

    classificationimbalanced
  • 31

    How can weak or distant supervision produce training labels for an NLP task?

    nlp
  • 32

    How would you design an active learning loop for text annotation?

    design
  • 33

    When should you use Cohen's kappa versus Krippendorff's alpha for annotation agreement?

  • 34

    How should annotation disagreements be adjudicated without hiding guideline problems?

    conflict
  • 35

    How would you evolve a production label taxonomy without invalidating old training data and metrics?

    monitoring
  • 36

    How would you choose between mBERT and XLM-R for a multilingual encoder task?

  • 37

    How would you perform zero-shot cross-lingual transfer for intent classification?

    classification
  • 38

    What is tokenizer fertility, and why does it matter in multilingual NLP?

    nlptokenstokenizer-fertility
  • 39

    How would you handle transliteration and code-switching in a multilingual text classifier?

    code-switching
  • 40

    Which augmentation methods are useful for a low-resource NLP task, and how do you control label noise?

    nlp
  • 41

    What do BLEU and ROUGE measure, and what important quality can they miss?

    bleurouge
  • 42

    How does BERTScore differ from lexical overlap metrics for translation or summarization?

    monitoring
  • 43

    How would you score NER when exact entity boundaries are not the only useful outcome?

  • 44

    How would you use bootstrap testing to decide whether one NLP model is significantly better than another?

    nlptesting
  • 45

    How would you design robustness, slice, and fairness evaluation for a text classifier?

    llm-evaldesign
  • 46

    What data and model lineage would you record with MLflow or Weights & Biases for an NLP experiment?

    nlplineageexperiments
  • 47

    What should a model and data contract contain for a production NLP classifier?

    nlpdata-contracts
  • 48

    How would you build a reproducible Spark and Airflow preprocessing pipeline for a large text corpus?

    airflowci-cdspark
  • 49

    How would you design a Kafka pipeline for streaming NLP classification?

    kafkadesignstreaming
  • 50

    How would you design an Elasticsearch index for lexical text search used by an NLP product?

    indexessearchdesign
  • 51

    A NER model reaches 97% token accuracy but only 71% entity-level F1. How would you diagnose the gap?

    tokens
  • 52

    Your BIO tagger emits sequences such as I-ORG after O and I-PER after B-ORG. How would you fix the invalid output?

    bio-tags
  • 53

    Legal contracts contain nested entities such as a company inside a defined party name, but your BIO model can return only one label per token. What would you design?

    tokensdesignbio-tags
  • 54

    Two annotators achieve Cohen's kappa of 0.48 on support-ticket intents. What would you do before training the classifier?

  • 55

    An active-learning loop selects only short, ambiguous complaints, and performance on long routine tickets declines. How would you correct the sampling bias?

    samplingperformance
  • 56

    Heuristic weak labels doubled your training set, but validation precision fell sharply. How would you find and reduce the label noise?

    train-testvalidationweak-supervision
  • 57

    Two support intents have Cohen's kappa of 0.38 and are each other's most common confusion, but product says they trigger different workflows. How would you decide whether to merge, redefine, or collect more data?

  • 58

    A support classifier confidently maps requests about a newly launched subscription-pause feature to billing or cancellation, although this intent is outside its taxonomy. How would you add safe abstention?

    resilience
  • 59

    A multilabel support classifier sometimes predicts both refund-approved and refund-denied, or emits card-chargeback without its payments parent. How would you enforce taxonomy coherence?

  • 60

    Overall accuracy is 94%, but recall for a minority fraud-text class is 38%. What would you change?

  • 61

    A ticket classifier scores 98% offline but fails when email signatures and routing headers are removed. How would you address the shortcut?

  • 62

    Validation F1 is 96%, but manual review finds nearly identical documents in train and validation. How would you repair the leakage?

    leakagevalidation
  • 63

    A news classifier is evaluated with a random split, but production always predicts articles published later. How would you redesign evaluation?

    llm-evaldecision-making
  • 64

    A classifier trained on chat messages loses 15 F1 points when deployed to transcribed phone calls. How would you handle the domain drift?

    deploymentiac
  • 65

    A BERT document classifier misses cancellation clauses that usually appear near the end of 2,000-token contracts. What would you change?

    tokensbertresilience
  • 66

    Overlapping windows improve long-document recall, but one positive window makes too many whole documents positive. How would you aggregate window scores?

    aggregation
  • 67

    An extractive QA model selects the right words, but returned character offsets highlight the wrong substring in the original document. How would you debug it?

  • 68

    An extractive QA system answers unanswerable questions with plausible spans. How would you tune no-answer behavior?

    system-design
  • 69

    Product search finds paraphrases with dense embeddings but misses exact part numbers, while BM25 finds part numbers but weakly handles intent. How would you design search?

    nlpembeddingsbm25
  • 70

    A semantic search bi-encoder has acceptable latency but weak top-10 recall; reranking every document with a cross-encoder exceeds the 200 ms budget. What would you do?

    retrievalrerankingbi-encoder
  • 71

    Hard-negative mining improves training loss, but search quality falls because many mined negatives are actually relevant. How would you fix the process?

    concurrency
  • 72

    A sentence encoder gives cosine similarities above 0.95 for almost every sentence pair. How would you investigate embedding collapse?

    nlpembeddings
  • 73

    Fine-tuning XLM-R raises English intent F1 by 6 points but lowers Spanish and Polish F1 by 9 points. How would you restore multilingual quality?

    fine-tuning
  • 74

    The tokenizer averages 1.3 subwords per English word but 4.8 for Turkish, and Turkish inference is slower and less accurate. What would you do?

    inferencetokens
  • 75

    A sentiment model works on monolingual messages but fails on Spanish-English code-switched chats. How would you improve it?

  • 76

    You have only 300 labeled examples for a new intent in a low-resource language. How would you build a credible classifier?

  • 77

    Domain-adaptive pretraining on medical notes improves coding accuracy but degrades performance on general patient messages. How would you adjust it?

    performance
  • 78

    After sequentially fine-tuning one encoder on five intent datasets, the newest task improves while the first task loses 20 F1 points. How would you reduce catastrophic forgetting?

    fine-tuning
  • 79

    Fine-tuning the same BERT classifier with five random seeds produces macro F1 from 72% to 84%. How would you stabilize training?

    fine-tuningbert
  • 80

    Freezing the bottom nine transformer layers cuts training cost, but the domain classifier underfits specialized terminology. What would you try?

    nlp
  • 81

    A distilled text classifier is twice as fast but loses most recall on rare intents. How would you change the distillation objective?

    model-compression
  • 82

    INT8 quantization reduces latency by 35%, but F1 drops only for Arabic and Thai. How would you investigate and mitigate it?

    latencymodel-compression
  • 83

    A classifier exported to ONNX returns different probabilities from PyTorch for padded batches. How would you debug the mismatch?

    batchserving-runtimespytorch
  • 84

    Dynamic batching doubles throughput, but p99 latency rises from 180 ms to 900 ms during uneven traffic. How would you tune it?

    latencythroughputbatch
  • 85

    You must serve a 120 ms text classifier on Kubernetes, and both CPU and GPU nodes are available. How would you choose and deploy the serving target?

    kubernetesdeploymentmodel-serving
  • 86

    A classification API receives many equivalent inputs with different casing and whitespace. How would you add Redis caching without returning incorrect labels?

    cachingapiredis
  • 87

    A Kafka-based NLP pipeline occasionally classifies the same event twice and sometimes processes updates out of order. How would you make outputs correct?

    nlpkafkaconcurrency
  • 88

    A Spark preprocessing job is slow because a few very long documents create straggler partitions. How would you remove the skew?

    partitioningspark
  • 89

    A new tokenizer requires an Airflow backfill of two years of documents without delaying the daily preprocessing run. How would you design it?

    designbackfilltokens
  • 90

    An MLflow run shows the expected metrics, but deployment loads a tokenizer from another experiment. How would you prevent wrong-artifact releases?

    deploymentmonitoringartifacts
  • 91

    A preprocessing team changes token IDs from int64 to int32 and renames attention_mask, breaking the model service. How would you enforce the model-data contract?

    tokensdata-contracts
  • 92

    The share of neutral sentiment labels rises from 40% to 75% over a month, but input text statistics look stable. How would you investigate label drift?

    iac
  • 93

    Model accuracy falls while label proportions remain stable, and average message length and emoji frequency have doubled. How would you handle feature drift?

    iac
  • 94

    A translation model has acceptable corpus BLEU, but audits find poor accuracy on rare medical terminology. How would you evaluate and gate the next release?

    llm-evaldecision-makingbleu
  • 95

    A summarizer's ROUGE score rises after it starts copying long source passages, but users prefer the previous summaries. What would you change?

    rouge
  • 96

    An entity-resolution system merges different people who share a surname and employer. How would you reduce false matches?

    system-design
  • 97

    You must train a support classifier from messages containing names, phone numbers, and account IDs. How would you handle PII in preprocessing?

    pii
  • 98

    Aggregate intent F1 is unchanged after a release, but complaints rise among users writing short German messages. How would you use error slices?

    aggregation
  • 99

    Offline metrics favor a new ticket classifier. How would you run an A/B test to decide whether it improves the product?

    ab-testingmonitoring
  • 100

    Design a document-triage endpoint that must extract organizations, classify document type, and rank urgency within 250 ms. How would you structure it?

    designendpoints