<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>LLM Engineering on Chen Kai Blog</title><link>https://www.chenk.top/en/llm-engineering/</link><description>Recent content in LLM Engineering on Chen Kai Blog</description><generator>Hugo</generator><language>en</language><lastBuildDate>Tue, 07 Apr 2026 09:00:00 +0000</lastBuildDate><atom:link href="https://www.chenk.top/en/llm-engineering/index.xml" rel="self" type="application/rss+xml"/><item><title>LLM Engineering (12): Production — Deployment, Monitoring, Cost</title><link>https://www.chenk.top/en/llm-engineering/12-production/</link><pubDate>Tue, 07 Apr 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/llm-engineering/12-production/</guid><description>&lt;p>This is the last chapter. The previous ones covered building the model, the prompt, the retrieval, and the evaluation. This chapter focuses on maintaining it without breaking the bank. Production LLM serving is more like running a high-traffic web service than classical ML serving, except each web request costs money and can take up to two minutes.&lt;/p>
&lt;p>I&amp;rsquo;ll focus more on numbers here than in earlier chapters. In production, the difference between a profitable feature and a money pit often boils down to a 2-5x cost factor that no one is tracking. The most useful skill to develop is back-of-the-envelope cost arithmetic for LLM workloads. The numbers below are accurate as of late 2025 / early 2026; verify them against current pricing before committing.&lt;/p></description></item><item><title>LLM Engineering (11): Safety and Alignment</title><link>https://www.chenk.top/en/llm-engineering/11-safety/</link><pubDate>Mon, 06 Apr 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/llm-engineering/11-safety/</guid><description>&lt;p>Safety has the worst signal-to-noise ratio of any topic in LLM engineering. There&amp;rsquo;s a lot of philosophy, a lot of marketing, and not a lot of engineering specifics. This chapter is the engineering specifics: what RLHF actually optimizes when it talks about &amp;ldquo;safety,&amp;rdquo; how refusal calibration breaks, what red-teaming looks like in practice, the hallucination measures that actually predict customer impact, and the small but significant 2024-2026 papers (Sleeper Agents, refusal as a feature direction, weak-to-strong generalization) that should change how you think about alignment in production.&lt;/p></description></item><item><title>LLM Engineering (10): Evaluation</title><link>https://www.chenk.top/en/llm-engineering/10-evaluation/</link><pubDate>Sun, 05 Apr 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/llm-engineering/10-evaluation/</guid><description>&lt;p>Evaluation is the part of the LLM stack where everyone has opinions but no one is confident. The leaderboards are gamed, the public benchmarks are contaminated, and most teams I&amp;rsquo;ve worked with had no eval set when I joined. This chapter covers what evaluation actually tells you, what the benchmarks hide, the LLM-as-judge biases that go unaddressed, the calibration metrics most teams skip, and the production patterns that catch regressions before customers notice.&lt;/p></description></item><item><title>LLM Engineering (9): Prompting at Production Scale</title><link>https://www.chenk.top/en/llm-engineering/09-prompting/</link><pubDate>Sat, 04 Apr 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/llm-engineering/09-prompting/</guid><description>&lt;p>A prompt that works on 100 examples in a notebook can fail on 10% of inputs in production for reasons unrelated to cleverness. This chapter covers prompting as an engineering task: where chain-of-thought helps (and where it doesn&amp;rsquo;t), how prompt caching affects costs, how to combine few-shot, chain-of-thought, and self-consistency without using every trick, and how to defend against jailbreaks and injections that production traffic will generate within a week of launch.&lt;/p></description></item><item><title>LLM Engineering (8): Retrieval-Augmented Generation</title><link>https://www.chenk.top/en/llm-engineering/08-rag/</link><pubDate>Fri, 03 Apr 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/llm-engineering/08-rag/</guid><description>&lt;p>RAG is the most over-deployed and under-engineered pattern in LLM applications. The 2024 demo loop — embed everything with &lt;code>text-embedding-3-large&lt;/code>, dump into pgvector, top-5 cosine — works for 1000 documents and a forgiving demo. It does not survive 100K real documents and a customer who notices when the answer is wrong. This chapter is what I wish more teams knew before they built their second generation of RAG.&lt;/p>
&lt;p>The original RAG paper (&lt;a href="https://arxiv.org/abs/2005.11401" target="_blank" rel="noopener noreferrer">Lewis et al., 2020 &lt;span aria-hidden="true" style="font-size:0.75em; opacity:0.55; margin-left:2px;">↗&lt;/span>&lt;/a>
) framed retrieval-augmented generation as a hybrid model: a dense retriever (DPR) trained jointly with a generator (BART) so the retrieval objective optimized end-task accuracy. Production RAG in 2026 doesn&amp;rsquo;t look much like Lewis&amp;rsquo;s RAG — modern systems use frozen pre-trained embedders, separate rerankers, and decoder-only generators that don&amp;rsquo;t train against the retriever. But the core insight (parameterize knowledge separately from reasoning) survived and became the dominant paradigm. The &lt;a href="https://arxiv.org/abs/2312.10997" target="_blank" rel="noopener noreferrer">Gao et al. (2023) RAG survey &lt;span aria-hidden="true" style="font-size:0.75em; opacity:0.55; margin-left:2px;">↗&lt;/span>&lt;/a>
 is the best comprehensive overview of the post-2020 evolution into &amp;ldquo;Naive RAG → Advanced RAG → Modular RAG.&amp;rdquo;&lt;/p></description></item><item><title>LLM Engineering (7): Function Calling and Tool Use</title><link>https://www.chenk.top/en/llm-engineering/07-function-calling/</link><pubDate>Thu, 02 Apr 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/llm-engineering/07-function-calling/</guid><description>&lt;p>Function calling connects an LLM to the world outside its weights. It combines chat-template details (&lt;a href="https://www.chenk.top/en/llm-engineering/02-tokenization/">Chapter 2&lt;/a>
), structured-output kernels (&lt;a href="https://www.chenk.top/en/llm-engineering/05-inference/">Chapter 5&lt;/a>
), and prompt engineering (&lt;a href="https://www.chenk.top/en/llm-engineering/09-prompting/">Chapter 9&lt;/a>
). This chapter explores what happens under the hood, the guarantees you can rely on, and the agent-loop patterns that handle real workloads.&lt;/p>
&lt;p>The intellectual lineage matters. Tool use as an LLM capability traces back to two near-simultaneous papers in 2022: &lt;strong>MRKL Systems&lt;/strong> (Karpas et al., AI21) which proposed expert-routing among neuro-symbolic modules, and &lt;strong>ReAct&lt;/strong> (&lt;a href="https://arxiv.org/abs/2210.03629" target="_blank" rel="noopener noreferrer">Yao et al., 2022 &lt;span aria-hidden="true" style="font-size:0.75em; opacity:0.55; margin-left:2px;">↗&lt;/span>&lt;/a>
) which interleaved chain-of-thought reasoning with tool actions. &lt;strong>Toolformer&lt;/strong> (&lt;a href="https://arxiv.org/abs/2302.04761" target="_blank" rel="noopener noreferrer">Schick et al., 2023 &lt;span aria-hidden="true" style="font-size:0.75em; opacity:0.55; margin-left:2px;">↗&lt;/span>&lt;/a>
) showed self-supervised teaching of tool use, generating training data by having a model insert tool-call markers into existing text. By 2024 every frontier model had post-training data structured around the tool-use format, and tool calling moved from &amp;ldquo;research demo&amp;rdquo; to &amp;ldquo;API feature.&amp;rdquo;&lt;/p></description></item><item><title>LLM Engineering (6): Long Context — RoPE, YaRN, Sinks</title><link>https://www.chenk.top/en/llm-engineering/06-long-context/</link><pubDate>Wed, 01 Apr 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/llm-engineering/06-long-context/</guid><description>&lt;p>&amp;ldquo;1M token context&amp;rdquo; is one of the most over-claimed numbers in LLMs. A model can attend to 1M tokens — that&amp;rsquo;s an architecture statement. A model can &lt;em>use&lt;/em> information at position 800K to answer a question — that&amp;rsquo;s a behavior statement, and it&amp;rsquo;s more challenging. This chapter covers the math of position encoding, the engineering tricks that extend context beyond the training length, and why most long-context claims fail needle-in-a-haystack tests.&lt;/p></description></item><item><title>LLM Engineering (5): Inference Optimization</title><link>https://www.chenk.top/en/llm-engineering/05-inference/</link><pubDate>Tue, 31 Mar 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/llm-engineering/05-inference/</guid><description>&lt;p>Inference is where the money goes. A single 70B-class model serving 1000 concurrent users at 50 tok/s consumes the GPU budget used to train the model in about 3 months. This chapter focuses on two key metrics: time-to-first-token (TTFT) and inter-token latency (ITL), and one ratio: GPU-seconds per million output tokens.&lt;/p>
&lt;p>Training is a one-time capital expense, with costs spread over millions of inference calls. Inference, however, is a recurring operating expense that doesn&amp;rsquo;t amortize. A 50% (1.5x) improvement in tokens-per-GPU-second compounds daily over the product&amp;rsquo;s lifetime. That&amp;rsquo;s why every serious LLM team has at least one full-time engineer focused on inference, and why the open-source community has released four distinct waves of inference engines (FasterTransformer → DeepSpeed-Inference → vLLM → SGLang/TensorRT-LLM/llama.cpp) in five years.&lt;/p></description></item><item><title>LLM Engineering (4): Post-training — SFT, DPO, RLHF, RLAIF</title><link>https://www.chenk.top/en/llm-engineering/04-post-training/</link><pubDate>Mon, 30 Mar 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/llm-engineering/04-post-training/</guid><description>&lt;p>A base model from pretraining can complete text but cannot follow instructions, refuse harmful requests, or maintain a persona—these are post-training behaviors. Post-training is where the gap between a research paper&amp;rsquo;s claims and a production-grade model lies. This chapter covers what each post-training algorithm optimizes, why most reward models are subtly flawed, and the effective methods for 2026.&lt;/p>
&lt;p>&lt;figure class="article-figure">
 &lt;img src="https://blog-pic-ck.oss-cn-beijing.aliyuncs.com/posts/en/llm-engineering/04-post-training/illustration_1.png" alt="LLM Engineering (4): Post-training — SFT, DPO, RLHF, RLAIF — Chapter overview" loading="lazy" decoding="async" class="content-image">
 
&lt;/figure>
&lt;/p></description></item><item><title>LLM Engineering (3): Pretraining at Scale</title><link>https://www.chenk.top/en/llm-engineering/03-pretraining/</link><pubDate>Sun, 29 Mar 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/llm-engineering/03-pretraining/</guid><description>&lt;p>Pretraining is where most of an LLM&amp;rsquo;s capability comes from, and it&amp;rsquo;s also where the leaderboard-vs-reality gap is widest. Most published runs are heroic engineering more than they are scientific results. This chapter is about the parts of pretraining that you actually have to get right when you&amp;rsquo;re not OpenAI: the data, the parallelism choice, and the failure modes that only show up when the cluster is large enough to make a single bad NCCL all-reduce kill a 30-day run.&lt;/p></description></item><item><title>LLM Engineering (2): Tokenization Deep Dive</title><link>https://www.chenk.top/en/llm-engineering/02-tokenization/</link><pubDate>Sat, 28 Mar 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/llm-engineering/02-tokenization/</guid><description>&lt;p>Tokenization is the layer everyone skips. It&amp;rsquo;s also the layer where I&amp;rsquo;ve debugged the most production bugs — silent quality regressions, mysterious cost spikes, models refusing to follow instructions because someone formatted the chat template wrong. This chapter is everything I wish I&amp;rsquo;d internalized before shipping a multilingual product.&lt;/p>
&lt;p>&lt;figure class="article-figure">
 &lt;img src="https://blog-pic-ck.oss-cn-beijing.aliyuncs.com/posts/en/llm-engineering/02-tokenization/illustration_1.png" alt="LLM Engineering (2): Tokenization Deep Dive — Chapter overview" loading="lazy" decoding="async" class="content-image">
 
&lt;/figure>
&lt;/p>
&lt;hr>
&lt;h2 id="what-a-tokenizer-actually-does" class="heading-anchor">What a tokenizer actually does&lt;a href="#what-a-tokenizer-actually-does" class="heading-link" aria-label="Permalink to this section" title="Copy link to this section">#&lt;/a>
&lt;/h2>&lt;p>A tokenizer maps a string to a list of integer IDs. Reverse maps IDs back to a string. Both directions are deterministic but not bijective in general — round-tripping &lt;code>tokenizer.decode(tokenizer.encode(s))&lt;/code> can lose whitespace, normalize Unicode, or collapse repeated punctuation, depending on the algorithm.&lt;/p></description></item><item><title>LLM Engineering (1): Architectures from Transformer to MoE</title><link>https://www.chenk.top/en/llm-engineering/01-architectures/</link><pubDate>Fri, 27 Mar 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/llm-engineering/01-architectures/</guid><description>&lt;p>The 2017 Transformer block is still the silhouette of every production LLM in 2026, but almost every internal piece has been swapped, sparsified, or specialized. This series covers the modern stack end to end — architecture, training, inference, retrieval, evaluation, safety, deployment. Chapter 1 is about the block itself: what attention looks like in a 2026 model, how MoE breaks the param-FLOPs link, and where the non-attention alternatives (Mamba, RWKV) actually beat the Transformer.&lt;/p></description></item></channel></rss>