Interview Prep & Revision Guide

MEDIUM13 min readby AdminJune 20, 2026History
0.0|0 ratingsLog in to rate

50 essential interview questions with detailed answers, revision notes, and quick cheat sheets.

#ai-engineering#course#interview-prep

Introduction

This guide compiles the 50 most important interview questions, high-impact answers, revision notes, and a reference cheat sheet to prepare you for placement interviews and technical evaluations.


50 Most Important Interview Questions & Answers

Module 1: Introduction to AI Engineering

Q1: What is the difference between AI, Machine Learning, and Deep Learning?

  • Answer: AI is the broad concept of enabling machines to mimic human intelligence. Machine Learning is a subset of AI that learns patterns from data without being explicitly programmed. Deep Learning is a specialized subset of ML that uses multi-layered artificial neural networks to process unstructured data automatically.

Q2: What is Artificial General Intelligence (AGI) and how does it differ from Narrow AI?

  • Answer: Narrow AI is optimized to execute a single, specific task (e.g., chess playing or translation). AGI is a theoretical system that matches or exceeds human cognitive abilities across all domains, including reasoning, general learning, and context adaptation.

Q3: What is Generative AI?

  • Answer: Generative AI is a subset of deep learning focused on generating entirely new data instances (text, images, audio, code) by modeling the underlying probability distribution of training data.

Q4: Why are Large Language Models (LLMs) considered "generalists"?

  • Answer: LLMs are generalists because they are trained on massive, diverse web-scale text corpora. Instead of performing a single task, they learn generalized language representations, enabling them to execute coding, translation, summarizing, and reasoning through prompts alone.

Q5: What is the difference between an AI Engineer, an ML Engineer, and a Data Scientist?

  • Answer: A Data Scientist analyzes data to extract business insights and build statistical models. An ML Engineer designs, trains, and optimizes custom neural architectures. An AI Engineer integrates existing foundation models (LLMs) into production applications using APIs, vector databases, and orchestrations.

Q6: Draw or explain the high-level architecture of a RAG-based AI product.

  • Answer: User \to Application Server \to Embeddings Generator \to Vector Database (retrieves relevant document chunks) \to Prompt Compiler (combines prompt + history + retrieved docs) \to LLM API \to Application Server \to User.

Q7: What are the main limitations of utilizing closed-source APIs (like OpenAI) versus hosting open-source models?

  • Answer: Closed APIs are pay-per-token, have rate limits, raise privacy concerns (sending data outside your VPC), and present vendor lock-in risk. Open-source models require manual hosting setup and high GPU cost, but ensure complete data privacy and customization control.

Q8: Explain "catastrophic forgetting" in neural networks.

  • Answer: It is when a neural network trained on Task A is subsequently trained on Task B and completely loses its ability to perform Task A, because the weights are updated to fit only the new task.

Q9: What is heuristic programming and when is it preferred over ML?

  • Answer: Heuristic programming is rule-based coding (e.g., regex, nested if-else statements). It is preferred when the logic is simple, predictable, deterministic, and requires zero computational latency or token cost.

Q10: How does a Transformer model process text in parallel?

  • Answer: Unlike older sequential networks (RNNs) that process word-by-word, the Transformer architecture uses self-attention to process all tokens in a sequence concurrently, allowing massive parallelization on GPU hardware.

Q11: What is an Embeddings Model?

  • Answer: A model that translates text strings into high-dimensional numerical vectors (embeddings) where semantically similar texts are mapped close to each other in vector space.

Q12: Why is the GIL (Global Interpreter Lock) a bottleneck for Python AI applications?

  • Answer: The GIL restricts Python execution to a single thread at a time. This blocks CPU-bound tasks like raw tokenizing or image pre-processing from executing concurrently in multi-threaded code.

Module 2: Python for AI Engineers

Q13: Explain the difference between mutable and immutable data types in Python.

  • Answer: Mutable objects (lists, dictionaries, sets) can be changed after creation. Immutable objects (tuples, strings, integers, floats) cannot be altered.

Q14: Why can we use a tuple as a dictionary key but not a list?

  • Answer: Dictionary keys must be hashable. Tuples are immutable and have a constant hash value throughout their lifetime. Lists are mutable; their contents can change, which would alter their hash values and corrupt the hash table structure.

Q15: What is list comprehension and what is its performance benefit?

  • Answer: A concise syntax to create lists. Performance-wise, list comprehensions run at C-speed inside the Python interpreter because the loop is executed natively in optimized C code rather than Python bytecode.

Q16: What is a Python generator and why is it useful for handling large context chunks?

  • Answer: A generator is an iterator created using functions with the yield keyword. It yields values lazily one-at-a-time on demand instead of loading the entire list into memory, preventing Out-Of-Memory (OOM) crashes.

Q17: What are *args and **kwargs in Python functions?

  • Answer: *args captures an arbitrary number of positional arguments as a tuple. **kwargs captures an arbitrary number of keyword arguments as a dictionary.

Q18: What is a closure in Python?

  • Answer: A closure is an inner function that retains access to variables from its outer enclosing scope even after the outer function has finished executing.

Q19: Explain the decorator pattern in Python.

  • Answer: A decorator is a design pattern that wraps a target function to extend or modify its behavior without altering its source code. It is implemented using higher-order functions and closures.

Q20: Why should we use @functools.wraps when writing decorators?

  • Answer: It copies the name, docstring, and annotations of the original wrapped function to the decorated wrapper, preserving the original function's identity for debugging and documentation.

Q21: What are the benefits of using Python @dataclass over a standard dictionary?

  • Answer: Dataclasses enforce static type hints, prevent runtime typos (accessed via obj.key rather than obj["key"]), auto-generate boilerplate code (__repr__, __init__), and support immutability when configured as frozen.

Q22: What is the difference between except Exception as e: and a bare except:?

  • Answer: except Exception as e: catches standard runtime exceptions. A bare except: catches all exceptions, including system interrupts like KeyboardInterrupt, making it impossible to stop a running script via the terminal.

Q23: What is Exception Chaining (raise ... from e)?

  • Answer: It links a new exception to a caught underlying exception, preserving the original stack trace to help developers trace the root cause of the error.

Q24: What is the difference between concurrency and parallelism?

  • Answer: Concurrency is structuring tasks to run in overlapping timeframes, typically on a single thread (ideal for I/O-bound tasks). Parallelism is running multiple tasks concurrently on separate CPU cores (ideal for CPU-bound tasks).

Q25: Why is time.sleep() forbidden in asynchronous python code?

  • Answer: time.sleep() is synchronous and blocking; it freezes the active thread, preventing the async event loop from executing other concurrent tasks. Use await asyncio.sleep() instead.

Module 3: APIs and Backend Fundamentals

Q26: What are the core constraints of a RESTful API architecture?

  • Answer: Client-server separation, statelessness, cacheability, uniform interface (URI resource mapping), and layered system design.

Q27: Explain the concept of "statelessness" in REST APIs.

  • Answer: The server does not store session context. Every request from a client must contain all parameters, credentials, and context required to complete the operation.

Q28: What is the difference between POST and GET methods?

  • Answer: GET retrieves representations of resources without modifying data (safe and idempotent). POST submits data to create a new resource or run a stateful operation (neither safe nor idempotent).

Q29: What is the difference between PUT and PATCH methods?

  • Answer: PUT replaces an entire resource representation with the new payload. PATCH applies partial updates to specific fields of a resource.

Q30: What does a 429 status code represent, and how should an AI Engineer handle it?

  • Answer: 429 represents "Too Many Requests" (rate limit hit). An AI Engineer should handle it by implementing exponential backoff retries, queue queuing, or switching to backup model providers.

Q31: What does a 502 status code represent in an AI application?

  • Answer: 502 represents "Bad Gateway", indicating that the API server received an invalid response from an upstream server (like an external LLM API gateway).

Q32: Why is returning a 200 OK status code with an error message in the JSON body an anti-pattern?

  • Answer: It violates HTTP specifications. Standard load balancers, proxies, API clients, and routing gateways rely on HTTP status codes to detect errors, trace performance, and trigger fallbacks automatically.

Q33: What is a JSON Web Token (JWT) and how is it structured?

  • Answer: A JWT is a cryptographically signed token used to securely transmit data claims between parties. It is structured into three parts: Header, Payload, and Signature, separated by dots.

Q34: What is the security advantage of using JWT over session tokens?

  • Answer: JWTs are self-contained and stateless. The server can verify the token's validity and read user claims by checking its signature, without needing to query a session database on every request.

Q35: How does OAuth 2.0 differ from simple API Key authentication?

  • Answer: API Keys are static secrets shared directly. OAuth 2.0 is an authorization framework that uses short-lived access tokens issued by an identity provider, granting restricted scope permissions without exposing passwords.

Q36: Why is FastAPI preferred over Flask for AI backend development?

  • Answer: FastAPI supports async/await natively, handles concurrent I/O-bound requests efficiently, performs automated input validation using Pydantic, and generates Swagger documentation out-of-the-box.

Q37: What is Dependency Injection in FastAPI?

  • Answer: A design pattern that injects reusable components (like database connections or authorization logic) into route handlers using the Depends function.

Q38: Why should you avoid using blocking libraries (like requests) inside async FastAPI routes?

  • Answer: Synchronous blocking calls freeze the execution thread, blocking the event loop and preventing FastAPI from handling other concurrent requests.

Module 4: LLM Fundamentals

Q39: Explain how an autoregressive LLM generates text.

  • Answer: The model takes an input sequence of tokens, processes it, outputs a probability distribution over the vocabulary for the next token, samples a token, appends it to the input, and repeats the cycle until it hits an <EOS> token.

Q40: What is a Tokenizer and what is the concept of BPE?

  • Answer: A tokenizer splits text strings into numerical IDs representing sub-word units. Byte-Pair Encoding (BPE) is a tokenization algorithm that builds a vocabulary by iteratively merging the most frequent character/sub-word pairs.

Q41: Why does non-English text consume more tokens than English text?

  • Answer: Tokenizers are trained primarily on English data, where common words are assigned unique token IDs. Non-English words do not match these merges and are split into smaller character or byte tokens, increasing the total token count.

Q42: What is a Context Window, and what is its computational bottleneck?

  • Answer: The maximum number of input and output tokens a model can process in one step. The bottleneck is the self-attention mechanism, which scales quadratically (O(N2)O(N^2)) in memory relative to the sequence length.

Q43: How do you manage chat history when it exceeds the model's context window limit?

  • Answer: By implementing a sliding window buffer that prunes the oldest messages, using summarization models to condense older conversation turns, or using RAG pipelines to retrieve only relevant context.

Q44: What is the difference between Temperature and Top-P?

  • Answer: Temperature scales logits to control the randomness of token generation (lower values make output deterministic; higher values make it creative). Top-P restricts sampling to a subset of tokens whose cumulative probability exceeds the threshold PP.

Q45: Why is setting Temperature to 0.0 useful for production APIs?

  • Answer: It makes the output deterministic, ensuring the model always selects the highest-probability token. This is critical for returning consistent structures like JSON or SQL code.

Q46: What is Few-Shot Prompting, and when is it preferred over Zero-Shot?

  • Answer: Few-shot prompting provides input-output examples inside the prompt. It is preferred when the target formatting pattern is complex, or when the model needs to mimic a specific tone or structure.

Q47: Explain Chain-of-Thought (CoT) prompting.

  • Answer: CoT instructs the model to break down its reasoning step-by-step before outputting the final answer. This forces the model to generate intermediate reasoning tokens, which improves logical reasoning accuracy.

Q48: What is Structured Output in LLMs?

  • Answer: It is forcing the model to return data in a machine-readable format (like valid JSON conforming to a JSON Schema) instead of unstructured natural language text.

Q49: What is Function Calling?

  • Answer: A technique where the model is provided with a list of tools defined by their JSON schema parameters. The model outputs a structured JSON object containing the function name and arguments to execute, delegating the action to the application code.

Q50: How does grammar-guided constrained decoding work?

  • Answer: The API gateway parses the model's token output against a target JSON schema. It dynamically adjusts the output probabilities during generation, setting the probability of invalid tokens to zero to guarantee schema compliance.

Interview Revision Notes

  1. AI vs. traditional software: Traditional software uses rules to transform data. AI infers patterns from data to construct rules dynamically.
  2. GIL Limits: Python's GIL limits execution to one thread. Bypass it using multiprocessing for CPU-bound tasks, or asynchronous event loops for I/O-bound tasks.
  3. Data Structures: Lists are dynamic arrays (O(N)O(N) lookup). Sets and dicts are hash tables (O(1)O(1) lookup). Use sets for fast uniqueness filtering.
  4. Decorators: Utilize closures to wrap function executions. Always use @functools.wraps to preserve function attributes.
  5. Async Concurrency: asyncio runs I/O-bound tasks concurrently on a single thread. Avoid synchronous blocking libraries (like requests or time.sleep()) in async routes to prevent freezing the event loop.
  6. REST URIs: Use nouns, not verbs (e.g., /api/v1/chats instead of /getChats). Match actions using HTTP methods (GET, POST, PATCH, DELETE).
  7. HTTP Statuses: Return correct status codes (2xx success, 4xx client errors, 5xx server errors). Use 429 for rate limit indicators and 401 for unauthorized access.
  8. Stateless JWT: JWTs verify credentials statelessly using cryptographic signatures, eliminating the need for database queries on every API request.
  9. Sub-word Tokens: Models process sub-word token IDs, not raw text. 1 token is approximately 4 characters in English.
  10. Sampling Parameters: High temperature flattens token distributions, promoting creativity. Low temperature sharpens distributions, promoting deterministic, syntax-safe outputs.

Cheat Sheet for Quick Revision

text
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
================================================================================
                       AI ENGINEERING CHEAT SHEET
================================================================================

1. CORE DEFINITIONS:
   - 1 English Token ≈ 4 characters ≈ 0.75 words.
   - Standard attention mechanism memory complexity: O(N²) quadratic scaling.
   - Temperature range: 0.0 (deterministic/JSON) to 1.0+ (creative writing).
   - Top-P range: 0.0 to 1.0 (limits choices to cumulative probability subset).

2. COMMON HTTP STATUS CODES:
   - 200 OK          : Request completed successfully.
   - 201 Created     : Resource created successfully (POST).
   - 400 Bad Request : Invalid client payload format.
   - 401 Unauthorized: Invalid or missing API key headers.
   - 403 Forbidden   : Authenticated but lacks permissions.
   - 429 Rate Limit  : Too many requests. Apply exponential backoff.
   - 502 Bad Gateway : Upstream provider API connection failure.

3. PYTHON FASTAPI PARADIGM:
   - Run server      : uvicorn main:app --reload --port 8000
   - Interactive Docs: http://127.0.0.1:8000/docs
   - FastAPI inputs  : Validate incoming JSON using Pydantic schemas.
   - Async paths     : Use async/await for I/O operations (httpx instead of requests).

4. CODE PATTERNS:
   - Exponential Backoff: delay = initial_delay * (2 ** attempt)
   - Pruning Window     : while total_tokens > max_limit: history.pop(0)
   - JWT Parts          : Header.Payload.Signature
================================================================================

Discussion

Join the discussion! Sign in to leave comments and ask questions.

Loading discussion...