<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Valenx</title>
    <description>The latest articles on DEV Community by Valenx (@valenx).</description>
    <link>https://dev.to/valenx</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4234431%2F95967249-f0e6-4da3-808c-b8cd5ac3509d.png</url>
      <title>DEV Community: Valenx</title>
      <link>https://dev.to/valenx</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/valenx"/>
    <language>en</language>
    <item>
      <title>Embeddings and Cosine Similarity: Explaining Semantic Search in an AI Engineer Interview</title>
      <dc:creator>Valenx</dc:creator>
      <pubDate>Fri, 27 Nov 2026 23:19:59 +0000</pubDate>
      <link>https://dev.to/valenx/embeddings-and-cosine-similarity-explaining-semantic-search-in-an-ai-engineer-interview-1fa9</link>
      <guid>https://dev.to/valenx/embeddings-and-cosine-similarity-explaining-semantic-search-in-an-ai-engineer-interview-1fa9</guid>
      <description>&lt;p&gt;When an interviewer asks how you would let an LLM call your APIs, your job is to explain how a model proposal becomes an authorized action and what happens when a step fails. For more practice, enter $0 to get the &lt;a href="https://valenx.org/go/free-aie30?utm_source=hashnode&amp;amp;utm_medium=article&amp;amp;utm_campaign=dp1127&amp;amp;utm_content=A18" rel="noopener noreferrer"&gt;free Top 30 AI Engineer Interview Questions PDF (13 pages, each with what the interviewer tests and the follow-up to expect)&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the interviewer is checking
&lt;/h2&gt;

&lt;p&gt;The interviewer wants to hear where the model's authority ends and where your application makes decisions. Start by tracing a single turn. The model returns either a final answer or a proposed call with a tool name and arguments. The application decides whether the call can run and feeds the outcome back into the conversation.&lt;/p&gt;

&lt;p&gt;Then explain what changes when a call can send a message or update a record. A well-formed request can still target a record the caller cannot access. An authorized request can still time out after the service has already made the change. Those cases tell the interviewer more about your design than a list of tool definitions.&lt;/p&gt;

&lt;h2&gt;
  
  
  A strong answer
&lt;/h2&gt;

&lt;p&gt;I’d give the model an allowlist of tools with descriptions and argument schemas. When it proposes a call, my application looks up the tool, validates the arguments, and checks the caller’s permissions for that action and resource. If the arguments are bad, I return a structured error so the model can correct the request within the step budget.&lt;/p&gt;

&lt;p&gt;For an action with side effects, I’d show the user what will change and wait for confirmation tied to that exact action. I’d recheck permissions before executing. Each call has a timeout, and writes carry an idempotency key that stays the same across retries of the same confirmed action. If a write times out and I can’t tell whether it succeeded, I check the operation status before deciding what to report or retry.&lt;/p&gt;

&lt;p&gt;I feed the result or error back to the model and log each step with its outcome and latency, keeping secrets out of the logs. The loop ends when the model gives a final answer or reaches the step limit. At the limit, I report what completed and flag anything still pending or uncertain.&lt;/p&gt;

&lt;h2&gt;
  
  
  Follow-ups to expect
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;What if the model invents a tool or omits a required field? Reject the call before execution. Return an error that identifies the unknown tool or invalid field. Count rejected proposals toward the step limit so repeated errors cannot keep the loop alive.&lt;/li&gt;
&lt;li&gt;What if the arguments pass validation but reference someone else’s record? Use the authenticated caller’s identity from the application context. Check access to the specific record before execution, even when the tool is on the allowlist.&lt;/li&gt;
&lt;li&gt;What if the user confirms one action and the model changes the arguments? Bind approval to the tool and the validated arguments shown to the user. If the target or another material detail changes, ask again before executing.&lt;/li&gt;
&lt;li&gt;What if a timeout happens after the service commits the write? Treat the outcome as unknown. Check a status endpoint if one exists. Retry only when the operation is safe to repeat, such as when the service honors the same idempotency key and deduplicates the write.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The weak answer
&lt;/h2&gt;

&lt;p&gt;A weak answer stops at dispatching the named function and passing its output back to the model. It leaves the interviewer guessing who checks access, what the user actually approved, and whether a retry can create a second write.&lt;/p&gt;

&lt;p&gt;A common mistake is to treat a timeout as evidence that nothing happened. Walk through the case where a service saves a record and the reply gets lost. Your explanation should make clear how the application distinguishes a confirmed failure from an outcome it still needs to reconcile.&lt;/p&gt;

&lt;h2&gt;
  
  
  A drill
&lt;/h2&gt;

&lt;p&gt;Practice with two tools. One reads a support ticket and the other adds a customer-visible reply. Give your initial answer aloud, then walk through these inputs in order.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The model leaves out the ticket ID. State what error it gets and whether any API call runs.&lt;/li&gt;
&lt;li&gt;The model supplies a ticket ID outside the caller’s account. Name the permission check that blocks the call.&lt;/li&gt;
&lt;li&gt;The user approves a reply and the write times out. Explain what you log, how you check whether the reply was posted, and what you tell the user if the step limit arrives first.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Keep practicing
&lt;/h2&gt;

&lt;p&gt;Repeat the drill until you can explain both a successful call and an uncertain write without losing track of what the user sees. For a broader set of interview drills, use &lt;a href="https://valenx.org/go/bf-aie?utm_source=hashnode&amp;amp;utm_medium=article&amp;amp;utm_campaign=dp1127&amp;amp;utm_content=A18" rel="noopener noreferrer"&gt;The 0 to 1 AI Engineer Interview Playbook (twenty chapters on RAG, agents, evals, fine-tuning and LLM system design), 30 percent off with code BF30 through Mon Nov 30&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Valenx Press. Practice material, no company affiliation, no interview promise.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>interview</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How Would You Evaluate an LLM Feature? The Eval Question in AI Engineer Interviews</title>
      <dc:creator>Valenx</dc:creator>
      <pubDate>Fri, 27 Nov 2026 23:17:56 +0000</pubDate>
      <link>https://dev.to/valenx/how-would-you-evaluate-an-llm-feature-the-eval-question-in-ai-engineer-interviews-44gf</link>
      <guid>https://dev.to/valenx/how-would-you-evaluate-an-llm-feature-the-eval-question-in-ai-engineer-interviews-44gf</guid>
      <description>&lt;p&gt;When an interviewer asks, “How do you know your LLM feature works?” your job is to explain how you would catch a bad change before users see it. Use the &lt;a href="https://valenx.org/go/free-aie?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=dp1127&amp;amp;utm_content=A15" rel="noopener noreferrer"&gt;free AI Engineer Interview Cheat Sheet (4 pages, 12 must-know questions with short model answers)&lt;/a&gt; to rehearse this and other questions. Enter $0 to get it free.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the interviewer is checking
&lt;/h2&gt;

&lt;p&gt;The interviewer wants to hear what counts as a failure, how you would detect it, and which failures would block a release. Start with one feature so you can make those decisions concrete.&lt;/p&gt;

&lt;p&gt;Suppose the feature drafts a support reply from a customer message and a policy excerpt. A fluent reply can still give the wrong deadline or promise a refund the policy does not authorize. An evaluation should catch both errors and tell you which case failed.&lt;/p&gt;

&lt;h2&gt;
  
  
  A strong answer
&lt;/h2&gt;

&lt;p&gt;“I’d start with a small golden set drawn from real support requests, with customer details removed. I’d keep the policy excerpt with each request and include common cases, ambiguous cases, and cases where the feature should ask a clarifying question. For each one, I’d write down what the reply must get right and what would make it fail.&lt;/p&gt;

&lt;p&gt;“I’d run deterministic checks first. I’d validate the response format and compare facts with a single expected value, like a deadline in a structured field. For qualities that need judgment, like whether the reply explains the next step clearly, I’d use a model grader with a rubric and examples of passing and failing replies. I’d have a person independently score a sample, including borderline cases, and use disagreements to refine the rubric.&lt;/p&gt;

&lt;p&gt;“I’d rerun the suite on every prompt or model change and compare results case by case with the current release. If a new version starts promising refunds it can’t authorize, I’d block it even if the average score goes up. I’d keep the failing case and rerun it after the fix.”&lt;/p&gt;

&lt;h2&gt;
  
  
  Follow-ups to expect
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;How big should the test set be? Start with a set small enough to review by hand that covers common inputs and costly failures. Add cases when you discover a new failure mode or a gap in coverage. If you tune prompts against the same examples repeatedly, keep a separate set for release checks.&lt;/li&gt;
&lt;li&gt;How do you handle subjective outputs? Score observable behaviors. For a support reply, ask whether it gives a specific next step and makes any uncertainty clear. Accept different wording that meets the same criteria. Have people review a sample of passes and failures, especially when the grader and reviewers disagree.&lt;/li&gt;
&lt;li&gt;What can go wrong with the model grader? In pairwise comparisons, it may favor whichever answer appears first. Swap the order and inspect judgments that flip. It may also reward longer answers that contain no extra useful information. Include concise passing examples during calibration and check whether added detail actually satisfies the rubric.&lt;/li&gt;
&lt;li&gt;What would you measure online? For support drafts, track how often agents accept, edit, or discard them. Review a sample of the edits so you can distinguish factual corrections from wording preferences. Acceptance measures what agents do with a draft. A separate review can check whether accepted drafts follow policy.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The weak answer
&lt;/h2&gt;

&lt;p&gt;“I tried a few prompts and it looked good” describes a smoke test. It leaves the interviewer guessing which inputs you chose, what you checked, and whether you would catch a regression after changing the prompt. You can build on that first pass by saving the inputs, defining expected behavior, and adding a case where the feature should decline to make a promise.&lt;/p&gt;

&lt;h2&gt;
  
  
  A drill
&lt;/h2&gt;

&lt;p&gt;Pick a feature you could explain without a diagram. Write six test cases, then practice answering aloud in 60 to 90 seconds.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For each case, write one requirement and one failure condition.&lt;/li&gt;
&lt;li&gt;Choose a fact or format rule you can check automatically and a quality criterion you would put in a grading rubric.&lt;/li&gt;
&lt;li&gt;Describe one disagreement a human reviewer might have with the grader and how you would resolve it.&lt;/li&gt;
&lt;li&gt;Imagine the new version improves five replies and introduces a serious policy error in the sixth. Explain your release decision and name the regression you would add to the release report.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Keep practicing
&lt;/h2&gt;

&lt;p&gt;Repeat the drill with a feature from your own work. When you describe the evaluation, name one case that would change your release decision. For more interview practice, use &lt;a href="https://valenx.org/go/bf-aie?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=dp1127&amp;amp;utm_content=A15" rel="noopener noreferrer"&gt;The 0 to 1 AI Engineer Interview Playbook (twenty chapters on RAG, agents, evals, fine-tuning and LLM system design), 30 percent off with code BF30 through Mon Nov 30&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Valenx Press. Practice material, no company affiliation, no interview promise.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>interview</category>
      <category>testing</category>
    </item>
    <item>
      <title>Bi-Encoder vs Cross-Encoder: The Reranking Question in AI Engineer Interviews</title>
      <dc:creator>Valenx</dc:creator>
      <pubDate>Fri, 27 Nov 2026 23:05:19 +0000</pubDate>
      <link>https://dev.to/valenx/bi-encoder-vs-cross-encoder-the-reranking-question-in-ai-engineer-interviews-30da</link>
      <guid>https://dev.to/valenx/bi-encoder-vs-cross-encoder-the-reranking-question-in-ai-engineer-interviews-30da</guid>
      <description>&lt;p&gt;The interviewer asks why you would add a reranker after vector search, and your job is to explain what the extra model call buys you. For more practice, get the &lt;a href="https://valenx.org/go/free-aie?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=dp1127&amp;amp;utm_content=A10" rel="noopener noreferrer"&gt;free AI Engineer Interview Cheat Sheet (4 pages, 12 must-know questions with short model answers)&lt;/a&gt; and enter $0.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the interviewer is checking
&lt;/h2&gt;

&lt;p&gt;Can you explain how the system searches a large corpus quickly and still puts the most relevant results near the top? A clear answer follows a query through both stages.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Retrieve. A bi-encoder embeds the query and each document separately. You can compute document embeddings ahead of time and put them in a vector index. At request time, you embed the query and search for nearby document vectors. Vector similarity is a proxy for relevance, and an approximate nearest neighbor index can also miss some of the closest vectors.&lt;/li&gt;
&lt;li&gt;Rerank. A cross-encoder reads the query and a candidate document together and scores the pair. It can account for how phrases relate across the query and document, including qualifiers that determine whether the document answers the question. Because the score depends on the pair, you need fresh model computation for each candidate. Doing that across the whole corpus is usually too slow for a live request.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A strong answer
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;I'd use the bi-encoder to find plausible candidates quickly and the cross-encoder to decide which ones should appear first. With the bi-encoder, I can embed and index documents before any query arrives. At request time I embed the query and look up nearby vectors. That gives me a shortlist, but a document can be close in embedding space because it's about the same topic while missing a condition the user asked for.&lt;/p&gt;

&lt;p&gt;I'd score each shortlisted document with a cross-encoder. It reads the query and document together, so it can give more weight to whether the document actually satisfies that condition. I'd only run it on the shortlist because scoring every query and document pair would exceed the latency budget.&lt;/p&gt;

&lt;p&gt;To choose the shortlist size, I'd sweep candidate counts on a labeled set of representative queries. I'd measure recall at k before reranking to see whether retrieval is finding the relevant documents. Then I'd compare mean reciprocal rank, or MRR, with and without reranking at the same final cutoff. MRR tells me how early the first relevant result appears. I'd pick a candidate count that gives a meaningful ranking improvement within the end-to-end tail latency budget. If retrieval misses a relevant document, the reranker has no chance to surface it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Follow-ups to expect
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;How would you set the candidate count? Look for where adding candidates yields little extra recall or final ranking improvement. Measure latency under representative load and with realistic document lengths. A wider shortlist gives the reranker more opportunities, but it also gives it more pairs to score.&lt;/li&gt;
&lt;li&gt;What if recall is high and MRR barely moves? Inspect queries where the relevant result starts low in the shortlist. Check whether the reranker promotes it, leaves it buried, or favors a plausible distractor. If the first relevant result already appears near the top for most queries, MRR has little room to improve.&lt;/li&gt;
&lt;li&gt;What if users need several relevant passages? Keep recall at the final cutoff alongside MRR. A system can place the first relevant passage near the top and still drop other passages the user needs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The weak answer
&lt;/h2&gt;

&lt;p&gt;A weak answer says vector search is fast and reranking makes it more accurate, then stops. That leaves the interviewer guessing what the cross-encoder reads, why it runs only after retrieval, and how you'd know if the extra work paid off. If you claim it fixes missed results, walk through a query where the relevant document never enters the shortlist.&lt;/p&gt;

&lt;h2&gt;
  
  
  A drill
&lt;/h2&gt;

&lt;p&gt;Use a query about refund rules for an unopened item. Write a candidate list with a general refund policy, a passage about opened items, and a passage that directly addresses unopened items. Mark relevance before you rank them.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Explain why the same-topic passages might appear high in vector search.&lt;/li&gt;
&lt;li&gt;Explain what the cross-encoder could use to put the directly relevant passage first.&lt;/li&gt;
&lt;li&gt;Remove that passage from the shortlist and say what happens to candidate recall and the reciprocal rank for that query.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Keep practicing
&lt;/h2&gt;

&lt;p&gt;Practice giving the answer aloud, then defend your candidate count when the interviewer tightens the latency budget. For more prompts, see &lt;a href="https://valenx.org/go/bf-aie?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=dp1127&amp;amp;utm_content=A10" rel="noopener noreferrer"&gt;The 0 to 1 AI Engineer Interview Playbook (twenty chapters on RAG, agents, evals, fine-tuning and LLM system design), 30 percent off with code BF30 through Mon Nov 30&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Valenx Press. Practice material, no company affiliation, no interview promise.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>interview</category>
      <category>search</category>
    </item>
    <item>
      <title>LoRA in an AI Engineer Interview: What the Low-Rank Update Actually Saves</title>
      <dc:creator>Valenx</dc:creator>
      <pubDate>Fri, 27 Nov 2026 23:01:21 +0000</pubDate>
      <link>https://dev.to/valenx/lora-in-an-ai-engineer-interview-what-the-low-rank-update-actually-saves-5egp</link>
      <guid>https://dev.to/valenx/lora-in-an-ai-engineer-interview-what-the-low-rank-update-actually-saves-5egp</guid>
      <description>&lt;p&gt;When an interviewer asks you to explain LoRA and when you would use it, the hard part is saying exactly what gets smaller during training and what you still need at inference. For more practice with that kind of distinction, get the &lt;a href="https://valenx.org/go/free-aie30?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=dp1127&amp;amp;utm_content=A09" rel="noopener noreferrer"&gt;free Top 30 AI Engineer Interview Questions PDF (13 pages, each with what the interviewer tests and the follow-up to expect)&lt;/a&gt; by entering $0.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the interviewer is checking
&lt;/h2&gt;

&lt;p&gt;Can you explain the update at one layer, then connect it to an engineering decision? Start with a weight matrix W in a layer you want to adapt. LoRA freezes W and learns two smaller matrices, A and B. Their product BA has the same shape as W and is added to W as a scaled update. The rank you choose sets an upper bound on the rank of that update.&lt;/p&gt;

&lt;p&gt;For a 4096 by 4096 weight matrix, full fine-tuning makes all 16,777,216 entries trainable. At rank 8, the two factors have shapes 8 by 4096 and 4096 by 8. Together they contain 65,536 trainable parameters, a factor of 256 fewer for that matrix. You still store the original weight. The savings come from computing and storing gradients and optimizer state for the factors, and from saving only the factors in an adapter checkpoint. Training also still uses memory for activations.&lt;/p&gt;

&lt;h2&gt;
  
  
  A strong answer
&lt;/h2&gt;

&lt;p&gt;I would use LoRA when I already have a capable base model and want to adapt it to a specific task with a limited training budget. I freeze the base weights and add a trainable low-rank update to selected layers. For each weight matrix I target, I learn two thin matrices whose product gives me an update of the right shape. A smaller rank means fewer trainable parameters and less optimizer state. It also gives the update less capacity, so I would pick the rank using validation results.&lt;/p&gt;

&lt;p&gt;If I need several task variants, I can keep one base model and load a different adapter for each task. Serving still requires the full base model. I can merge the update into the base weights for a fixed task, which folds the adapter computation into the original layer, or keep the adapter separate so I can swap it. If storing the frozen base is the training memory bottleneck, I would consider QLoRA. It trains LoRA adapters while keeping the frozen base weights quantized.&lt;/p&gt;

&lt;h2&gt;
  
  
  Follow-ups to expect
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Which layers would you target? Start with the attention projections as a baseline. If that run falls short, test adding adapters to the feed-forward projections. Hold the data and evaluation fixed so you can see whether broader coverage earns its extra cost.&lt;/li&gt;
&lt;li&gt;How would you choose rank? Compare a small set of ranks while keeping the target layers fixed. Look at held-out task performance and memory use. If a larger rank provides little gain, use the smaller one. If every rank struggles, check the data and layer choice before paying for more capacity.&lt;/li&gt;
&lt;li&gt;Does LoRA prevent catastrophic forgetting? The original weights remain intact, so disabling an unmerged adapter recovers the base model's behavior under the same serving settings. With the adapter enabled, performance on general tasks can still drop. Evaluate both the target task and any base capabilities your application depends on.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The weak answer
&lt;/h2&gt;

&lt;p&gt;LoRA makes the model smaller, so training and inference are both cheaper. That answer conflates trainable parameters with the weights needed to serve the model. An adapter checkpoint can be small because it depends on a compatible base checkpoint. At inference, a separate adapter adds computation to its target layers. Merging removes that separate computation, and the resulting weight matrices still have their original dimensions.&lt;/p&gt;

&lt;h2&gt;
  
  
  A drill
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Give the strong answer aloud in 90 seconds. Draw W, A, and B, and calculate the trainable parameter count for rank 8 without notes.&lt;/li&gt;
&lt;li&gt;Assume you need to serve three task variants on one base. Explain how keeping adapters separate lets you switch tasks and what serving with three merged variants would require you to store.&lt;/li&gt;
&lt;li&gt;Name one metric for the target task and one regression check for a general capability. Explain how those results would guide your choice of rank.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Keep practicing
&lt;/h2&gt;

&lt;p&gt;For more questions that ask you to defend a design choice under follow-up, see &lt;a href="https://valenx.org/go/bf-aie?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=dp1127&amp;amp;utm_content=A09" rel="noopener noreferrer"&gt;The 0 to 1 AI Engineer Interview Playbook (twenty chapters on RAG, agents, evals, fine-tuning and LLM system design), 30 percent off with code BF30 through Mon Nov 30&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Valenx Press. Practice material, no company affiliation, no interview promise.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>interview</category>
      <category>llm</category>
    </item>
    <item>
      <title>Temperature 0 Is Not a Determinism Switch: Answering Sampling Questions in AI Engineer Interviews</title>
      <dc:creator>Valenx</dc:creator>
      <pubDate>Fri, 27 Nov 2026 22:26:23 +0000</pubDate>
      <link>https://dev.to/valenx/temperature-0-is-not-a-determinism-switch-answering-sampling-questions-in-ai-engineer-interviews-9gm</link>
      <guid>https://dev.to/valenx/temperature-0-is-not-a-determinism-switch-answering-sampling-questions-in-ai-engineer-interviews-9gm</guid>
      <description>&lt;p&gt;You can define temperature, top-k, and top-p in an interview and still get stuck when the interviewer asks why a test failed at temperature 0. To practice that kind of follow-up, enter $0 for the &lt;a href="https://valenx.org/go/free-aie30?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=dp1127&amp;amp;utm_content=A03" rel="noopener noreferrer"&gt;free Top 30 AI Engineer Interview Questions PDF (13 pages, each with what the interviewer tests and the follow-up to expect)&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the interviewer is checking
&lt;/h2&gt;

&lt;p&gt;At each generation step, the model scores possible next tokens. The interviewer wants you to explain how each setting changes the distribution used to select that next token, then connect the setting to a product requirement.&lt;/p&gt;

&lt;p&gt;The harder part comes when you move from decoding to serving. An interview answer should explain both what greedy decoding does with a fixed set of scores and why repeated requests can produce slightly different scores in a production system.&lt;/p&gt;

&lt;h2&gt;
  
  
  A strong answer
&lt;/h2&gt;

&lt;p&gt;I think of temperature as changing how strongly the decoder favors the highest-scoring tokens. At positive temperatures, it divides the logits by the temperature before softmax. Lower temperature concentrates probability on the leading tokens, while higher temperature spreads it out. I'd lower it for a constrained task like extraction and raise it if I wanted more varied draft suggestions.&lt;/p&gt;

&lt;p&gt;Top-k keeps a fixed number of the highest-scoring tokens. I'd use it when I want a hard cap on how many choices the decoder considers at each step. Top-p keeps the smallest group of highest-probability tokens whose cumulative probability reaches the threshold. I'd use that when I want the number of choices to adapt. A clear favorite can leave a small pool, while a flatter distribution can leave a larger one. After filtering, the remaining probabilities are renormalized before sampling.&lt;/p&gt;

&lt;p&gt;Temperature 0 typically selects the highest-scoring token directly. That choice is deterministic given the same scores and tie-breaking rule. In a live service, batching can change how floating-point computations run, which can flip the order of two nearly tied tokens. Once one token changes, the next step has a different prefix. For tests, I'd check the output contract and run several generations to see whether the feature holds up across outputs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Follow-ups to expect
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Why can batching change the result for the same prompt? A request may run alone or alongside other requests. The batch shape can affect kernel selection or the order of floating-point operations. Because intermediate results are rounded, a different computation order can move scores enough to change which token wins a close contest.&lt;/li&gt;
&lt;li&gt;When would you choose top-k over top-p? Use top-k when the size of the candidate pool is the constraint. Use top-p when you want the pool to expand on ambiguous steps and shrink on obvious ones. If either filter leaves a single token, the decoder has only one choice at that step.&lt;/li&gt;
&lt;li&gt;How would you test a model that extracts fields from support tickets? Parse the response and validate the schema. Check that required fields exist, allowed labels are used, extracted values are supported by the ticket, and missing values follow the contract. Assert exact values for fields where the task requires them.&lt;/li&gt;
&lt;li&gt;What if the feature writes a summary? Define rubric checks for preserving the central claim, covering required facts, and avoiding unsupported additions. A model grader can apply that rubric with the source text in view. Review examples of its judgments against human assessments before relying on it. Run each test case several times and inspect where the outputs fail.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The weak answer
&lt;/h2&gt;

&lt;p&gt;A candidate says temperature 0 makes every call identical, top-k and top-p both make answers more creative, and a good regression test saves one response and compares every future response to it.&lt;/p&gt;

&lt;p&gt;That answer skips the difference between reshaping probabilities and filtering candidates. The regression test also treats a harmless wording change as a failure. If the feature promises a particular field value or a literal token required by a parser, assert it directly. For open-ended prose, assert the properties the user depends on.&lt;/p&gt;

&lt;h2&gt;
  
  
  A drill
&lt;/h2&gt;

&lt;p&gt;Use a prompt that turns a support ticket into structured fields and a short summary. Write down three assertions before generating anything.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The response parses and satisfies the schema.&lt;/li&gt;
&lt;li&gt;The priority label is allowed and any extracted identifiers appear in the ticket.&lt;/li&gt;
&lt;li&gt;The summary names the problem without adding an unsupported cause.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Run the prompt several times at temperature 0, then try a positive temperature. Evaluate each output against the same assertions. Practice explaining how two differently worded summaries can both pass, and identify one plausible response that should fail.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep practicing
&lt;/h2&gt;

&lt;p&gt;Rehearse the strong answer aloud, then have a partner interrupt with one of the follow-ups. For more practice, see &lt;a href="https://valenx.org/go/bf-aie?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=dp1127&amp;amp;utm_content=A03" rel="noopener noreferrer"&gt;The 0 to 1 AI Engineer Interview Playbook (twenty chapters on RAG, agents, evals, fine-tuning and LLM system design), 30 percent off with code BF30 through Mon Nov 30&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Valenx Press. Practice material, no company affiliation, no interview promise.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>interview</category>
      <category>testing</category>
    </item>
    <item>
      <title>Exact vs Approximate Nearest Neighbor: How to Explain Vector Search in an AI Engineer Interview</title>
      <dc:creator>Valenx</dc:creator>
      <pubDate>Fri, 27 Nov 2026 22:25:02 +0000</pubDate>
      <link>https://dev.to/valenx/exact-vs-approximate-nearest-neighbor-how-to-explain-vector-search-in-an-ai-engineer-interview-1p3g</link>
      <guid>https://dev.to/valenx/exact-vs-approximate-nearest-neighbor-how-to-explain-vector-search-in-an-ai-engineer-interview-1p3g</guid>
      <description>&lt;p&gt;When an interviewer asks how a vector database finds similar documents, the hard part is explaining how it goes from a query to a ranked list and what it gives up to do that quickly. Practice that explanation with the &lt;a href="https://valenx.org/go/free-aie?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=dp1127&amp;amp;utm_content=A02" rel="noopener noreferrer"&gt;free AI Engineer Interview Cheat Sheet (4 pages, 12 must-know questions with short model answers)&lt;/a&gt;, available by entering $0.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the interviewer is checking
&lt;/h2&gt;

&lt;p&gt;The question is usually some version of “How does a vector database find documents similar to a query?” Walk through what you store, how you score it, and how the database decides which vectors to score. Those are three separate decisions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The embedding model maps text to a vector. You might store one vector per document or one per chunk.&lt;/li&gt;
&lt;li&gt;The similarity metric determines the ranking for any set of vectors you score.&lt;/li&gt;
&lt;li&gt;The index determines how much of the collection you need to examine to get a useful ranking.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A strong answer
&lt;/h2&gt;

&lt;p&gt;I embed each document chunk ahead of time and embed the query at search time. Both embeddings need to come from the same model, or from query and document encoders trained to share a space. Then I rank chunks by similarity to the query vector.&lt;/p&gt;

&lt;p&gt;Cosine similarity compares direction. Dot product also reflects vector magnitude. If I normalize both query and document vectors to unit length, dot product equals cosine similarity, so either gives the same ranking.&lt;/p&gt;

&lt;p&gt;With a flat exact search, I score every eligible vector. Any vector I skip could have a higher score, so a full scan gives me the true top k for that metric. With approximate search, I examine fewer vectors. HNSW follows links in a graph toward promising neighbors. IVF groups vectors into lists and probes the lists whose centroids are closest to the query.&lt;/p&gt;

&lt;p&gt;Both can return results faster while missing some true neighbors. HNSW uses extra memory for graph links. Plain IVF stores centroids and list assignments alongside the vectors, and some IVF configurations compress the vectors to save memory. I tune how broadly the index searches and measure what that does to latency and recall.&lt;/p&gt;

&lt;p&gt;I also account for filters like tenant or language. Filtering the returned candidates can leave me with fewer than k results. If I switch to a different embedding model, I re-embed the corpus and rebuild the index. Equal dimensions alone tell me nothing about whether the two models share a coordinate space.&lt;/p&gt;

&lt;h2&gt;
  
  
  Follow-ups to expect
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;How do you measure ANN recall? Run representative queries against a flat exact search and the approximate index using the same corpus, similarity metric, and filters. For each query, divide the number of exact top k results that also appear in the approximate top k by the number of results in the exact set. Average across queries. That measures how closely the index matches exact search. Human relevance labels answer a different question about whether either result set is useful.&lt;/li&gt;
&lt;li&gt;When would keyword search beat vectors? When the literal token carries the intent. If someone enters a product code or an invoice ID, the exact identifier matters more than semantic similarity. Use an exact field lookup when the input is a known identifier. Keyword search helps when that identifier appears inside a longer query or document.&lt;/li&gt;
&lt;li&gt;What if a metadata filter matches very few records? If you search first and filter afterward, the nearest candidates may all be ineligible. You can increase the candidate pool, use an index that applies the filter during search, or scan the eligible subset exactly when it is small enough.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The weak answer
&lt;/h2&gt;

&lt;p&gt;A weak answer says the database embeds the query, uses cosine similarity, and returns the closest documents. That leaves out the step the interviewer is asking about. Cosine gives you a score once you have two vectors. It leaves open whether the database scores the whole collection or uses an index to find candidates.&lt;/p&gt;

&lt;p&gt;If you mention an approximate index, say what it can miss and how you would check. If you say it saves memory, name the configuration that does so. Skipping distance calculations and storing fewer bytes are separate things.&lt;/p&gt;

&lt;h2&gt;
  
  
  A drill
&lt;/h2&gt;

&lt;p&gt;Give yourself 90 seconds to explain how a search for a troubleshooting guide runs from query embedding to ranked results. Then add three constraints, one at a time.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The query contains a product code that differs from another valid code by one character.&lt;/li&gt;
&lt;li&gt;The result must belong to a tenant with very few documents.&lt;/li&gt;
&lt;li&gt;The team wants to replace its embedding model.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For each constraint, name the change you would make and how you would verify that it worked.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep practicing
&lt;/h2&gt;

&lt;p&gt;Once you can explain which vectors get scored and why, practice the follow-up about what can go wrong in production. For more prompts, see &lt;a href="https://valenx.org/go/bf-aie?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=dp1127&amp;amp;utm_content=A02" rel="noopener noreferrer"&gt;The 0 to 1 AI Engineer Interview Playbook (twenty chapters on RAG, agents, evals, fine-tuning and LLM system design), 30 percent off with code BF30 through Mon Nov 30&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Valenx Press. Practice material, no company affiliation, no interview promise.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>machinelearning</category>
      <category>interview</category>
      <category>database</category>
    </item>
    <item>
      <title>Why Your LLM Cannot Count the Letters in a Word: The Tokenization Interview Question</title>
      <dc:creator>Valenx</dc:creator>
      <pubDate>Fri, 27 Nov 2026 22:23:40 +0000</pubDate>
      <link>https://dev.to/valenx/why-your-llm-cannot-count-the-letters-in-a-word-the-tokenization-interview-question-4mip</link>
      <guid>https://dev.to/valenx/why-your-llm-cannot-count-the-letters-in-a-word-the-tokenization-interview-question-4mip</guid>
      <description>&lt;p&gt;You can define tokenization in an interview and still get stuck when asked why a model miscounts letters in an ordinary word. To practice that jump from definition to explanation, grab the &lt;a href="https://valenx.org/go/free-aie30?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=dp1127&amp;amp;utm_content=A01" rel="noopener noreferrer"&gt;free Top 30 AI Engineer Interview Questions PDF (13 pages, each with what the interviewer tests and the follow-up to expect)&lt;/a&gt; and enter $0.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the interviewer is checking
&lt;/h2&gt;

&lt;p&gt;The interviewer wants to hear what the model receives and what that representation means for your application. A tokenizer converts text into a sequence of integer IDs. Each ID identifies an entry in the tokenizer's vocabulary. A token can represent a whole word, part of a word, punctuation, whitespace, or even part of a character's byte encoding.&lt;/p&gt;

&lt;p&gt;Subword tokenizers let common patterns fit into a compact sequence while keeping smaller pieces available for unfamiliar text. Two common approaches build those pieces differently.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Byte pair encoding, or BPE, starts with small units and learns merges from pairs that occur frequently in the training text. At encoding time, it applies the learned merge rules.&lt;/li&gt;
&lt;li&gt;A unigram tokenizer starts with many candidate pieces and prunes them during training. At encoding time, it can score possible splits and select the most likely one under its learned piece probabilities.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A strong answer
&lt;/h2&gt;

&lt;p&gt;Tokenization is how we turn text into the sequence of IDs a language model processes. The vocabulary usually has pieces of different sizes, so a familiar word can fit into one token and an unfamiliar one can take several. BPE learns which neighboring pieces to merge. A unigram tokenizer learns probabilities for candidate pieces and uses them to choose a split.&lt;/p&gt;

&lt;p&gt;That matters for tasks where the unit I care about differs from the model's unit. If I ask for the number of letter r's in strawberry, the model may have to reason about letters inside a token. Long numbers can be split into digit groups that don't line up with the columns needed for arithmetic. Even a leading space can change the token sequence because some vocabulary entries include a space.&lt;/p&gt;

&lt;p&gt;It also matters when I ship an application. More input tokens consume more of the context window and can increase prompt processing time. More generated tokens usually mean a longer wait. If the service bills by tokens, the counts affect the bill too. I'd measure with the target model's tokenizer, and I'd use deterministic code whenever the task needs an exact letter count or arithmetic result.&lt;/p&gt;

&lt;h2&gt;
  
  
  Follow-ups to expect
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;How would you count tokens before sending a request? Use the target model's tokenizer or its token counting endpoint when available. Count the complete input, including system instructions, chat history, retrieved text, and tool definitions. If you count locally, account for message formatting and special tokens as far as the provider documents them. Reserve room for the expected output within the context limit, then compare your estimate with the usage reported by the API.&lt;/li&gt;
&lt;li&gt;Why does the same text cost different amounts on different models? There are two variables. Different vocabularies and encoding rules can produce different token counts. Models can also charge different rates per token, with separate rates for input and output. Compare both the count and the applicable price before making a cost estimate.&lt;/li&gt;
&lt;li&gt;Why might a non-English prompt use more tokens? If a tokenizer's training data favored English, its vocabulary may cover common English words and fragments with larger pieces. Text in a less represented language or script can break into smaller pieces, sometimes down to bytes. The difference depends on the language, the text, and the tokenizer. Measure equivalent requests in the languages your application serves.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The weak answer
&lt;/h2&gt;

&lt;p&gt;Saying that tokenization splits text into words leaves you unable to explain why adding a space can change the count or why two models disagree on the same request. Bringing up a fixed characters-per-token ratio has the same problem. Such a ratio can give you a rough estimate for similar text, but it can miss the budget on code, numbers, or multilingual input.&lt;/p&gt;

&lt;h2&gt;
  
  
  A drill
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Inspect the token boundaries for &lt;code&gt;strawberry&lt;/code&gt; and &lt;code&gt;strawberry&lt;/code&gt; with a tokenizer you use. Count the r's separately, then explain why counting tokens cannot give you that answer.&lt;/li&gt;
&lt;li&gt;Type a 20-digit number without separators, then the same number with commas, and inspect both. Compare the token boundaries with the place values you'd use for addition.&lt;/li&gt;
&lt;li&gt;Count equivalent requests in two languages on two models. Then give the strong answer aloud in 60 to 90 seconds and name one engineering decision those counts would change.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Keep practicing
&lt;/h2&gt;

&lt;p&gt;For more practice connecting interview concepts to system design decisions, see &lt;a href="https://valenx.org/go/bf-aie?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=dp1127&amp;amp;utm_content=A01" rel="noopener noreferrer"&gt;The 0 to 1 AI Engineer Interview Playbook (twenty chapters on RAG, agents, evals, fine-tuning and LLM system design), 30 percent off with code BF30 through Mon Nov 30&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Valenx Press. Practice material, no company affiliation, no interview promise.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>interview</category>
      <category>career</category>
    </item>
    <item>
      <title>Debugging a RAG app in an interview: split retrieval from generation</title>
      <dc:creator>Valenx</dc:creator>
      <pubDate>Fri, 27 Nov 2026 20:54:17 +0000</pubDate>
      <link>https://dev.to/valenx/debugging-a-rag-app-in-an-interview-split-retrieval-from-generation-4plf</link>
      <guid>https://dev.to/valenx/debugging-a-rag-app-in-an-interview-split-retrieval-from-generation-4plf</guid>
      <description>&lt;p&gt;"How would you build a RAG pipeline?" is the most common AI engineer design question. The usual answer lists parts: vector DB, embeddings, LLM. The step that gets skipped is the one that makes it work: the retrieved passages have to go into the prompt, with the question, before the model answers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Say the full path in order
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;1. Ingest and clean documents, then split into chunks (a few hundred tokens with overlap is a fine start).&lt;/li&gt;
&lt;li&gt;2. Embed chunks and index them. Add keyword search (BM25) for exact terms like product codes.&lt;/li&gt;
&lt;li&gt;3. At query time: retrieve candidates (hybrid), rerank, keep the top few.&lt;/li&gt;
&lt;li&gt;4. Assemble the prompt: instructions + retrieved passages + the question. Ask for citations and allow "not enough information".&lt;/li&gt;
&lt;li&gt;5. Evaluate retrieval (was the right chunk retrieved?) separately from generation (did the answer use it faithfully?).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The follow-up: "Your RAG app gives wrong answers. How do you debug it?" Split it. If the right chunk was not retrieved, fix chunking, embeddings, hybrid search or filters. If it was, fix the prompt, the context noise or the model.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;gold_chunk_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;gold_answer&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;eval_set&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;hits&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;retrieve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;retrieval_ok&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;gold_chunk_id&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;h&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;hits&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;answer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;generate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hits&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;record&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;retrieval_ok&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;faithful&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;answer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;hits&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;correct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;answer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;gold_answer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;90-second drill: say steps 1-5 out loud without notes, then answer the debug follow-up.&lt;/p&gt;

&lt;p&gt;12 must-know questions with model answers, free cheat sheet → &lt;a href="https://valenx.org/go/free-aie?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=dp1127&amp;amp;utm_content=D02" rel="noopener noreferrer"&gt;https://valenx.org/go/free-aie?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=dp1127&amp;amp;utm_content=D02&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Valenx Press. Practice material, no interview promise.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>career</category>
      <category>interview</category>
      <category>llm</category>
    </item>
    <item>
      <title>Estimate the KV cache before your interviewer asks</title>
      <dc:creator>Valenx</dc:creator>
      <pubDate>Fri, 27 Nov 2026 20:53:55 +0000</pubDate>
      <link>https://dev.to/valenx/estimate-the-kv-cache-before-your-interviewer-asks-5fc</link>
      <guid>https://dev.to/valenx/estimate-the-kv-cache-before-your-interviewer-asks-5fc</guid>
      <description>&lt;p&gt;Most AI engineer loops now include some version of "How much memory does the KV cache need?" Candidates who only define it get a polite nod. Candidates who estimate it get the next question.&lt;/p&gt;

&lt;p&gt;What it is (one sentence): the KV cache stores the attention keys and values of every token already processed, so each new token does not recompute the whole prefix.&lt;/p&gt;

&lt;h3&gt;
  
  
  The estimate, said out loud
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Per token = 2 (K and V) × layers × KV heads × head dim × bytes.&lt;/li&gt;
&lt;li&gt;For a model with 32 layers, 8 KV heads, head dim 128, 16-bit values: 2 × 32 × 8 × 128 × 2 = 131,072 bytes = 128 KiB per token.&lt;/li&gt;
&lt;li&gt;One 8k-token request: 8,192 × 128 KiB ≈ 1 GiB. Ten concurrent requests ≈ 10 GiB on top of the weights.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;layers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;kv_heads&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;head_dim&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bytes_per&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;128&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
&lt;span class="n"&gt;per_token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;layers&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;kv_heads&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;head_dim&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;bytes_per&lt;/span&gt;   &lt;span class="c1"&gt;# 131072 bytes = 128 KiB&lt;/span&gt;
&lt;span class="n"&gt;per_8k&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;per_token&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;8192&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;**&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;                           &lt;span class="c1"&gt;# ~1.0 GiB per request&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;per_token&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;per_8k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The follow-up they are waiting for
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Why only 8 KV heads? Grouped-query attention shares K/V across query heads and shrinks the cache.&lt;/li&gt;
&lt;li&gt;Prefill vs decode: prefill processes the prompt in parallel and sets time to first token (compute bound). Decode makes one token per step and is limited by memory bandwidth.&lt;/li&gt;
&lt;li&gt;How do you serve more users? Paged KV cache, quantized KV, shorter contexts, prefix caching.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;90-second drill: cover this page, say the formula, plug in the numbers, then name one way to cut the cache. Score yourself 1 to 5.&lt;/p&gt;

&lt;p&gt;29 more questions in this format (what's tested, 4-step frame, follow-up): free Top 30 PDF → &lt;a href="https://valenx.org/go/free-aie30?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=dp1127&amp;amp;utm_content=D01" rel="noopener noreferrer"&gt;https://valenx.org/go/free-aie30?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=dp1127&amp;amp;utm_content=D01&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Valenx Press. Practice material. No company affiliation, no interview promise.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>career</category>
      <category>interview</category>
      <category>llm</category>
    </item>
    <item>
      <title>Zero-shot vs few-shot prompting: when do you use each?</title>
      <dc:creator>Valenx</dc:creator>
      <pubDate>Thu, 12 Nov 2026 20:06:56 +0000</pubDate>
      <link>https://dev.to/valenx/zero-shot-vs-few-shot-prompting-when-do-you-use-each-4deh</link>
      <guid>https://dev.to/valenx/zero-shot-vs-few-shot-prompting-when-do-you-use-each-4deh</guid>
      <description>&lt;h2&gt;
  
  
  What the interviewer is testing
&lt;/h2&gt;

&lt;p&gt;Whether you know when zero-shot is enough, can identify cases that need few-shot examples, and can design balanced examples without copying surface patterns into the output.&lt;/p&gt;

&lt;h2&gt;
  
  
  Answer framework
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Zero-shot prompting: give the instruction and any needed context without demonstrations.&lt;/li&gt;
&lt;li&gt;Few-shot prompting: include several labeled input and output examples in the prompt.&lt;/li&gt;
&lt;li&gt;Use zero-shot for common tasks with simple formats and little ambiguity.&lt;/li&gt;
&lt;li&gt;Use few-shot for unusual formats, subtle labels, or strict style and output consistency.&lt;/li&gt;
&lt;li&gt;Choose balanced, varied examples that cover hard cases, since models can copy their surface patterns.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sample answer
&lt;/h2&gt;

&lt;p&gt;I start by thinking about how much structure the task needs. For a common task with a simple format, I use zero-shot prompting: I describe the task and give any necessary context, but no demonstrations. That is quicker to maintain and avoids spending context window space on examples. If the model already understands the labels and the expected output is easy to recognize, zero-shot is usually the cleaner choice.&lt;/p&gt;

&lt;p&gt;I switch to few-shot prompting when the format is unusual, the labels are subtle, or I need consistent style. I put a few input and output examples directly in the prompt, usually with a clear separation between examples and the final query. I select examples that cover the hard cases, vary the inputs, and make the labels balanced. I also test whether the examples are actually changing behavior, rather than assuming that more examples always help.&lt;/p&gt;

&lt;p&gt;I see one failure mode as surface-pattern copying. If every example has a positive label, the model may treat positive as the default, even when the input calls for another label. I would catch that with a small set of edge cases, including examples with the opposite label, and adjust the examples if needed. In short, I use zero-shot for straightforward tasks and few-shot when examples communicate the missing pattern. I also treat examples as data that needs evaluation, not as decoration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Likely follow-ups
&lt;/h2&gt;

&lt;p&gt;When is few-shot prompting not worth the extra tokens? I would use zero-shot when the task is straightforward, the model already understands the format, and added examples would mainly increase cost and latency.&lt;/p&gt;

&lt;p&gt;How should I choose few-shot examples? I would cover hard cases, vary the inputs, balance the labels, and check that surface details in the examples are not driving the outputs.&lt;/p&gt;

&lt;p&gt;What if every few-shot example has the same label? I would rebalance the examples and include the opposite label, then test edge cases because the model may treat the repeated label as the default.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common mistakes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Using zero-shot for an unusual format or subtle labels without testing the model first.&lt;/li&gt;
&lt;li&gt;Using unbalanced labels, which can make one class the default.&lt;/li&gt;
&lt;li&gt;Choosing examples only from easy cases instead of covering hard cases.&lt;/li&gt;
&lt;li&gt;Assuming more examples always help instead of testing whether they change behavior.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This article was prepared with AI assistance and reviewed before publishing. The original lives on the free question bank:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://johnnnmai.github.io/ai-engineer-interview-questions/questions/zero-shot-vs-few-shot-prompting/?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=zero-shot-vs-few-shot-prompting" rel="noopener noreferrer"&gt;https://johnnnmai.github.io/ai-engineer-interview-questions/questions/zero-shot-vs-few-shot-prompting/?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=zero-shot-vs-few-shot-prompting&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>interview</category>
      <category>rag</category>
      <category>career</category>
    </item>
    <item>
      <title>Fine-tuning vs in-context learning: what is the difference?</title>
      <dc:creator>Valenx</dc:creator>
      <pubDate>Wed, 11 Nov 2026 23:07:28 +0000</pubDate>
      <link>https://dev.to/valenx/fine-tuning-vs-in-context-learning-what-is-the-difference-c78</link>
      <guid>https://dev.to/valenx/fine-tuning-vs-in-context-learning-what-is-the-difference-c78</guid>
      <description>&lt;h2&gt;
  
  
  What the interviewer is testing
&lt;/h2&gt;

&lt;p&gt;Whether you can distinguish prompt-based learning from weight updates, compare their costs and deployment needs, and choose retrieval for frequently changing facts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Answer framework
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;In-context learning puts instructions and examples into the prompt without changing the model weights.&lt;/li&gt;
&lt;li&gt;In-context learning supports immediate iteration, but each request pays for the extra prompt tokens and behavior remains bounded by the context window.&lt;/li&gt;
&lt;li&gt;Fine-tuning trains on examples and updates model parameters, potentially making formats, tone or narrow-task behavior more consistent.&lt;/li&gt;
&lt;li&gt;Fine-tuning can make a smaller model perform as well as a larger prompted model, but it requires data, training, evaluation and redeployment.&lt;/li&gt;
&lt;li&gt;Use retrieval rather than fine-tuning for facts that change frequently, because retrieval lets the source of truth be updated without retraining.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sample answer
&lt;/h2&gt;

&lt;p&gt;I would start by separating what changes. With in-context learning, I put the instructions and any examples directly into the prompt. The model parameters do not change, so I can iterate immediately by editing the prompt. The tradeoff is that every request carries and processes the extra prompt tokens, and the behavior I can obtain is constrained by the context window. It is a good fit when the task is quick to prototype, the instructions change often, or I want temporary behavior without a training run.&lt;/p&gt;

&lt;p&gt;Fine-tuning is different because I train the model on examples and update model parameters. That can make the desired format, tone or narrow task behavior more consistent and can make a smaller model perform as well as a larger model that only receives examples in its prompt. These benefits require evaluation. Learned behavior can reduce how much instruction I need to supply on every call.&lt;/p&gt;

&lt;p&gt;I would also be explicit about the cost. Fine-tuning requires curating data, running training and evaluating whether the result improved. After deployment, a changed model normally means redeployment. I would not use fine-tuning as my default way to teach frequently changing facts. retrieval is better because it lets me update the source of truth without retraining. So I choose based on whether I need durable behavior changes or current information, and whether the per-request prompt cost matters.&lt;/p&gt;

&lt;h2&gt;
  
  
  Likely follow-ups
&lt;/h2&gt;

&lt;p&gt;When would I choose in-context learning over fine-tuning? I would choose it when I need immediate iteration, temporary instructions or examples, or a quick prototype. I would also consider it when the extra prompt tokens and context-window limits are acceptable.&lt;/p&gt;

&lt;p&gt;Can fine-tuning be a good way to add frequently changing facts? Usually not. Fine-tuning is poorly suited to frequently changing information because each update requires training data, evaluation and redeployment. I would use retrieval so the information source can be updated independently.&lt;/p&gt;

&lt;p&gt;What operational work does fine-tuning add? I need to collect and curate training examples, run training, evaluate the result and deploy the updated model. Prompt-only changes also require evaluation and may require curated examples, but they do not require model training.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common mistakes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Treating in-context learning as a training step that changes model weights.&lt;/li&gt;
&lt;li&gt;Claiming prompt examples are permanently learned and no longer consume context tokens on each request.&lt;/li&gt;
&lt;li&gt;Using fine-tuning as the default solution for frequently changing facts.&lt;/li&gt;
&lt;li&gt;Comparing the approaches only on answer quality while ignoring prompt cost, context limits, training data, evaluation and redeployment.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This article was prepared with AI assistance and reviewed before publishing. The original lives on the free question bank:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://johnnnmai.github.io/ai-engineer-interview-questions/questions/fine-tuning-vs-in-context-learning/?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=fine-tuning-vs-in-context-learning" rel="noopener noreferrer"&gt;https://johnnnmai.github.io/ai-engineer-interview-questions/questions/fine-tuning-vs-in-context-learning/?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=fine-tuning-vs-in-context-learning&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>interview</category>
      <category>rag</category>
      <category>career</category>
    </item>
    <item>
      <title>What is self-attention and why does it matter?</title>
      <dc:creator>Valenx</dc:creator>
      <pubDate>Wed, 11 Nov 2026 20:09:24 +0000</pubDate>
      <link>https://dev.to/valenx/what-is-self-attention-and-why-does-it-matter-1h9b</link>
      <guid>https://dev.to/valenx/what-is-self-attention-and-why-does-it-matter-1h9b</guid>
      <description>&lt;h2&gt;
  
  
  What the interviewer is testing
&lt;/h2&gt;

&lt;p&gt;Whether you can explain the query-key-value computation, why self-attention improves long-range token interactions, the quadratic cost, and the reason for scaling before softmax.&lt;/p&gt;

&lt;h2&gt;
  
  
  Answer framework
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Represent each token with three learned projections: a query, a key and a value.&lt;/li&gt;
&lt;li&gt;Compute compatibility scores with the query-key dot product, scale them by 1/sqrt(d_k), and apply softmax to obtain attention weights.&lt;/li&gt;
&lt;li&gt;Produce each token's output as a weighted sum of the value vectors using those attention weights.&lt;/li&gt;
&lt;li&gt;Allow each token to retrieve information from any position permitted by the attention mask in one layer, avoiding a recurrent bottleneck while supporting parallel sequence processing during training.&lt;/li&gt;
&lt;li&gt;Recognize the trade-off: full self-attention has O(n^2) compute and an attention matrix that also scales quadratically with sequence length.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sample answer
&lt;/h2&gt;

&lt;p&gt;I explain self-attention as a way for the model to decide which other tokens in the sequence matter for the token it is processing. Each token is projected into a query, a key and a value. The query represents what the token is looking for, the key represents what it offers for matching, and the value carries information that can be passed along. We compute scores by taking the query-key dot product, divide by the square root of the key dimension, and apply softmax to get normalized attention weights.&lt;/p&gt;

&lt;p&gt;The output for each position is a weighted sum of the value vectors using those weights. The important benefit is direct information flow: each token can pull information from positions permitted by the attention mask through one layer instead of passing it through recurrent steps. Unmasked attention can access the entire sequence. causal attention can access only current and earlier positions. During training, positions can still be processed in parallel.&lt;/p&gt;

&lt;p&gt;The trade-off is quadratic computation. For sequence length n and fixed head dimensions, full attention uses O(n^2) compute. Explicitly storing its attention matrix also takes O(n^2) memory, but implementations such as FlashAttention avoid materializing that matrix. Dividing scores by the square root of the key dimension also matters: under standard assumptions, dot-product variance grows with dimension, which can saturate softmax and produce small gradients. Scaling helps keep scores in a useful range.&lt;/p&gt;

&lt;h2&gt;
  
  
  Likely follow-ups
&lt;/h2&gt;

&lt;p&gt;Why do we divide the attention scores by sqrt(d_k)? Without the scaling, dot products grow as the key dimension grows. The softmax can then saturate, producing very small gradients and making optimization harder.&lt;/p&gt;

&lt;p&gt;What is the main trade-off in self-attention? It gives tokens direct access to positions permitted by the attention mask, but full attention requires O(n^2) computation at fixed head dimensions. Materializing the attention matrix also requires O(n^2) memory. memory-efficient implementations avoid storing it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common mistakes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Assuming a token can only use nearby context, as in a fixed local window.&lt;/li&gt;
&lt;li&gt;Forgetting to scale the QK^T scores by sqrt(d_k) before applying softmax.&lt;/li&gt;
&lt;li&gt;Claiming the attention cost is linear in sequence length. the full attention matrix is quadratic.&lt;/li&gt;
&lt;li&gt;Describing the output as a plain average of values and ignoring the learned, content-dependent weights.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This article was prepared with AI assistance and reviewed before publishing. The original lives on the free question bank:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://johnnnmai.github.io/ai-engineer-interview-questions/questions/what-is-self-attention/?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=what-is-self-attention" rel="noopener noreferrer"&gt;https://johnnnmai.github.io/ai-engineer-interview-questions/questions/what-is-self-attention/?utm_source=devto&amp;amp;utm_medium=community&amp;amp;utm_campaign=what-is-self-attention&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>interview</category>
      <category>rag</category>
      <category>career</category>
    </item>
  </channel>
</rss>
