InterviewTreedInterviewTreed

InterviewTreed Question Bank

Natural Language Processing (NLP) Interview Questions and Answers

Explore natural language processing, text preprocessing, tokenization, embeddings, text classification, named entity recognition, language models, and modern NLP architectures.

Total Questions

50

Beginner

18

Intermediate

18

Advanced

14

Beginner Questions

Foundational concepts, terminology, and core ideas.

Q1Introduction to NLP

What is natural language processing (NLP)?

What is natural language processing (NLP). Explain the core idea, use cases, and trade-offs.

Answer

NLP is a field of AI focused on enabling computers to process, analyze, and generate human language. Tasks include classification, information extraction, translation, search, summarization, and question answering.

Key Points

  • NLP includes language understanding and generation
  • the best approach depends on the task and data
Q2NLP challenges

What are the main challenges in NLP?

What are the main challenges in NLP. Explain the core idea, use cases, and trade-offs.

Answer

Human language is ambiguous, context-dependent, variable across dialects, and often contains spelling errors, idioms, sarcasm, or domain-specific terms. Models must also handle limited data and changing language use.

Key Points

  • Ambiguity, context, variation, and data quality are core challenges
Q3Text preprocessing

What is tokenization?

What is tokenization. Explain the core idea, use cases, and trade-offs.

Answer

Tokenization splits text into units such as words, subwords, or characters. The chosen strategy affects vocabulary size, sequence length, handling of rare words, and downstream model behavior.

Key Points

  • Word tokenization is intuitive
  • subword tokenization handles rare words more flexibly
Q4Text preprocessing

What is the difference between stemming and lemmatization?

What is the difference between stemming and lemmatization. Explain the core idea, use cases, and trade-offs.

Answer

Stemming heuristically removes word endings and may produce non-dictionary forms. Lemmatization uses linguistic information to map a word to its base form, often considering part of speech.

Key Points

  • Stemming is usually simpler and faster
  • lemmatization is more linguistically informed
Q5Text preprocessing

What are stop words, and should they always be removed?

What are stop words, and should they always be removed. Explain the core idea, use cases, and trade-offs.

Answer

Stop words are frequent words such as 'the' or 'and' that some pipelines remove. They should not be removed automatically because they can carry meaning, especially in sentiment, question answering, and modern contextual models.

Key Points

  • Preprocessing choices depend on the task
  • evaluate before removing words
Q6Text preprocessing

What is text normalization?

What is text normalization. Explain the core idea, use cases, and trade-offs.

Answer

Text normalization converts text into a more consistent form, for example standardizing case, whitespace, Unicode, or selected spelling variants. Aggressive normalization can destroy useful signals such as capitalization or punctuation.

Key Points

  • Normalize only what is appropriate for the task and language
Q7Text representation

What is a bag-of-words representation?

What is a bag-of-words representation. Explain the core idea, use cases, and trade-offs.

Answer

Bag of words represents a document by token counts or presence, ignoring word order. It is simple and useful for baselines, but cannot directly capture sequence or contextual meaning.

Key Points

  • Simple and interpretable, but order and context are lost
Q8Text representation

What is TF-IDF?

What is TF-IDF. Explain the core idea, use cases, and trade-offs.

Answer

TF-IDF weights a term using its frequency in a document and how uncommon it is across a document collection. It often downweights words that appear in nearly every document.

Syntax

tfidf(term, document) = tf(term, document) * idf(term)

Key Points

  • TF-IDF is a strong sparse baseline for search and text classification
Q9Word embeddings

What are word embeddings?

What are word embeddings. Explain the core idea, use cases, and trade-offs.

Answer

Word embeddings map tokens to dense numeric vectors learned from data. Traditional embeddings such as Word2Vec can capture distributional similarity, while contextual models produce representations that depend on surrounding text.

Key Points

  • Dense vectors encode learned relationships
  • contextual embeddings vary with context
Q10Word embeddings

Compare Word2Vec, GloVe, and FastText.

Compare Word2Vec, GloVe, and FastText.. Explain the core idea, use cases, and trade-offs.

Answer

Word2Vec learns vectors using local prediction tasks; GloVe uses global word co-occurrence statistics; FastText represents words using character n-grams, helping with rare and unseen word forms.

Key Points

  • FastText can handle morphology and rare words better through subword information
Q11Linguistic analysis

What is part-of-speech tagging?

What is part-of-speech tagging. Explain the core idea, use cases, and trade-offs.

Answer

POS tagging assigns grammatical categories such as noun, verb, adjective, or adverb to tokens based on their use in context.

Key Points

  • Context matters because a word can have different grammatical roles
Q12Linguistic analysis

What is named entity recognition (NER)?

What is named entity recognition (NER). Explain the core idea, use cases, and trade-offs.

Answer

NER identifies spans of text and classifies them as entities such as people, organizations, locations, dates, or product names.

Key Points

  • NER extracts structured entities from unstructured text
Q14Text classification

What is sentiment analysis?

What is sentiment analysis. Explain the core idea, use cases, and trade-offs.

Answer

Sentiment analysis estimates the opinion or emotional polarity expressed in text, commonly positive, negative, or neutral. More advanced setups classify aspects or emotions.

Key Points

  • Domain, sarcasm, and context can affect accuracy
Q15Text classification

What is text classification?

What is text classification. Explain the core idea, use cases, and trade-offs.

Answer

Text classification assigns one or more labels to text, such as topic, spam status, intent, or sentiment. It may be binary, multiclass, or multilabel.

Key Points

  • Choose metrics and thresholds based on class balance and error costs
Q16Sequence labeling

What is sequence labeling?

What is sequence labeling. Explain the core idea, use cases, and trade-offs.

Answer

Sequence labeling assigns a label to each token in a sequence, as in POS tagging and NER. Predictions may be independent or constrained by sequence structure.

Key Points

  • Token-level evaluation is often used
  • entity spans may need span-level metrics
Q17NLP applications

What is machine translation?

What is machine translation. Explain the core idea, use cases, and trade-offs.

Answer

Machine translation converts text from one language to another while attempting to preserve meaning, style, and relevant context.

Key Points

  • Translation quality depends on language pair, domain, and evaluation method
Q18NLP applications

What is text summarization?

What is text summarization. Explain the core idea, use cases, and trade-offs.

Answer

Text summarization produces a shorter representation of a document. Extractive methods select existing passages, while abstractive methods generate new wording.

Key Points

  • Check factual consistency, coverage, and readability
Q19NLP applications

What is question answering in NLP?

What is question answering in NLP. Explain the core idea, use cases, and trade-offs.

Answer

Question answering produces an answer to a question using a model's learned knowledge, supplied context, or retrieved documents. Systems may be extractive or generative.

Key Points

  • Ground answers in trusted context when factual reliability matters

Intermediate Questions

Implementation details, practical patterns, and common workflows.

Q13Linguistic analysis

What is syntactic parsing?

What is syntactic parsing. Explain the core idea, use cases, and trade-offs.

Answer

Syntactic parsing analyzes grammatical structure, often by building a constituency tree or dependency relations between words.

Key Points

  • Parsing helps represent grammatical relationships but can be difficult for ambiguous sentences
Q20Language modeling

What is an n-gram language model?

What is an n-gram language model. Explain the core idea, use cases, and trade-offs.

Answer

An n-gram model estimates a token's probability from the preceding n−1 tokens. It is simpler than neural language models but suffers from data sparsity and limited context.

Syntax

P(token_t | token_1...token_(t-1))

Key Points

  • N-grams are useful baselines but have limited context length
Q22NLP approaches

What is the difference between rule-based and statistical NLP?

What is the difference between rule-based and statistical NLP. Explain the core idea, use cases, and trade-offs.

Answer

Rule-based systems use hand-written patterns or linguistic rules. Statistical systems learn patterns from examples, and modern neural methods learn complex representations from data.

Key Points

  • Rules are transparent for narrow cases
  • learned models generalize but need evaluation
Q25Neural NLP architectures

What is an encoder-decoder architecture?

What is an encoder-decoder architecture. Explain the core idea, use cases, and trade-offs.

Answer

An encoder transforms input into representations, and a decoder generates or predicts an output from those representations. It is common in translation, summarization, and sequence-to-sequence tasks.

Key Points

  • Encoder-decoder models map an input sequence to an output sequence
Q26Neural NLP architectures

What is attention in NLP?

What is attention in NLP. Explain the core idea, use cases, and trade-offs.

Answer

Attention lets a model weight relevant tokens or representations when processing a sequence. It helps capture relationships that may be far apart in the input.

Key Points

  • Attention weights are learned dynamically from representations
Q27Neural NLP architectures

What is a Transformer?

What is a Transformer. Explain the core idea, use cases, and trade-offs.

Answer

A Transformer is a neural architecture built around attention and feed-forward layers, with positional information to represent sequence order. It supports parallel training and underpins many modern language models.

Key Points

  • Self-attention models token relationships
  • positional information represents order
Q29Pretrained language models

What is BERT?

What is BERT. Explain the core idea, use cases, and trade-offs.

Answer

BERT is an encoder-style Transformer pretrained with objectives that help it build contextual representations. It is commonly adapted for classification, tagging, and extractive question answering.

Key Points

  • BERT is primarily an encoder model suited to language understanding tasks
Q30Pretrained language models

Compare BERT and GPT.

Compare BERT and GPT.. Explain the core idea, use cases, and trade-offs.

Answer

BERT uses an encoder-oriented bidirectional representation objective and is commonly used for understanding tasks. GPT-style models use autoregressive next-token prediction and are suited to text generation and many instruction-following tasks.

Key Points

  • Architecture and pretraining objective shape typical strengths
Q31Pretraining objectives

What is masked language modeling?

What is masked language modeling. Explain the core idea, use cases, and trade-offs.

Answer

Masked language modeling trains a model to predict selected tokens hidden from its input, encouraging it to use surrounding context.

Key Points

  • It is a common pretraining objective for encoder models such as BERT
Q32Language modeling

What is autoregressive language modeling?

What is autoregressive language modeling. Explain the core idea, use cases, and trade-offs.

Answer

Autoregressive language modeling predicts the next token given previous tokens and trains by maximizing the likelihood of token sequences.

Key Points

  • It supports left-to-right text generation
Q33Transfer learning

What is fine-tuning a pretrained NLP model?

What is fine-tuning a pretrained NLP model. Explain the core idea, use cases, and trade-offs.

Answer

Fine-tuning continues training a pretrained model on task-specific examples so its parameters adapt to the target task or domain.

Key Points

  • Use held-out validation data and guard against overfitting on small datasets
Q34Language modeling

What is zero-shot versus few-shot classification?

What is zero-shot versus few-shot classification. Explain the core idea, use cases, and trade-offs.

Answer

Zero-shot classification predicts labels without task-specific labeled training examples, often using a pretrained model's capabilities. Few-shot methods provide a small number of labeled examples or demonstrations.

Key Points

  • Evaluate on representative data
  • few-shot results can depend on example choice
Q35Prompting and RAG

What is prompt engineering for NLP models?

What is prompt engineering for NLP models. Explain the core idea, use cases, and trade-offs.

Answer

Prompt engineering structures instructions, context, examples, and output requirements to guide a model. It can improve task performance but is not a substitute for access control or validation.

Key Points

  • Test prompts systematically and validate generated outputs
Q38Evaluation

What are BLEU and ROUGE?

What are BLEU and ROUGE. Explain the core idea, use cases, and trade-offs.

Answer

BLEU measures n-gram precision with a brevity penalty and is often used in translation. ROUGE measures overlap-oriented recall variants and is common in summarization.

Key Points

  • Overlap metrics are imperfect proxies for semantic quality
Q39Semantic similarity

What is semantic similarity in NLP?

What is semantic similarity in NLP. Explain the core idea, use cases, and trade-offs.

Answer

Semantic similarity estimates how close two texts are in meaning, often by comparing sentence embeddings with cosine similarity.

Key Points

  • Similarity scores depend on embedding model and domain
  • calibrate thresholds
Q40Semantic similarity

What is cosine similarity for text embeddings?

What is cosine similarity for text embeddings. Explain the core idea, use cases, and trade-offs.

Answer

Cosine similarity measures the cosine of the angle between two vectors. It is often used to compare embedding direction while reducing sensitivity to vector magnitude.

Syntax

cosine(a, b) = (a · b) / (||a|| * ||b||)

Key Points

  • cosine(a,b) = (a · b) / (||a|| ||b||)
Q41Text representation

How do you handle out-of-vocabulary words?

How do you handle out-of-vocabulary words. Explain the core idea, use cases, and trade-offs.

Answer

Subword tokenization, character-level models, byte-level tokenization, or subword-aware embeddings help represent rare and unseen words.

Key Points

  • Subword methods reduce dependence on a fixed whole-word vocabulary
Q42Multilingual NLP

What is multilingual NLP?

What is multilingual NLP. Explain the core idea, use cases, and trade-offs.

Answer

Multilingual NLP builds systems that process multiple languages, often using shared representations or language-specific data and components.

Key Points

  • Performance can vary greatly by language and available training data

Advanced Questions

Architecture, optimization, and design trade-offs.

Q21Language modeling

What is perplexity?

What is perplexity. Explain the core idea, use cases, and trade-offs.

Answer

Perplexity measures how well a language model predicts a sequence, derived from average negative log-likelihood. Lower perplexity indicates better predictive fit on the same evaluation setup.

Key Points

  • Compare perplexity only with compatible tokenization and evaluation data
Q23Sequence modeling

What is a Hidden Markov Model (HMM) in NLP?

What is a Hidden Markov Model (HMM) in NLP. Explain the core idea, use cases, and trade-offs.

Answer

An HMM models a sequence using hidden states and observed outputs, with transition and emission probabilities. It has been used for tagging and speech-related sequence tasks.

Key Points

  • HMMs make conditional-independence assumptions that limit their expressiveness
Q24Sequence labeling

What is Conditional Random Field (CRF)?

What is Conditional Random Field (CRF). Explain the core idea, use cases, and trade-offs.

Answer

A CRF is a probabilistic model that predicts structured labels for an input sequence while considering dependencies between neighboring output labels.

Key Points

  • CRFs can enforce consistent sequence labels, often in tagging tasks
Q28Neural NLP architectures

Compare RNNs and Transformers for NLP.

Compare RNNs and Transformers for NLP.. Explain the core idea, use cases, and trade-offs.

Answer

RNNs process tokens recurrently and maintain a hidden state. Transformers use attention and parallelize sequence processing during training, but standard full self-attention can be expensive for long sequences.

Key Points

  • Transformers dominate many large-scale NLP tasks
  • RNNs can still suit some constrained settings
Q36Prompting and RAG

What is retrieval-augmented generation (RAG) for NLP?

What is retrieval-augmented generation (RAG) for NLP. Explain the core idea, use cases, and trade-offs.

Answer

RAG retrieves relevant external passages and supplies them as context to a language model before generation. This can improve grounding and enable use of current or private knowledge.

Key Points

  • Retrieval quality, access control, and source grounding are essential
Q37Evaluation

How do you evaluate a text classifier?

How do you evaluate a text classifier. Explain the core idea, use cases, and trade-offs.

Answer

Use metrics appropriate to the task, such as accuracy, precision, recall, F1, ROC-AUC, or PR-AUC. Inspect confusion matrices and evaluate important slices such as language or customer segment.

Key Points

  • Metrics should reflect class balance and the cost of different errors
Q43Evaluation

What is data leakage in NLP?

What is data leakage in NLP. Explain the core idea, use cases, and trade-offs.

Answer

Data leakage occurs when training or model selection uses information that would not be available at evaluation or deployment, such as duplicate documents across splits or future labels.

Key Points

  • Split by document, user, source, or time when appropriate
  • deduplicate data
Q44Text classification

How do you address class imbalance in text classification?

How do you address class imbalance in text classification. Explain the core idea, use cases, and trade-offs.

Answer

Use class-aware metrics, class weights, carefully applied sampling, threshold tuning, or additional labeled data. Avoid evaluating only with accuracy when minority classes matter.

Key Points

  • Check per-class recall and precision and preserve a realistic test distribution
Q45Prompting and RAG

How do you reduce hallucinations in a question-answering system?

How do you reduce hallucinations in a question-answering system. Explain the core idea, use cases, and trade-offs.

Answer

Ground answers in retrieved or supplied evidence, instruct the model to state when evidence is insufficient, validate citations, and evaluate factuality with representative cases.

Key Points

  • Prompting alone is not a guarantee
  • retrieval and verification matter
Q46Deployment

How do you deploy an NLP model in production?

How do you deploy an NLP model in production. Explain the core idea, use cases, and trade-offs.

Answer

Package tokenization and preprocessing with the model, expose a versioned API or batch job, validate inputs, and monitor latency, errors, drift, and task quality.

Key Points

  • Keep preprocessing consistent between training and serving
Q47Security and privacy

What are common NLP privacy and security risks?

What are common NLP privacy and security risks. Explain the core idea, use cases, and trade-offs.

Answer

Risks include sensitive text in logs, prompt injection through documents, memorization or disclosure, and unauthorized access to retrieved records.

Key Points

  • Minimize and protect data, enforce retrieval permissions, and test adversarial inputs
Q48Deployment

Design an end-to-end NLP text-classification pipeline.

Design an end-to-end NLP text-classification pipeline.. Explain the core idea, use cases, and trade-offs.

Answer

Collect and label data, remove leakage, split data appropriately, build a baseline, train and tune a model, evaluate with task-specific metrics, deploy with versioning, and monitor outcomes.

Key Points

  • Track dataset/model versions and define rollback and retraining criteria
Q49Deployment

How do you monitor an NLP model after deployment?

Explain how to track quality, drift, latency, and operational health.

Answer

Monitor latency, throughput, errors, input and prediction distributions, and task metrics when ground-truth labels become available. Review performance across important languages, domains, and user segments because aggregate metrics can hide regressions.

Set alert thresholds and define owners for investigation, rollback, and retraining. Version the model and preprocessing pipeline so production changes can be traced to a release.

Key Points

  • Track quality and operational metrics.
  • Monitor drift and important user segments.
  • Define alerting, rollback, and retraining procedures.
Q50Responsible NLP

How would you evaluate bias and fairness in an NLP system?

Describe representative datasets, subgroup metrics, and mitigation trade-offs.

Answer

Evaluate the system on representative data and compare relevant error rates across language varieties and user groups where appropriate and lawful. Review annotation quality, dataset coverage, and whether labels reflect subjective or historical bias.

Potential mitigations include improving data coverage, revising labels, adjusting thresholds where justified, and human review for high-impact decisions. Document trade-offs and continue monitoring after deployment.

Key Points

  • Audit subgroup performance and data coverage.
  • Investigate label and annotation bias.
  • Document mitigations and monitor real-world outcomes.

Share this question bank

Send this page to someone preparing for an interview.