Search, neural networks, transformers, LLMs and responsible AI. Open a question to read the answer.
The three terms are nested. Artificial intelligence is the broad goal of building systems that perform tasks normally needing human intelligence. Machine learning is the subset of AI in which behaviour is learned from data instead of being hand-coded. Deep learning is the subset of ML that uses neural networks with many layers to learn features directly from raw inputs.
A chess engine using alpha-beta search is AI but not ML. A spam filter using logistic regression is ML but not deep learning. An image classifier built on a CNN is all three.
Apply. For a payments fraud system, I would pick the simplest layer that meets the requirement. Hard compliance checks (sanctions lists, velocity limits) stay as rules. Transaction scoring on tabular features starts with gradient-boosted trees. Deep learning enters only where the input is unstructured, such as scanned documents or free-text dispute descriptions.
Test. Every learned model must beat a trivial baseline (a rule or a logistic regression) on a time-based holdout set, not a random split. I compare precision at a fixed alert volume, latency, and cost per prediction, so a deep model is only adopted when the gain justifies the extra compute and loss of interpretability.
Symbolic AI represents knowledge as explicit symbols and rules and reasons over them with logic or search. Statistical AI learns patterns from data and encodes them as numeric parameters. Neural networks and LLMs belong to the statistical side.
Neither dominates. Symbolic systems fail on ambiguous real-world input such as speech or images, while statistical models struggle to guarantee that a constraint always holds. Many production systems combine them, for example an LLM extracting fields from a document and a rule engine validating them.
Apply. In an insurance claims triage service, I would use a statistical model to score claim complexity from text and history, then a symbolic layer to enforce policy: coverage limits, mandatory manual review above a threshold, and regulatory routing rules. The model proposes, the rules decide what is allowed.
Test. The rule layer gets conventional unit tests, one per rule plus boundary cases, and a decisiontable review with domain experts. The model gets held-out evaluation and slice metrics. End to end, I replay a golden set of historical claims and assert that no output violates a rule, whatever the model score.
Search algorithms explore a state space to find a path from a start state to a goal. They differ in which node they expand next.
Apply. In a warehouse robot routing service, the floor is a weighted grid with blocked cells and slow zones. I would use A* with a Manhattan-distance heuristic scaled by the minimum cell cost, which stays admissible on a four-connected grid. BFS fits unweighted problems such as finding the fewest hops in a network, and DFS fits exhaustive tasks like enumerating configurations or detecting cycles.
Test. I check optimality by comparing A* path cost against Dijkstra on thousands of random maps; they must match. A property test asserts the heuristic never exceeds the true remaining cost. Edge cases include an unreachable goal, start equal to goal, and a fully blocked corridor.
Knowledge representation is how facts, relationships, and rules about a domain are encoded so a machine can store them and reason over them. A good representation is expressive enough to capture the domain, supports efficient inference, and can be maintained by people.
From these triples a reasoner can infer that Aspirin is contraindicated with anticoagulants through its class. Embeddings are a statistical, implicit alternative: they capture similarity but give no explicit, checkable facts.
Apply. For an e-commerce catalogue, I would model products, brands, categories, and compatibility as a knowledge graph with a defined schema. It powers faceted search, “works with this device” answers, and grounding for an LLM shopping assistant. I start by writing competency questions the graph must answer, then design the ontology around them rather than modelling everything.
Test. Each competency question becomes an automated SPARQL or Cypher query with an expected result. Schema constraints (SHACL for RDF) reject malformed data, such as a product with two brands or a price that is not numeric. A reasoner run checks the ontology for logical inconsistencies after every change.
An expert system is a program that captures the decision-making knowledge of human specialists as explicit rules and applies it to give advice or diagnoses in a narrow domain. MYCIN (infection diagnosis) and XCON (computer configuration) are the classic examples.
(goal to supporting facts). • Explanation facility: shows which rules led to a conclusion.
Apply. A rule-based engine suits a loan pre-qualification or regulatory compliance check where logic is stable, auditable, and written by policy staff. I would implement it with a rules engine such as Drools or a decision-table tool, keep rules in version control, and separate rule data (thresholds) from code so analysts can change them safely.
Test. Each rule gets at least one passing and one failing case, plus boundary values at every threshold. Expert-labelled historical cases form a regression suite that runs on every rule change. I also measure rule coverage: rules that never fire on realistic data are either dead or signal a gap in the test set.
These are the three main learning paradigms, distinguished by the feedback the learner receives.
Supervised learning minimises error against known answers, such as predicting house prices from labelled sales. Unsupervised learning groups or compresses unlabelled data, such as segmenting customers with k-means. In reinforcement learning, an agent chooses actions, observes rewards, and learns a policy that maximises cumulative reward; credit assignment over time is its core difficulty.
Apply. In a subscription business, churn prediction is supervised: labelled history of who cancelled. Customer segmentation for marketing is unsupervised: cluster usage behaviour, then name the segments with the business. Choosing which retention offer to show each user is a candidate for reinforcement learning (or a contextual bandit), since the reward, retention, arrives after the action.
Test. Supervised models are tested on a time-split holdout with precision, recall, and calibration. Clusters are checked with silhouette score, stability across resamples, and whether the business can act on them. For RL, I never train live first: I build a simulator or use logged data with off-policy evaluation, then run a small A/B test with guardrail metrics.
A neural network is a stack of layers, each computing a weighted sum of its inputs followed by a nonlinear activation. Backpropagation is the algorithm that computes how the loss changes with respect to every weight, so an optimiser can update them.
the loss with respect to its output and produces the gradient for its weights and for its input. 3. Update: an optimiser such as SGD or Adam adjusts weights using those gradients.
Apply. In practice backpropagation is handled by the framework, so the work is in setting up training correctly: a PyTorch model for classifying support tickets, a loss that matches the task, an optimiser, and a loop that calls loss.backward() then optimizer.step(). I log gradient norms per layer alongside the loss, because they show training health before accuracy does.
I verify gradients numerically with torch.autograd.gradcheck. Shape and dtype assertions catch silent broadcasting mistakes.
An activation function applies a nonlinearity to a neuron’s weighted sum. Without it, stacked linear layers collapse into one linear transformation and the network could not learn complex patterns.
in deep hidden layers. • Tanh: zero-centred, range (-1, 1); common in recurrent networks. • Softmax: turns a vector of scores into a probability distribution over classes.
Apply. For a multi-class document classifier, I use GELU or ReLU in hidden layers and leave the final layer as raw logits, letting the loss apply softmax internally (CrossEntropyLoss in PyTorch). Binary tasks use a single logit with BCEWithLogitsLoss; regression uses no output activation, or softplus when the target must be positive. The output activation is dictated by the target’s range, the hidden activation by training behaviour.
Test. I assert output ranges and that probabilities sum to one where expected. A quick ablation swaps the hidden activation on a fixed seed and compares validation curves. Monitoring the fraction of zero activations per layer during training exposes problems early.
A loss function measures how wrong a model’s predictions are; optimisation is the process of adjusting parameters to minimise it.
Loss is a differentiable proxy; the metric the business cares about (F1, revenue) usually is not differentiable.
Apply. For a fraud model with 0.2% positives, plain cross-entropy would favour predicting “legitimate” for everything. I would use class weights or focal loss, train with AdamW, and add a warmup plus cosine decay schedule. The loss is chosen to reflect error costs, and the decision threshold is tuned afterwards against business metrics.
Test. Sanity checks come first: the initial loss should be near ln(K) for K balanced classes, and the model must overfit a tiny subset. A learning-rate range test picks a sensible maximum rate. I track training and validation loss together, plus the real metric, such as precision at fixed recall, since a falling loss can coexist with a worse business outcome.
wise feed-forward network, residual connections, and layer normalisation. Since attention has no notion of order, positional information is added through positional encodings or rotary embeddings.
Each sub-layer is wrapped in a residual connection, and many modern models normalise before the sub-layer, as drawn.
Apply. I would rarely train a transformer from scratch. For a contract-review tool I would pick a pretrained model by task: an encoder model for clause classification and embeddings, a decoder-only LLM for drafting or extraction. Model size, context length, licence, and serving cost drive the choice before accuracy tuning begins.
Test. I benchmark latency and memory across realistic input lengths, since cost grows with sequence length. After any export, quantisation, or runtime change (ONNX, TensorRT, vLLM), I compare outputs against the reference model on a fixed test set and assert metric parity within a tolerance. Causalmask tests verify that a token’s output does not change when later tokens change.
The √d_k scaling keeps dot products from growing with dimension and saturating the softmax. Multihead attention runs several attentions in parallel with separate projections, so different heads can capture different relationships. In decoder models, a causal mask blocks attention to future tokens.
Apply. In a long-document summariser, attention is what lets each output token draw on relevant source passages. In practice I use library implementations (scaled_dot_product_attention in PyTorch, FlashAttention kernels) rather than hand-written ones, and choose context length and any sliding-window or grouped-query variant based on memory and latency budgets.
Test. I unit-test a custom attention layer against a reference implementation on random tensors. Mask tests are essential: padded positions must receive zero weight, and perturbing a future token must not change earlier outputs in a causal model. Shape checks cover batch, heads, and sequence dimensions.
An embedding is a dense numeric vector that represents an item, such as a word, sentence, image, or product, so that similar items sit close together in the vector space. Models learn them so that geometric closeness reflects semantic closeness.
At scale, exact search over millions of vectors is replaced with approximate nearest-neighbour indexes such as HNSW. Vectors from different embedding models are not comparable with each other.
Apply. For semantic search over support tickets, I would embed each ticket (chunked if long), store vectors in a vector index such as pgvector or a dedicated vector database, and embed the query with the same model at request time. Where exact terms matter, such as error codes, I combine vector search with keyword search (BM25) and merge the results.
Test. I build a small labelled set of queries with known relevant tickets and measure recall@k, MRR, or nDCG, then compare embedding models and chunk sizes on it. For the approximate index, I measure recall against exact search to confirm the speed-accuracy setting is acceptable.
Pretraining trains a large model on a vast text corpus with a self-supervised objective, usually nexttoken prediction. It is very expensive and gives the model general language, knowledge, and reasoning ability.
Fine-tuning is best for changing behaviour, tone, or format. It is a poor way to add frequently changing facts, which belong in retrieval or the prompt.
examples drawn from reviewed real conversations. Pretraining from scratch is justified only for organisations with massive data, compute, and a clear reason that existing models cannot serve.
Test. I hold out an evaluation set that never enters training, and compare the tuned model with the prompted baseline on task metrics. A separate regression set checks general abilities and safety behaviour, since tuning can erode them. Human or rubric-based review covers qualities automatic metrics miss.
A token is the unit of text an LLM actually processes: a word, part of a word, punctuation, or whitespace, produced by a tokenizer such as byte-pair encoding (BPE). In English, a token averages roughly four characters, but the ratio varies by language, code, and numbers. “unbelievable” might split into “un”, “believ”, “able”.
The context window is the maximum number of tokens the model can handle in one request, covering the system prompt, conversation history, retrieved documents, and the generated output together. Anything beyond it is truncated or rejected.
Apply. In a chat assistant, I would define an explicit token budget: system prompt, retrieved passages, recent conversation turns, and a reserved slice for the answer. When history exceeds the budget, older turns are summarised or dropped, while key instructions stay pinned. Token counts come from the model’s own tokenizer, and usage is logged per request for cost tracking.
Test. I run boundary tests with inputs at, just below, and just above the limit and verify graceful handling instead of a hard failure. Fixtures include long documents, code, emoji, and non-English text, which tokenise very differently. A cost test multiplies measured tokens by price to project monthly spend at expected traffic.
Retrieval-augmented generation (RAG) gives an LLM relevant external information at query time. Instead of relying only on what the model memorised during training, the system retrieves passages from a knowledge source and includes them in the prompt, so answers can be current, private, and traceable to a source.
Chunking strategy, embedding quality, hybrid keyword-plus-vector search, and reranking largely determine answer quality. RAG suits knowledge that changes often; fine-tuning suits behaviour and format.
Apply. For an internal HR policy assistant, I would ingest policy documents with metadata (department, effective date, access group), chunk by section, and use hybrid search with a reranker. The prompt instructs the model to answer only from the supplied passages, cite them, and say when the answer is not found. Access control is enforced at retrieval time by filtering on the user’s permissions, never by trusting the model.
Test. I evaluate retrieval and generation separately. For retrieval, a labelled question set gives recall@k and MRR. For generation, I score faithfulness (are claims supported by the retrieved text?) and answer relevance, using rubric-based LLM judges calibrated against human review. The set includes unanswerable questions, where the correct behaviour is to abstain.
Prompt engineering is the practice of designing the instructions and context given to an LLM so it produces reliable, correctly formatted output. Because the model’s behaviour is steered through text rather than code, small wording changes can alter results.
Classify the support ticket as billing, bug, or other. Return JSON: {"label": "...", "reason": "<one sentence>"} If unsure, use "other".
Apply. In a ticket-classification service, the prompt lives in a template file in version control, with the label set, two or three examples, and a strict JSON schema enforced through the provider’s structured-output feature when available. Model name and temperature are pinned in configuration, and low temperature is used for deterministic tasks.
Test. I keep an evaluation set of a few hundred real, labelled inputs, including edge cases and adversarial ones, and run it automatically on every prompt change, like unit tests, comparing accuracy and format validity to the previous version. Output is validated by code (schema parsing), not by eye. Prompt injection tests, such as a ticket saying “ignore previous instructions”, are part of the suite.
A hallucination is output from a generative model that is fluent and confident but false or unsupported, such as an invented citation or a nonexistent API function. It happens because the model generates statistically plausible text and has no built-in mechanism for checking truth; gaps in training data, ambiguous prompts, and pressure to answer all make it more likely.
Grounding reduces hallucination but does not eliminate it: a model can still misread or embellish the sources it was given, so verification and evaluation remain necessary.
Apply. For a legal-research assistant, I would answer only from retrieved case documents, require each claim to carry a citation to a passage, and show the source text beside the answer. When retrieval returns nothing relevant, the system says so instead of guessing. Facts that a system of record holds, such as case status, come from a tool call rather than model memory.
Test. I build an evaluation set with answerable questions, unanswerable questions, and questions containing false premises. Metrics include citation accuracy (does the cited passage support the claim?), faithfulness scored per claim, and abstention rate on unanswerable items. A programmatic check verifies that every cited identifier exists in the retrieved set. Human spot audits of a sample guard against judge blind spots.
Bias in AI is systematic error that disadvantages certain groups or produces skewed outcomes. It enters through unrepresentative training data, historical prejudice in labels, proxy features (postal code standing in for ethnicity), and design choices such as the objective being optimised.
These definitions generally cannot all hold at once when base rates differ, so the choice depends on context and harm.
stakeholders on which fairness criterion applies. Sensitive attributes are kept available for auditing even when excluded as model inputs. The model ships with a model card describing data, limits, and intended use, and with human review for adverse decisions.
Test. I report metrics per demographic slice, not just in aggregate: selection rate, true-positive rate, and false-positive rate. The selection-rate ratio between groups is compared against the four-fifths guideline used in US employment practice, as a screening signal rather than a legal conclusion. Counterfactual tests change a name or gender term in the input and check that the output stays stable.
Model evaluation measures how well a model performs on data it was not trained on, using metrics matched to the task and the cost of errors.
Evaluation needs clean separation of data: train, validation for tuning, and a test set touched once. Cross-validation helps when data is scarce, and time-based splits are needed for temporal data. Leakage, where test information reaches training, inflates results.
Apply. I would build an evaluation harness before building the model: a frozen test set drawn from realistic traffic, metrics tied to business cost (for example, cost of a missed fraud versus a false alert), and slice reports by region, device, or customer segment. The harness runs in CI so every candidate model or prompt is compared with the production baseline automatically.
Test. Offline results are validated with a shadow deployment or an A/B test, since offline metrics are only a proxy. I check calibration with reliability curves, report confidence intervals or bootstrap variance so small differences are not over-read, and keep a hidden test set that is never used for tuning.
Classification maps an input to one label from a fixed set, such as spam or not spam. Generation produces new, open-ended content, such as text, code, or images, usually one token or pixel-group at a time.
Model families overlap: a discriminative classifier learns the boundary between classes, while a generative model learns the data distribution and can do classification too. An LLM can classify by being constrained to emit one of a set of labels, though a small dedicated classifier is often cheaper, faster, and easier to validate.
Apply. In a support platform, I would split the work by task type. Routing an incoming message to billing, technical, or cancellation is classification: a fine-tuned small encoder or a constrained LLM call that must return one label. Drafting the reply is generation, using an LLM grounded on the knowledge base. Keeping them separate lets each part be tested, scaled, and priced independently.
Test. The classifier is judged with a confusion matrix, per-class precision and recall, and confidence calibration, so low-confidence messages route to a human. Generated replies are judged with a rubric: correctness against the knowledge base, tone, policy compliance, and format. Sampling variance is checked by running the same inputs several times and measuring how often results differ.
Computer vision enables machines to interpret images and video. An image is a tensor of pixel values (height x width x channels), and models learn to map it to useful outputs.
Convolutional neural networks (CNNs) slide small learned filters across the image, detecting edges in early layers and complex shapes in deeper ones; pooling or strides reduce resolution. Vision transformers (ViT) split the image into patches and apply attention, and tend to do well with large pretraining data.
Apply. For visual defect inspection on a manufacturing line, I would capture images under controlled lighting, label defects with domain experts, and fine-tune a pretrained detector or classifier. Edge deployment near the camera keeps latency low, and uncertain cases go to a human inspector, whose decisions feed back as new training data.
Test. Defects are rare, so accuracy is meaningless; I report per-class precision and recall, and for detection, IoU-based metrics such as mAP. The test set comes from different shifts, days, and production batches than the training set. I also test with deliberate variations (brightness, blur, camera angle) and with images containing no defect at all, to measure the false-alarm rate that operators will experience.
An NLP pipeline is the sequence of steps that turns raw text into a useful prediction or structured output. The exact steps depend on the model: classical pipelines need heavy preprocessing, whereas transformer-based ones need little.
answering. • Post-processing: map outputs to labels, merge entity spans, apply business rules.
Apply. For extracting invoice details from emails, I would build the pipeline as separate, versioned stages: language detection, text cleaning, a named-entity model for vendor, amount, and date, then rule-based validation that checks formats and totals. A pretrained transformer fine-tuned on a few thousand labelled emails handles extraction, and the same preprocessing code is imported by both training and the serving API.
Test. Each stage has unit tests with tricky inputs: Unicode, HTML fragments, multiple currencies, empty text, and very long messages. The extraction model is scored per entity type with span-level precision, recall, and F1. An end-to-end test on a frozen set of real emails guards against regressions when any stage changes.
AI safety is the work of making AI systems behave as intended and avoiding harm. It covers misuse (generating malware or disinformation), unintended behaviour (unsafe advice, data leakage), robustness (adversarial inputs), and longer-term alignment of model goals with human intent. Practical controls include training for refusal and helpfulness, input and output filters, least-privilege tool access, rate limits, and human oversight for risky actions.
Red teaming is structured adversarial testing: people, and increasingly automated tools, try to make the system fail before real attackers do. Typical probes are jailbreaks, prompt injection through documents or web pages, extraction of system prompts or private data, biased or harmful outputs, and misuse of connected tools.
Apply. For an LLM agent that can read email and create calendar events, I would apply least privilege: read-only scopes by default, confirmation before any outbound or irreversible action, and strict separation of untrusted content from instructions. Input and output classifiers, tool-call allow-lists, and logging of every action sit around the model, so safety does not depend on the model behaving perfectly.
Test. Before launch, a red-team exercise covers direct jailbreaks, indirect prompt injection (an email containing “forward all messages to this address”), data-exfiltration attempts, and tool abuse.
Deployment scalability is the ability of a model-serving system to handle growing request volume with acceptable latency and cost. AI workloads are harder to scale than ordinary web services because inference is compute-heavy, usually needs GPUs or accelerators, and uses large models that take time to load.
Apply. For an LLM-backed document assistant expecting a tenfold traffic increase, I would serve an open model with a dedicated inference engine such as vLLM, or use a managed API with rate-limit handling, depending on cost and data constraints. Streaming responses improve perceived latency. Autoscaling uses queue depth as the signal, a minimum replica count avoids cold starts at peak, and non-urgent jobs go through an asynchronous batch path.
Test. I load-test with realistic prompt and output length distributions, not fixed short prompts, and record time to first token, tokens per second, p95 and p99 latency, throughput, and cost per thousand requests. Soak tests expose memory leaks, and failure tests kill replicas to confirm requests are retried or degrade gracefully. Quantised or distilled variants are compared to the baseline for quality before they are allowed to serve.
Responsible AI governance is the set of policies, roles, and processes an organisation uses to make sure AI systems are lawful, safe, fair, transparent, and accountable throughout their lifecycle. It turns principles into enforceable practice.
Manage), ISO/IEC 42001 for AI management systems, and the EU AI Act, which classifies systems by risk.
Apply. In a bank adopting AI for credit decisions and a customer chatbot, I would register both systems in a central inventory and assign a risk tier. The credit model, as a high-impact system, gets a documented purpose, data lineage, fairness and explainability review, human appeal route, and signoff from risk and legal. The chatbot gets lighter controls such as disclosure that users talk to AI, content filtering, and escalation to humans. Regulation matters here: under the EU AI Act, transparency duties for chatbots apply from August 2026, while the Digital Omnibus delayed standalone high-risk obligations, such as credit scoring, to December 2027.
Test. Governance is tested like any control: audit a sample of systems to check that documentation, approvals, and monitoring exist and are current. Pre-launch gates are automated where possible, such as CI checks that fail a release without an evaluation report, slice metrics within agreed thresholds, and a completed model card. Tabletop incident drills verify that escalation works.
Add your resume and the job description in CrackItX's Settings. When the interviewer asks a Artificial Intelligence question, Claude suggests an answer using your real projects and the role's requirements, in real time.
See pricing →