Practice
- 1 How Would You Reduce Hallucinations?Free "Our support assistant sometimes makes things up: refund timelines, plan features, even links. Users act on these answers. How would you reduce hallucinations?"
- 2 Your RAG Answers Are Wrong: How Do You Debug It?Free "Our internal HR assistant uses RAG over the policy wiki. Employees report wrong answers, for example that contractors get the 2026 learning budget, which they don't. How would you debug this?"
- 3 How Would You Cut LLM Latency in Half?Free "Our RAG chat assistant takes about 3 seconds before the first word appears and up to 12 seconds to finish. Product wants it twice as fast. How would you do it?"
- 4 How Would You Cut LLM Cost by 10x?Free "Our AI support assistant costs about $120,000 a month in model API fees and usage keeps growing. Finance wants it cut by 10x without users noticing. How would you approach it?"
- 5 Your Agent Is Stuck in a Loop: What Do You Do?Free · sign up "In production, some runs of our support agent never finish: it keeps calling the same search tool until it times out after 40 steps. What's going on, and what do you do?"
- 6 How Many GPUs Do You Need to Serve a 70B Model?Free · sign up "We want to self-host a 70B open model for our chat product. How many GPUs do we need?"
- 7 Your Training Loss Spiked: How Do You Find Out Why?Free · sign up "We're three days into a training run on 64 GPUs. Overnight the loss jumped from 2.1 to 6.8 at step 41,200. What do you do?"
- 8 How Do You Ship a Prompt Change Safely?Free · sign up "Your team wants to change the system prompt of a production assistant used by 200,000 people a day, to make answers friendlier. Last time a prompt change caused a spike in complaints. How would you ship this change safely?"
- 9 Implement Softmax and Cross-Entropy (Numerically Stable)Free · sign up Implement softmax(logits) and the mean cross-entropy loss cross_entropy(logits, targets) for a batch, using NumPy. logits has shape (N, C): one row of raw scores per example, one column per class. targets has shape (N,) with the correct class index for each row. Both functions must stay correct f...
- 10 Implement Multi-Head AttentionFree · sign up Implement the forward pass of causal multi-head self-attention in NumPy. Input x has shape (B, T, D): B sequences of T tokens with D features each. Given weight matrices Wq, Wk, Wv, Wo of shape (D, D) and a number of heads H that divides D, return an output of shape (B, T, D). Each token may atte...
- 11 Implement Top-k and Top-p SamplingFree · sign up Implement sample_next_token(logits, temperature, top_k, top_p) in NumPy. logits is a 1-D array of raw scores, one per vocabulary token. Apply temperature, then keep only the top_k highest-scoring tokens (0 means no limit), then keep the smallest set of the remaining tokens whose probabilities add...
- 12 Implement a BPE TokenizerFree · sign up Implement Byte Pair Encoding (BPE). Write train_bpe(word_counts, num_merges) that takes a dictionary of words and their frequencies and returns the ordered list of learned merges, where each merge joins the most frequent adjacent pair of symbols. Then write encode(word, merges) that splits a new ...
- 13 Implement a KV Cache for GenerationFree · sign up Add a KV cache to a causal self-attention layer. Write a KVCache that stores keys and values for one sequence, and an attend_step(x_new, cache, ...) that processes new tokens: the whole prompt at once (prefill), then one token at a time (decode). The outputs must equal those of full attention ove...
- 14 Implement Beam SearchFree · sign up Implement beam search decoding. You get a function next_log_probs(seq) that returns a dictionary of possible next tokens and their log probabilities given a sequence. Starting from a start token, return the highest-scoring complete sequence (ending in an end token) found with beam width W, within...
- 15 Implement Rotary Position Embeddings (RoPE)Free · sign up Implement rotary position embeddings (RoPE). Given query and key tensors of shape (T, head_dim) and their token positions, return rotated versions so that the attention score between a query and a key depends on how far apart they are, not on where they sit in the sequence. Use NumPy.
- 16 Implement a LoRA Linear LayerFree · sign up Implement a LoRA (low-rank adaptation) version of a linear layer. The original weight W and bias b are frozen. Add two small trainable matrices so the layer computes y = x·Wᵀ + b + (α/r)·x·Aᵀ·Bᵀ. Write the forward pass, the backward pass for A and B, and a function that merges the adapter back in...
- 17 Implement Vector Top-k Retrieval with Cosine SimilarityFree · sign up Implement top_k_cosine(query, docs, k) in NumPy. query is an embedding vector of length D and docs is an (N, D) matrix of document embeddings. Return the indices and cosine similarity scores of the k most similar documents, best first. It should be fast for N in the millions on one machine.
- 18 Implement a Text Chunker with OverlapFree · sign up Write a chunker for a RAG pipeline. Part 1: chunk_tokens(tokens, size, overlap) splits a list of tokens into windows of at most size tokens where consecutive windows share overlap tokens. Part 2: chunk_sentences(sentences, count_tokens, max_tokens, overlap_sentences) packs whole sentences into ch...
- 19 Implement a Minimal Agent Loop with Tool CallsFree · sign up Implement a minimal agent loop. You get a function model(messages) that returns either a final text answer or a list of tool calls (each with an id, a tool name and JSON arguments), and a dictionary of Python tools. Keep calling the model, run the tools it asks for, feed the results back, and ret...