An NLP engineer builds systems that understand and generate text, such as classifiers, entity extraction, search, summarisation and multilingual models for Indian languages. Interviews test text preprocessing, tokenisation, embeddings, transformer architecture, fine-tuning, evaluation metrics and handling noisy or code-mixed text like Hinglish. Increasingly, interviews also cover LLM prompting, RAG and efficient fine-tuning methods such as LoRA. A project walkthrough with error analysis is usually expected.
Transformers and BERT Text classification and NER Tokenisation Fine-tuning with LoRA Multilingual NLP
Solved for this roleStart practicing
3 QUESTIONS FREESign up to unlock the full question bank and track your progress.Unlock every question and answer, then continue practising company-wise and package-wise.
✓ 3 questions free • Unlock the rest in seconds
01
What is DBSCAN and when is it better than K-means?
DBSCAN is a density-based clustering algorithm. It groups points that have at least min_samples neighbours within distance eps, and marks isolated points as noise. Unlike K-means, it does not need the number of clusters, finds clusters of any shape, and handles outliers. It struggles when clusters have very different densities and in high dimensions. It suits location data, like finding delivery hotspots from GPS points.
02
Write scikit-learn code to calibrate a gradient boosting classifier's probabilities and check the result.
First confirm with per-segment metrics and enough samples, since small groups are noisy. Then check why: fewer training examples from that region, different feature distributions, missing data or labels that reflect past biased decisions. Fixes include collecting more data, reweighting, segment-aware features or a separate calibration. Also review fairness and regulatory requirements, and agree with risk and compliance teams on acceptable performance gaps before launch.
04
Why is cross-entropy preferred over MSE for classification in neural networks?
Cross-entropy measures how far predicted probabilities are from the true class and strongly penalises confident wrong predictions. With a softmax or sigmoid output, it gives large, useful gradients when the model is wrong. MSE with sigmoid outputs gives very small gradients when predictions saturate, so learning slows down. Use binary cross-entropy for two classes, categorical cross-entropy for many classes, and MSE for regression targets.
It combines gradient boosting with regularisation, handling of missing values, parallel tree construction and speed optimisations, and it performs strongly on tabular data.
Function calling lets an LLM respond with a structured request to call a tool you defined, such as get_order_status with an order_id, instead of plain text. Your code runs the function, returns the result to the model, and the model uses it in its final answer. This connects LLMs to live data, calculators and APIs. You must validate arguments, limit which tools exist and handle errors, because the model can choose wrong inputs.
08
What is the randomisation unit in an experiment, and why does it matter?
The randomisation unit is what you assign to variants: a user, a session, a device, a page view or even a city. Choosing user-level keeps each person's experience consistent and avoids contamination. The analysis unit should match the randomisation unit, because if you randomise by user but analyse by page view, observations are correlated and standard errors come out too small, producing false positives. Use the delta method or bootstrap when they differ.
09
What is chunking in RAG and how do you choose a chunk size?
Chunking splits documents into smaller pieces before embedding them, so retrieval returns focused passages that fit in the prompt. Small chunks, like 200 tokens, are precise but lose context; large chunks, like 1,000 tokens, keep context but add noise and cost. Split on natural boundaries such as headings and paragraphs, add some overlap, and keep metadata like title and section. Then tune chunk size using retrieval metrics on real questions.
10
Your LLM assistant confidently quotes a policy clause that does not exist. Why does this happen and how do you reduce it?
Hallucination is when a model produces confident text that is false or not supported by any source. It happens because the model generates plausible tokens rather than checking facts. Reduce it by grounding answers in retrieved documents, asking the model to cite sources and say I do not know when context is missing, using low temperature, and validating outputs with rules or a second checking step. Measure it with a labelled evaluation set.
BERT is an encoder-only transformer that reads text in both directions at once. It was pretrained with masked language modelling, where about 15 percent of tokens are hidden and the model predicts them, plus next sentence prediction in the original version. This gives contextual embeddings, so a word's vector depends on its sentence. You fine-tune BERT with a small task head for classification, NER or question answering.
12
Write Python code to evaluate a forecasting model with expanding-window time series cross-validation.
import numpy as np
from sklearn.model_selection import TimeSeriesSplit
from sklearn.metrics import mean_absolute_error
tscv = TimeSeriesSplit(n_splits=5, test_size=28)
scores = []
for tr, te in tscv.split(X):
model.fit(X.iloc[tr], y.iloc[tr])
pred = model.predict(X.iloc[te])
scores.append(mean_absolute_error(y.iloc[te], pred))
print(np.mean(scores), scores)
It applies Bayes' theorem assuming features are independent given the class. The assumption is rarely true but the model is fast and works well for text.
14
You keep adding features and R-squared keeps rising. Is the model really getting better?
R-squared shows the share of variance in the target explained by the model. It never decreases when you add a feature, even a useless one. Adjusted R-squared penalises extra features based on the number of predictors and sample size, so it rises only if a new feature improves the model more than chance would. Use adjusted R-squared to compare linear models with different numbers of features.
15
You must classify support messages into 40 categories, but some categories have only 20 examples. What do you do?
Start with a pretrained sentence embedding model plus a simple classifier, or fine-tune a small transformer with class weights. For the rare categories, try few-shot approaches such as SetFit or an LLM with examples in the prompt, and generate or collect more examples. Merge categories that are rarely distinguishable. Report per-class F1 rather than overall accuracy, and route low-confidence predictions to a human queue.
16
What is the difference between an epoch, a batch and an iteration?
Quantisation stores model weights in lower precision, such as 8-bit or 4-bit integers instead of 16-bit floats. A 7-billion parameter model drops from about 14 GB to around 4 GB at 4-bit, so it fits on smaller GPUs or even laptops and runs faster. The cost is some loss in quality, usually small at 8-bit and noticeable on hard tasks at very low bits. Common formats include GPTQ, AWQ and GGUF.
18
What is subword tokenisation like BPE or WordPiece?
Subword tokenisers split text into frequent pieces between characters and full words. Byte Pair Encoding starts from characters and repeatedly merges the most frequent pairs. WordPiece, used by BERT, is similar but chooses merges by likelihood. Rare words like unhappiness become un, happi, ness, so there are no unknown words and the vocabulary stays around 30,000 to 100,000. Token counts also decide LLM cost and context use.
19
What is the difference between a one-tailed and a two-tailed test?
A two-tailed test checks for a difference in either direction, for example whether a new page changes conversion up or down. A one-tailed test checks only one direction, such as whether it increases conversion. One-tailed tests have more power for that direction but ignore harm in the other direction. In most product experiments a two-tailed test is the safer default unless the direction was fixed before seeing data.
20
What are precision and recall trade-offs in practice?
Raising the threshold improves precision but lowers recall. Fraud detection leans to recall, while spam filters often prefer precision; choose by the cost of each error.
An AI agent is an LLM that works in a loop: it plans a step, calls a tool, reads the result and decides the next step until the goal is met. For example, it might query a database, run Python on the result and write a summary. Agents handle multi-step tasks but are less predictable, slower and costlier than a single call. Good designs limit tools and steps, log every action and keep a human check for risky actions.
22
How do you evaluate clustering when you have no labels?
Use internal metrics: the silhouette score compares how close a point is to its own cluster versus the nearest other cluster, and the Davies-Bouldin index measures cluster overlap. The elbow method looks at within-cluster variance. But the real test is usefulness: are clusters stable across random seeds and samples, can the business describe them, and do they behave differently on outcomes like spend or churn?
It tries candidate splits and picks the one that most reduces impurity — Gini or entropy (information gain) for classification, variance / MSE for regression.
The ROC curve plots true positive rate against false positive rate across thresholds. AUC is the probability that a random positive is ranked above a random negative; 0.5 is chance.
Term Frequency × Inverse Document Frequency: a word scores high if it is frequent in one document but rare across all documents. A classic way to turn text into numeric features.
It lets a model weigh which input positions matter most for each output, computing weighted combinations of values from query-key similarity. It is the core of transformers.
27
Your dataset is highly imbalanced (2% positives). How do you handle it?
Use stratified splits, class weights, resampling (SMOTE or undersampling) and threshold tuning, and judge the model with PR-AUC or F1 instead of accuracy.
28
How do you choose a learning rate for a neural network?
Situation: sales leaders wanted an LLM to auto-send pricing quotes to clients. Task: guide them to a safe plan. Action: I demoed real failure cases where the model invented discounts, showed accuracy numbers from a test set and proposed a draft-and-approve flow with fixed price data from our system. Result: they agreed, quote drafting time fell by half, and no wrong prices reached clients.
30
Your image classifier trained on 2,000 images memorises the training set within 5 epochs. What do you try?
With so little data, I would use transfer learning from a pretrained model like ResNet or EfficientNet and fine-tune only the top layers first. I would add data augmentation such as flips, crops and colour changes, use dropout and weight decay, and apply early stopping on validation loss. Collecting more labelled images or using a smaller model also helps. I would check for duplicate images across train and validation sets too.
31
What is the difference between SGD and Adam optimisers?
SGD updates weights using the gradient times a fixed learning rate, often with momentum. Adam keeps running averages of gradients and their squares, giving each parameter its own adaptive step size. Adam converges fast with little tuning and is the default for transformers. Well-tuned SGD with momentum sometimes generalises better on vision tasks. AdamW, which decouples weight decay, is the common choice for modern deep learning.
32
What is the difference between hard voting and soft voting in ensembles?
In hard voting each model predicts a class and the majority wins. In soft voting each model gives class probabilities, they are averaged, and the class with the highest average wins. Soft voting usually works better because it uses each model's confidence, but it needs calibrated probabilities from all models. Hard voting is simpler and works even with models that only output labels.
Hybrid search combines keyword search, like BM25, with vector search. Keywords catch exact matches such as product codes and names, while vectors catch meaning and paraphrases. Results are merged, often with reciprocal rank fusion. Reranking then takes the top 20 to 50 candidates and scores each one against the query with a cross-encoder model, which is slower but more accurate. Together they usually improve RAG answer quality noticeably.
Gradients shrink as they pass through many layers (for example with sigmoid), so early layers barely learn. ReLU, residual connections and good initialisation help.
36
Write a basic PyTorch training loop for one epoch.
model.train()
for X, y in train_loader:
X, y = X.to(device), y.to(device)
optimizer.zero_grad()
logits = model(X)
loss = loss_fn(logits, y)
loss.backward()
optimizer.step()
# evaluation
model.eval()
with torch.no_grad():
val_loss = sum(loss_fn(model(Xv.to(device)), yv.to(device)).item() for Xv, yv in val_loader)
37
Write Python code using Hugging Face transformers to run sentiment analysis on a list of reviews.
from transformers import pipeline
clf = pipeline(
'sentiment-analysis',
model='distilbert-base-uncased-finetuned-sst-2-english'
)
reviews = ['Delivery was fast and the product is great',
'Packaging was damaged and support did not reply']
for text, out in zip(reviews, clf(reviews, batch_size=16)):
print(out['label'], round(out['score'], 3), '-', text)
Guardrails are checks around the model that keep inputs and outputs safe and on-topic. Input guardrails detect prompt injection, abuse or off-topic requests. Output guardrails check for personal data, toxic content, policy violations or invalid formats before the answer reaches the user. They can be rules, classifiers or a second LLM call. Good guardrails also define fallback responses and log blocked cases for review.
It projects data onto orthogonal directions of maximum variance to reduce dimensions, remove correlation and speed up models, at some cost of interpretability.
40
Your sales forecast scores well in k-fold cross-validation but fails in production. What could be wrong with the validation?
Random k-fold mixes future and past rows, so the model trains on data from after the period it predicts. That leaks information and inflates scores. Use time-based splits instead: train on an expanding or rolling window and validate on the next period, like TimeSeriesSplit in scikit-learn. Leave a gap between train and validation when features use lagged values, so the test reflects real forecasting conditions.
Frequently asked questions
What does a NLP Engineer do?
An NLP engineer builds systems that understand and generate text, such as classifiers, entity extraction, search, summarisation and multilingual models for Indian languages. Interviews test text preprocessing, tokenisation, embeddings, transformer architecture, fine-tuning, evaluation metrics and handling noisy or code-mixed text like Hinglish. Increasingly, interviews also cover LLM prompting, RAG and efficient fine-tuning methods such as LoRA. A project walkthrough with error analysis is usually expected.
Which skills are tested in a NLP Engineer interview?
Expect questions on Transformers and BERT, Text classification and NER, Tokenisation, Fine-tuning with LoRA, Multilingual NLP. Most rounds also ask you to explain a project and solve one practical problem live.
How do I prepare for a NLP Engineer interview?
Revise Deep Learning and NLP, Generative AI and LLMs, Machine Learning first using the topic sheets, practise the questions on this page aloud, then do one full mock interview to practise timing.