Gen AI Interview Questions and Answers
26 questions with short, clear answers · Updated December 2026
Generative AI questions now come up for AI engineer, ML engineer, data scientist and even cloud and software developer roles. This page covers the concepts interviewers expect you to explain clearly: how large language models work, prompting, embeddings and RAG, fine-tuning, agents and tool use, evaluation, and safety and cost in production.
The field moves fast, so the answers explain ideas that stay true across models and vendors rather than benchmark numbers that change every few months. Be ready to talk about a project you built, such as a RAG chatbot over your own documents.
LLM fundamentals
Q1. What is generative AI, and how is it different from traditional machine learning?
Traditional machine learning mostly predicts or classifies: is this email spam, what will sales be next month. Generative AI creates new content, such as text, code, images, audio or video, by learning the patterns of its training data. Large language models are the best-known example; they are trained on huge text collections and can be adapted to many tasks with prompts instead of training a new model for each task.
Q2. How does a large language model generate text?
An LLM is a transformer neural network trained to predict the next token from the tokens before it. To generate, it predicts a probability for every possible next token, picks one (according to sampling settings), appends it and repeats. After pre-training on large text collections, models are tuned with instruction data and human or AI feedback so they follow instructions and behave helpfully and safely.
Q3. What are tokens and the context window?
Tokens are the pieces of text a model reads and writes: whole words, parts of words or punctuation; in English a token is roughly three-quarters of a word, and Hindi usually takes more tokens for the same text. The context window is the maximum number of tokens the model can consider at once, covering the prompt, any documents, the conversation history and the output. Pricing and speed are usually per token.
Q4. What is the attention mechanism in transformers?
Self-attention lets each token look at every other token in the input and weigh how relevant each one is when building its representation, so a word's meaning can depend on words far away ("bank" near "river" versus "loan"). Transformers stack many attention layers and process tokens in parallel, which made training on very large datasets practical.
Q5. What do temperature and top-p control?
They control randomness when picking the next token. Low temperature (near 0) makes the model pick the most likely tokens, giving focused, repeatable answers for extraction, classification or code. Higher temperature spreads probability out for more varied, creative text. Top-p (nucleus sampling) samples only from the smallest set of tokens whose probabilities add up to p. Some newer reasoning models fix these settings.
Q6. What is hallucination, and how do you reduce it?
Hallucination is when a model states something false or made up with confidence, because it generates plausible text rather than looking facts up. Reduce it by grounding answers in retrieved documents (RAG) and asking the model to cite them, telling it to say "I don't know" when the context lacks the answer, using tools for calculations and live data, lowering temperature for factual tasks, and checking outputs with evaluations or a human review for high-stakes use.
Q7. What is the difference between open-weight and closed models?
Closed models are used through a vendor's API; you cannot download them, but they are often the most capable and need no infrastructure. Open-weight models can be downloaded and run on your own servers or cloud, which gives control over data, cost at scale and fine-tuning, but you manage hosting, GPUs and updates yourself. Many companies use both, choosing per task.
Prompt engineering
Q8. What makes a good prompt?
Clear context and goal, the role or audience, specific instructions, relevant data separated from instructions (for example with XML tags or headings), examples of the desired output, constraints such as length and tone, and the output format (for example JSON with given fields). Then test it on real examples and iterate; prompts are code and should be versioned and evaluated.
Q9. What are zero-shot, few-shot and chain-of-thought prompting?
Zero-shot gives only the instruction. Few-shot adds a few input-output examples so the model copies the pattern and format. Chain-of-thought asks the model to reason step by step before answering, which helps with multi-step problems; many current models have built-in reasoning or "thinking" modes that do this without being asked.
Q10. What is a system prompt?
Instructions given to the model separately from the user's messages, usually by the application, that set its role, rules, tone and boundaries for the whole conversation, for example "You are a support assistant for our product; answer only from the provided documents." Users do not normally see it, but it should not be treated as secret, because it can sometimes be extracted.
Q11. How do you get reliable structured output such as JSON from an LLM?
Use the provider's structured output or JSON schema feature, or define the output as a tool call with a schema, so the response is guaranteed to match. Without that, describe the schema exactly, give an example, and validate the result in code (for example with Pydantic), retrying or repairing on failure.
Embeddings and RAG
Q12. What are embeddings?
An embedding is a list of numbers (a vector) that represents the meaning of a piece of text, an image or other data, produced by an embedding model. Texts with similar meaning get vectors that are close together, measured with cosine similarity or dot product. Embeddings power semantic search, recommendations, clustering and RAG.
Q13. What is RAG (retrieval-augmented generation)?
RAG answers questions using your own data without retraining the model. Documents are split into chunks, embedded and stored in a vector index. For each question, the most relevant chunks are retrieved and put into the prompt, and the model answers from them, ideally with citations. It keeps answers current and grounded, and access control can be applied at retrieval time.
Q14. What is a vector database?
A database that stores embeddings and finds the nearest vectors to a query quickly using approximate nearest-neighbour indexes such as HNSW. Examples are Pinecone, Weaviate, Qdrant, Milvus and Chroma, and vector support in existing databases such as PostgreSQL with pgvector, OpenSearch and Elasticsearch. Metadata filters (by user, date or department) are as important as similarity.
Q15. How do you choose a chunking strategy?
Chunks must be small enough to be specific but large enough to keep meaning: commonly a few hundred tokens with some overlap, split along natural boundaries such as headings, paragraphs or functions rather than fixed character counts. Keep metadata such as the source, title and section with each chunk, and test different sizes against real questions, because the best choice depends on the documents.
Q16. How can you improve a RAG system that gives poor answers?
First find whether retrieval or generation is failing by checking whether the right chunks were retrieved. To improve retrieval: hybrid search (vector plus keyword such as BM25), a reranker model, better chunking and metadata filters, and query rewriting. To improve generation: clearer instructions to answer only from the context and cite sources, fewer but better chunks, and a stronger model. Measure every change on a fixed evaluation set.
Q17. When would you fine-tune a model instead of using RAG or prompting?
Use prompting first, and RAG when the model needs knowledge it does not have or that changes. Fine-tune when you need a consistent style, format or behaviour that prompts cannot achieve reliably, a specialised task where a smaller fine-tuned model can match a larger one at lower cost and latency, or domain language. Fine-tuning is poor at adding facts that change, and it needs good training data and evaluation.
Q18. What are LoRA and quantization?
LoRA (low-rank adaptation) is a parameter-efficient fine-tuning method: the original weights are frozen and small extra matrices are trained, so fine-tuning needs far less GPU memory and the adapter files are small. Quantization stores weights in fewer bits (for example 8-bit or 4-bit instead of 16-bit), cutting memory and cost for running a model with a small loss in quality. QLoRA combines the two.
AI agents and tool use
Q19. What is an AI agent, and how is it different from a chatbot?
A chatbot answers one message at a time. An agent is given a goal and works towards it in a loop: the model decides on an action, calls a tool (search, code execution, an API, a database), observes the result and decides the next step until the task is done. Agents can complete multi-step work, but need limits on cost and steps, permissions and human approval for risky actions.
Q20. How does tool calling (function calling) work?
The application describes available tools to the model with a name, a description and a JSON schema for the parameters. When useful, the model responds with a tool call (the tool name and arguments) instead of text; the application runs the tool itself and sends the result back, and the model uses it to continue. The model never runs code directly, so the application controls what is allowed.
Q21. What is the Model Context Protocol (MCP)?
MCP is an open protocol, introduced by Anthropic in 2024 and now widely adopted, that standardises how AI applications connect to tools and data sources. A service is wrapped once as an MCP server exposing tools, resources and prompts, and any MCP-compatible client (assistants, IDEs, agent frameworks) can use it, instead of a custom integration for every app and every model.
Q22. What are common patterns for building agents?
Start with the simplest thing that works: a single model call, then prompt chaining (fixed steps), routing (classify the request and send it to a specialised prompt), parallel calls, and an orchestrator that delegates to worker agents. A full autonomous loop is used only when the steps cannot be known in advance. Frameworks such as LangGraph, the OpenAI Agents SDK and the Claude Agent SDK help, but the patterns matter more than the framework.
Evaluation, safety and production
Q23. How do you evaluate an LLM application?
Build a test set of realistic inputs with expected answers or grading criteria, including edge cases and past failures. Score outputs with code checks where possible (format, exact facts), with an LLM-as-judge using a clear rubric for open-ended quality, and with human review on a sample. Track metrics such as accuracy, groundedness, refusal rate, latency and cost, and run the evals on every prompt or model change.
Q24. What is prompt injection, and how do you defend against it?
Prompt injection is when instructions hidden in user input or in content the model reads (a web page, email or document) try to override the application's instructions, for example to leak data or trigger a tool. There is no complete fix, so defend in layers: treat retrieved content as data, give tools least privilege, require human confirmation for sensitive actions, filter inputs and outputs, separate trusted and untrusted content, and log and monitor.
Q25. How do you reduce the cost and latency of an LLM application?
Use the smallest model that passes your evals and route only hard requests to larger models; shorten prompts and retrieved context; use prompt caching for long, repeated prefixes; cache full responses for repeated questions; stream output so users see text sooner; use batch APIs for work that is not urgent; and set limits on output length and agent steps.
Q26. What responsible-AI and data concerns should you consider?
Privacy (do not send personal or confidential data where it is not allowed, check the provider's data retention and training terms, and follow laws such as India's DPDP Act), bias and fairness in outputs, copyright and licensing of generated content and training data, transparency that users are talking to AI, human oversight for decisions that affect people, and content safety filters.
Learn Gen AI hands-on
Knowing the answers is half the job; interviewers also ask what you have built. Technical Guftgu's Gen AI training is taught in Hindi with live classes, labs and project work, plus resume and mock-interview help. We do not promise or guarantee job placement.
Gen AI training near you
- Gen AI training in Delhi
- Gen AI training in Noida
- Gen AI training in Gurugram
- Gen AI training in Dehradun
- Gen AI training in Bangalore
- Gen AI training in Hyderabad
- Gen AI training in Pune
- Gen AI training in Mumbai
- Gen AI training in Chennai
- Gen AI training in Kolkata
- Gen AI training in Jaipur
- Gen AI training in Lucknow