<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>LLM on Chen Kai Blog</title><link>https://www.chenk.top/en/tags/llm/</link><description>Recent content in LLM on Chen Kai Blog</description><generator>Hugo</generator><language>en</language><lastBuildDate>Thu, 07 May 2026 09:00:00 +0000</lastBuildDate><atom:link href="https://www.chenk.top/en/tags/llm/index.xml" rel="self" type="application/rss+xml"/><item><title>Alibaba Cloud Full Stack (10): Bailian and DashScope — The LLM Layer</title><link>https://www.chenk.top/en/aliyun-fullstack/10-bailian-llm/</link><pubDate>Thu, 07 May 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/aliyun-fullstack/10-bailian-llm/</guid><description>&lt;p>When I first needed an LLM API for a production app in China, my options were limited and expensive. Most international providers had no mainland endpoint, billing required a foreign credit card, and latency from calling US-based APIs was 800ms+ before a single token came back. Then Qwen showed up on DashScope with an OpenAI-compatible endpoint, and suddenly building AI products in China became as straightforward as anywhere else. Same SDK, same request shape, same streaming protocol — just a different &lt;code>base_url&lt;/code> and a key from the Bailian console. I have been running production workloads against it for over a year now, and this article is the comprehensive walkthrough I wish I had on day one.&lt;/p></description></item><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><item><title>Terraform for AI Agents (6): LLM Gateway and Secrets Management</title><link>https://www.chenk.top/en/terraform-agents/06-llm-gateway-and-secrets/</link><pubDate>Sun, 22 Mar 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/terraform-agents/06-llm-gateway-and-secrets/</guid><description>&lt;p>A pattern I see repeatedly in immature agent stacks: each agent has its own copy of &lt;code>OPENAI_API_KEY&lt;/code> in its own &lt;code>.env&lt;/code> file. Sometimes the same key, sometimes different ones, sometimes a colleague&amp;rsquo;s personal key from when they prototyped. When the bill arrives nobody can tell which agent caused which token spend, and when a key leaks (it always does) you&amp;rsquo;re playing whack-a-mole across a dozen &lt;code>.env&lt;/code> files.&lt;/p>
&lt;p>The real wake-up call hit me two years ago. A contractor finished his three-month engagement on a Friday, his laptop went home, and on the following Tuesday DashScope billing flagged 12 million tokens of &lt;code>qwen-max&lt;/code> traffic from an IP we didn&amp;rsquo;t recognise. His personal API key — copy-pasted into a side project — was still sitting in our agent&amp;rsquo;s &lt;code>.env&lt;/code>. Rotating it took six hours: three engineers, four repos, two CI pipelines, one panicked Slack thread. Never again.&lt;/p></description></item><item><title>Aliyun PAI (3): PAI-DLC — Distributed Training Without the Cluster Pain</title><link>https://www.chenk.top/en/aliyun-pai/03-pai-dlc-distributed-training/</link><pubDate>Sat, 07 Mar 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/aliyun-pai/03-pai-dlc-distributed-training/</guid><description>&lt;p>A DSW notebook is for one engineer on one GPU. When you need eight GPUs across two nodes or training that runs longer than eight hours, you switch to &lt;strong>DLC&lt;/strong>. DLC is PAI&amp;rsquo;s job-submission front-end for a managed Kubernetes cluster. You describe what you want (image, command, resources, data mounts), and DLC schedules pods, runs them to completion, persists logs, and reports the results. The docs call this &lt;em>Deep Learning Containers&lt;/em>; we just say &amp;ldquo;DLC job&amp;rdquo;.&lt;/p></description></item><item><title>Aliyun Bailian (2): The Qwen LLM API in Production</title><link>https://www.chenk.top/en/aliyun-bailian/02-qwen-llm-api/</link><pubDate>Thu, 26 Feb 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/aliyun-bailian/02-qwen-llm-api/</guid><description>&lt;p>This article in the series covers most of the production wins. While the other models are interesting, the LLMs are what every product I&amp;rsquo;ve shipped on Bailian calls every minute of every day. The official Qwen API reference is dense and complete; this article is the readable companion that guides you through it.&lt;/p>
&lt;p>&lt;figure class="article-figure">
 &lt;img src="https://blog-pic-ck.oss-cn-beijing.aliyuncs.com/posts/en/aliyun-bailian/02-qwen-llm-api/illustration_1.png" alt="Aliyun Bailian (2): The Qwen LLM API in Production — Chapter overview" loading="lazy" decoding="async" class="content-image">
 
&lt;/figure>
&lt;/p>
&lt;hr>
&lt;h2 id="pick-the-right-qwen-variant-for-the-workload" class="heading-anchor">Pick the right Qwen variant for the workload&lt;a href="#pick-the-right-qwen-variant-for-the-workload" class="heading-link" aria-label="Permalink to this section" title="Copy link to this section">#&lt;/a>
&lt;/h2>&lt;p>The Qwen family is large. Some teams overspend by defaulting to &lt;code>qwen-max&lt;/code> everywhere; others underspend on quality by defaulting to &lt;code>qwen-turbo&lt;/code>. The right answer is &amp;ldquo;match variant to job&amp;rdquo;:&lt;/p></description></item><item><title>Aliyun Bailian (1): Platform Overview and First Request</title><link>https://www.chenk.top/en/aliyun-bailian/01-platform-overview/</link><pubDate>Wed, 25 Feb 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/aliyun-bailian/01-platform-overview/</guid><description>&lt;p>If you ship anything that touches Chinese-language users, sooner or later you will end up calling a Bailian model. Qwen-Max is the cheapest sane way to get GPT-4-class Chinese understanding, the Wanxiang video models are the only production-grade text-to-video API I can buy with a Chinese invoice, and Qwen-TTS-Flash is the only TTS that handles Cantonese and Sichuanese without sounding like a customs announcement. After about a year of running these in production for an AI-marketing platform, this series is what I wish someone had handed me on day one.&lt;/p></description></item><item><title>AI Agents Complete Guide: From Theory to Industrial Practice</title><link>https://www.chenk.top/en/standalone/ai-agents-complete-guide/</link><pubDate>Mon, 19 Jan 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/standalone/ai-agents-complete-guide/</guid><description>&lt;p>A chatbot answers questions. An &lt;em>agent&lt;/em> gets things done — it browses, runs code, calls APIs, queries databases, and iterates until the job is complete. The same LLM powers both, but the wrapper differs: an agent runs in a loop with tools, memory, and the ability to inspect its own work.&lt;/p>
&lt;p>This guide is the expanded version of that idea. It covers the four core capabilities (planning, memory, tool use, reflection), major framework families, multi-agent collaboration, evaluation, and the production concerns that determine whether an agent succeeds or fails.&lt;/p></description></item><item><title>Recommendation Systems (12): Large Language Models and Recommendation</title><link>https://www.chenk.top/en/recommendation-systems/12-llm-recommendation/</link><pubDate>Sat, 03 Jan 2026 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/recommendation-systems/12-llm-recommendation/</guid><description>&lt;p>A user opens a movie app and types: &lt;em>&amp;ldquo;Something like Inception, but less depressing.&amp;rdquo;&lt;/em> A traditional recommender — collaborative filtering, two-tower DNN, even DIN — sees zero useful tokens here. It has no &lt;code>like&lt;/code> button to count, no co-watch graph to traverse, no user ID with history. The query has to be turned into IDs before the system can do anything.&lt;/p>
&lt;p>A Large Language Model has the opposite problem: it has &lt;em>too much&lt;/em> world knowledge but doesn&amp;rsquo;t know who this user is. It knows Inception is a Christopher Nolan film with non-linear narrative and a hopeful-but-ambiguous ending; it knows what &amp;ldquo;depressing&amp;rdquo; means in cinema; it can name twenty films that fit. But it can&amp;rsquo;t tell you which of those twenty the &lt;em>current&lt;/em> user has already seen, rated badly, or left half-watched.&lt;/p></description></item><item><title>NLP (12): Frontiers and Practical Applications</title><link>https://www.chenk.top/en/nlp/frontiers-applications/</link><pubDate>Tue, 25 Nov 2025 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/nlp/frontiers-applications/</guid><description>&lt;p>We have spent eleven chapters climbing from raw text to multimodal foundation models. This twelfth and final chapter sits at the frontier and at the runway. It is where research stops being a paper and starts being a service: an LLM that calls tools, writes and debugs code, reasons through hundred-step problems, ingests a 200K-token contract, and serves a thousand concurrent users behind a FastAPI endpoint with p95 latency under 300 ms.&lt;/p></description></item><item><title>NLP (11): Multimodal Large Language Models</title><link>https://www.chenk.top/en/nlp/multimodal-nlp/</link><pubDate>Thu, 20 Nov 2025 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/nlp/multimodal-nlp/</guid><description>&lt;p>Humans never perceive the world in one channel at a time. We watch a chart while reading the caption, hear a tone of voice while reading a face, glance at a screenshot while debating a bug. Pure-text language models are deaf and blind to all of that. &lt;strong>Multimodal Large Language Models (MLLMs)&lt;/strong> close the gap by aligning images, audio, and video into the same representation space the language model already speaks.&lt;/p></description></item><item><title>NLP (10): RAG and Knowledge Enhancement Systems</title><link>https://www.chenk.top/en/nlp/rag-knowledge-enhancement/</link><pubDate>Sat, 15 Nov 2025 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/nlp/rag-knowledge-enhancement/</guid><description>&lt;p>A frozen language model is a confident liar. It can&amp;rsquo;t read yesterday&amp;rsquo;s incident report, your company wiki, or the patch notes that shipped this morning, so when you ask, it confabulates an answer that is grammatically perfect but factually wrong. &lt;strong>Retrieval-Augmented Generation (RAG)&lt;/strong> breaks the deadlock by separating &lt;em>memory&lt;/em> from &lt;em>reasoning&lt;/em>: keep the LLM small and stable, and put the volatile knowledge in an external store that you can update anytime. Before generating, retrieve the relevant evidence and condition the model on it.&lt;/p></description></item><item><title>NLP (9): Deep Dive into LLM Architecture</title><link>https://www.chenk.top/en/nlp/llm-architecture-deep-dive/</link><pubDate>Mon, 10 Nov 2025 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/nlp/llm-architecture-deep-dive/</guid><description>&lt;p>The 2017 Transformer paper drew one block. Every production LLM today still uses that diagram as a silhouette, but almost every internal piece has been replaced. Pre-norm replaced post-norm. RMSNorm replaced LayerNorm. SwiGLU replaced GELU. Rotary embeddings replaced sinusoids. Multi-head attention became grouped-query attention. The dense FFN sometimes became a sparse mixture of experts. And the inference loop is dominated by a data structure that doesn&amp;rsquo;t appear in the original paper at all: the KV cache.&lt;/p></description></item><item><title>NLP (8): Model Fine-tuning and PEFT</title><link>https://www.chenk.top/en/nlp/fine-tuning-peft/</link><pubDate>Wed, 05 Nov 2025 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/nlp/fine-tuning-peft/</guid><description>&lt;p>In 2020, fine-tuning a 7-billion-parameter language model was a project budget item: eight A100s, several days, and an engineer who knew how to babysit gradient checkpointing. In 2024, a graduate student does it on a laptop. The distance between those two worlds is almost entirely covered by one paper — Hu et al.&amp;rsquo;s LoRA (ICLR 2022) — and one follow-up — Dettmers et al.&amp;rsquo;s QLoRA (NeurIPS 2023).&lt;/p>
&lt;p>The shift is not just engineering. Parameter-Efficient Fine-Tuning (PEFT) reframes what it means to &amp;ldquo;have a model.&amp;rdquo; Instead of one binary blob per task, you keep a single frozen base model and a directory of small adapter files, each a few tens of megabytes. Switching tasks becomes loading a new adapter; serving N domains becomes O(1) base + N · ε.&lt;/p></description></item><item><title>NLP (7): Prompt Engineering and In-Context Learning</title><link>https://www.chenk.top/en/nlp/prompt-engineering-icl/</link><pubDate>Fri, 31 Oct 2025 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/nlp/prompt-engineering-icl/</guid><description>&lt;p>The same model can produce a sharp answer or a confident hallucination. The difference lies in the framing, not the weights. A vague request like &lt;em>&amp;ldquo;analyze this text&amp;rdquo;&lt;/em> yields a generic summary; a prompt with a role, two clear examples, and a strict output schema produces something a parser can use. &lt;strong>Prompt engineering turns that gap into a repeatable system, not just a lucky shot.&lt;/strong>&lt;/p>
&lt;p>In-Context Learning (ICL) is the mechanism that makes this work. When you include a few examples in the prompt, the model doesn&amp;rsquo;t retrain; it conditions its forward pass on those examples and effectively &lt;em>infers a task&lt;/em> from them. Understanding ICL&amp;rsquo;s capabilities and limitations separates a developer who struggles with the model from one who guides it.&lt;/p></description></item><item><title>Prompt Engineering Complete Guide: From Zero to Advanced Optimization</title><link>https://www.chenk.top/en/standalone/prompt-engineering-complete-guide/</link><pubDate>Tue, 30 Sep 2025 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/standalone/prompt-engineering-complete-guide/</guid><description>&lt;p>The same model, two prompts: one achieves 17% accuracy on grade-school math, the other 78%. The difference isn&amp;rsquo;t magic—it&amp;rsquo;s prompt engineering. This guide covers the techniques that work, the research behind them, and how to systematically optimize prompts for production.&lt;/p>
&lt;hr>
&lt;h2 id="what-you-will-learn" class="heading-anchor">What You Will Learn&lt;a href="#what-you-will-learn" class="heading-link" aria-label="Permalink to this section" title="Copy link to this section">#&lt;/a>
&lt;/h2>&lt;ul>
&lt;li>&lt;strong>Foundations&lt;/strong> — zero-shot, few-shot, many-shot, task decomposition, and the five-block prompt skeleton.&lt;/li>
&lt;li>&lt;strong>Reasoning techniques&lt;/strong> — Chain-of-Thought, Self-Consistency, Tree of Thoughts, Graph of Thoughts, ReAct.&lt;/li>
&lt;li>&lt;strong>Automation&lt;/strong> — Automatic Prompt Engineering (APE), DSPy, LLMLingua compression.&lt;/li>
&lt;li>&lt;strong>Practical templates&lt;/strong> — structured output, code generation, data extraction, multi-turn chat.&lt;/li>
&lt;li>&lt;strong>Evaluation and debugging&lt;/strong> — metrics, A/B testing, error analysis, the failure-mode toolkit.&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Prerequisites.&lt;/strong> Basic Python; experience calling any LLM API. No math background required.&lt;/p></description></item><item><title>LLM Workflows and Application Architecture: Enterprise Implementation Guide</title><link>https://www.chenk.top/en/standalone/llm-workflows-architecture/</link><pubDate>Thu, 31 Jul 2025 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/standalone/llm-workflows-architecture/</guid><description>&lt;p>Most LLM tutorials end where the interesting work begins. They show you how to call a chat completion endpoint, attach a vector store, and wrap the whole thing in a Streamlit demo. None of that is wrong, but none of it is what breaks at 3 a.m. when 10,000 users hit your service at once and every other answer is a hallucination.&lt;/p>
&lt;p>This article is about everything that comes after the demo. It is opinionated on purpose: production LLM systems are mostly plain distributed systems with one non-deterministic component bolted on, and most of the engineering effort goes into containing that non-determinism. We will work through seven dimensions — application architecture, workflow patterns, the RAG-vs-fine-tune decision, deployment topology, cost, observability, and enterprise integration — keeping each one short, concrete, and grounded in the levers that actually move the needle.&lt;/p></description></item><item><title>Prefix-Tuning: Optimizing Continuous Prompts for Generation</title><link>https://www.chenk.top/en/standalone/prefix-tuning/</link><pubDate>Tue, 29 Jul 2025 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/standalone/prefix-tuning/</guid><description>&lt;p>Fine-tuning a 1.5B-parameter GPT-2 model for each downstream task means saving a fresh 1.5B-parameter checkpoint every time. Across a dozen tasks, that is a substantial storage and serving headache, and it makes sharing a single base model essentially impossible. &lt;em>Prefix-Tuning&lt;/em> (Li &amp;amp; Liang, 2021) takes the opposite stance: freeze every weight of the language model, and learn a tiny block of continuous vectors — the &lt;em>prefix&lt;/em> — that is fed into the attention layers as if it were context the model already attended to. The model never changes; only the prefix does, and a different prefix produces a different &amp;ldquo;personality&amp;rdquo; on demand.&lt;/p></description></item><item><title>MoSLoRA: Mixture-of-Subspaces in Low-Rank Adaptation</title><link>https://www.chenk.top/en/standalone/moslora/</link><pubDate>Sun, 01 Sep 2024 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/standalone/moslora/</guid><description>&lt;p>LoRA is the default tool for adapting a frozen base model: cheap, stable, mergeable, and good enough for most single-task settings. But the moment your fine-tuning data is genuinely heterogeneous — code mixed with math, instruction following mixed with creative writing, several domains in one adapter — a single low-rank subspace starts to feel cramped. You can grow &lt;span class="math-inline">$r$&lt;/span>
, but cost grows with it and you still get &lt;em>one&lt;/em> subspace, just a fatter one.&lt;/p></description></item><item><title>Position Encoding Brief: From Sinusoidal to RoPE and ALiBi</title><link>https://www.chenk.top/en/standalone/position-encoding-brief/</link><pubDate>Fri, 30 Jun 2023 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/standalone/position-encoding-brief/</guid><description>&lt;p>Self-attention has a strange property that surprises most people the first time they compute it by hand: it does not know the order of its inputs. Permute the tokens and every attention score is permuted along with them — the function is exactly equivariant. So before we can do anything useful with a Transformer, we have to inject position information from the outside.&lt;/p>
&lt;p>That single design decision — &lt;em>how&lt;/em> to inject it — has spawned a remarkable amount of research. Sinusoidal, learned, relative, T5-style buckets, RoPE, ALiBi, NoPE, and more. This post is a practitioner&amp;rsquo;s brief: enough math to know why each scheme works, enough comparison to choose one, and a clear focus on the property that matters most in the LLM era — &lt;strong>length extrapolation&lt;/strong>, the ability to handle sequences longer than anything seen in training.&lt;/p></description></item><item><title>LLMGR: Integrating Large Language Models with Graphical Session-Based Recommendation</title><link>https://www.chenk.top/en/standalone/llmgr/</link><pubDate>Sun, 22 Jan 2023 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/standalone/llmgr/</guid><description>&lt;p>Session-based recommendation relies on the click graph. New items lack edges, and long-tail items have a few noisy ones. Each item has a title and description, but the model never uses them. &lt;strong>LLMGR&lt;/strong> addresses this by treating the LLM as a &amp;ldquo;semantic engine&amp;rdquo; that converts text into representations a graph encoder can use, then lets a GNN handle ranking. On Amazon Music/Beauty/Pantry, the results show HR@20 up ~8.68%, NDCG@20 up ~10.71%, and MRR@20 up ~11.75% over the strongest GNN baseline, with the biggest gains for cold-start items.&lt;/p></description></item><item><title>Optimization (4): Learning Rate and Schedules</title><link>https://www.chenk.top/en/optimization-theory/04-learning-rate-schedules/</link><pubDate>Sun, 18 Sep 2022 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/optimization-theory/04-learning-rate-schedules/</guid><description>&lt;p>Your model diverges. You halve the learning rate. Now it trains, but takes forever. You halve again — now the loss is a flat line. Sound familiar? Of all the knobs you can turn, &lt;strong>learning rate&lt;/strong> is the one that most often decides whether training converges, crawls, or blows up. This guide gives you the intuition, the minimal math, and a practical workflow to get it right — from a 12-layer CNN on your laptop to a 70B-parameter LLM on a thousand GPUs.&lt;/p></description></item><item><title>Optimization (3): The Gradient Descent Family from SGD to AdamW</title><link>https://www.chenk.top/en/optimization-theory/03-gradient-descent-family/</link><pubDate>Fri, 16 Sep 2022 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/optimization-theory/03-gradient-descent-family/</guid><description>&lt;p>Why is &amp;ldquo;tuning the LR is an art&amp;rdquo; a meme for ResNet, while every modern LLM paper just writes &amp;ldquo;AdamW, &lt;span class="math-inline">$\beta_1{=}0.9, \beta_2{=}0.95, \mathrm{wd}{=}0.1$&lt;/span>
&amp;rdquo; and moves on? It is not an accident — it is the &lt;strong>end-point of three decades of optimizer evolution&lt;/strong>.&lt;/p>
&lt;p>This post walks the lineage end-to-end on a single thread: each step exists because of a &lt;strong>specific failure&lt;/strong> of the previous one. We end with the three directions that have actually entered the post-2023 large-model toolkit: Lion, Sophia, and Schedule-Free.&lt;/p></description></item><item><title>Multimodal LLMs and Downstream Tasks: A Practitioner's Guide</title><link>https://www.chenk.top/en/standalone/multimodal-llm-downstream-tasks/</link><pubDate>Sat, 09 Apr 2022 09:00:00 +0000</pubDate><guid>https://www.chenk.top/en/standalone/multimodal-llm-downstream-tasks/</guid><description>&lt;p>Stuffing pixels, audio, and video into a language model so it can &amp;ldquo;see,&amp;rdquo; &amp;ldquo;hear,&amp;rdquo; and reason — that was a research curiosity before CLIP landed in 2021. Today it&amp;rsquo;s table stakes for most consumer-facing AI products. But shipping a Multimodal LLM (MLLM) in production turns out to be hard in places people rarely talk about. Almost never the vision encoder. Almost always these four:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Alignment.&lt;/strong> How does the language model &amp;ldquo;understand&amp;rdquo; what the vision encoder produces? Is the projector a 2-layer MLP or a Q-Former? Which parameters thaw during training?&lt;/li>
&lt;li>&lt;strong>Task framing.&lt;/strong> The same MLLM has to do captioning, VQA, grounding, OCR. Each needs a prompt template that doesn&amp;rsquo;t quietly drop several points of accuracy.&lt;/li>
&lt;li>&lt;strong>Cost.&lt;/strong> A 1024x1024 image becomes hundreds of visual tokens. Prefill is brutal. Stretch that to video and the bill goes vertical. Token compression, KV cache reuse, and batching are not optional.&lt;/li>
&lt;li>&lt;strong>Evaluation.&lt;/strong> A model that scores 80 on MMBench can still hallucinate confidently on your customer&amp;rsquo;s invoice. Public benchmarks are the easy part.&lt;/li>
&lt;/ol>
&lt;p>This post follows the natural research arc — architecture, model families, downstream tasks, fine-tuning, evaluation, deployment — and tries to be specific enough at each stop that you can act on it. Less &amp;ldquo;what&amp;rsquo;s possible,&amp;rdquo; more &amp;ldquo;what to actually pick.&amp;rdquo;&lt;/p></description></item></channel></rss>