Skip to main content

19 posts tagged with "thai"

View all tags

[LLM 1/10] Continue Pretraining: Teaching New Knowledge to a Thai LLM

· 13 min read
Kobkrit Viriyayudhakorn
CEO, iApp Technology

A large language model that handles Thai reasonably well will still, more often than not, know nothing about your organization's specialized knowledge — not Thai government regulations, not the jargon of your industry, not your internal documents. This article covers the most direct fix: Continue Pretraining (CPT), from the equations all the way to code that runs end to end on free Colab in about 15 minutes.

[LLM 2/10] SFT + LoRA: Teaching a Model to Be an Assistant by Training 1.69% of Its Parameters

· 20 min read
Kobkrit Viriyayudhakorn
CEO, iApp Technology

Last chapter we used Continue Pretraining to put knowledge into the model's weights. But a model that knows is not a model that answers — a base model has exactly one job: continuing text. This chapter teaches SFT (Supervised Fine-Tuning) with LoRA: a technique that trains only about 1.7% of the parameters yet changes the behavior of the entire model — finished in ~15 minutes on free Colab. What you get back is an adapter file of roughly 40 MB that becomes the backbone of the rest of the series.

[LLM 3/10] RLHF and PPO: Training a Model on a Reward You Cannot Differentiate

· 28 min read
Kobkrit Viriyayudhakorn
CEO, iApp Technology

In chapter 2 we taught the model by "imitating the answer key" one token at a time. But the qualities that make an AI assistant genuinely usable — correct, polite, not making things up, not sliding into English — have no answer key to imitate, and cannot be written directly as a loss function. This chapter is the most classical answer to that problem: RLHF (Reinforcement Learning from Human Feedback) with PPO. We will train a real reward model from Thai preference pairs, then write the PPO loop ourselves from scratch in about 120 lines, and close with my favorite experiment in the series: taking off the KL leash and watching the model cheat the reward live. This is deliberately the heaviest chapter of the series, because chapter 4 (DPO) and chapter 5 (GRPO) both start from this chapter's equations and each choose a different piece to delete.

[LLM 4/10] DPO: When a Language Model Becomes Its Own Reward Model

· 20 min read
Kobkrit Viriyayudhakorn
CEO, iApp Technology

In the last chapter we did RLHF with PPO, and you saw how many moving parts it has — a separate reward model to train, four models resident in VRAM at once, a dozen-plus PPO hyperparameters to tune, and if the reward model is off, the policy finds a shortcut that games the score. In this chapter we'll accomplish the same thing with an ordinary supervised training loop — no reward model, no RL. And crucially, this is not an approximation. We'll prove algebraically that those two pieces genuinely cancel out.

[LLM 5/10] GRPO: Deleting the Value Network and Letting a Group of Answers Be Its Own Baseline

· 26 min read
Kobkrit Viriyayudhakorn
CEO, iApp Technology

The last chapter ended on DPO's gap: it can only rank answers someone prepared in a file. And chapter 3 paid PPO's full price: 4 models in VRAM, plus an entire value network to train on the side. This chapter combines the good halves of both — the model samples its own answers to learn from, genuine RL — but deletes the value network wholesale, using a statistical observation so simple it's almost irritating nobody framed it sooner: if you sample several answers to the same problem, the group's mean reward is already the baseline the value network was trying to estimate. And if the problem can be graded by code, we need no human preference data at all — zero pairs, zero baht.

[LLM 6/10] Context Distillation: Moving the System Prompt into the Model's Weights

· 25 min read
Kobkrit Viriyayudhakorn
CEO, iApp Technology

Every time a user messages your chatbot, you attach the same system prompt, hundreds of tokens long — every request, for the lifetime of the system, paid again and again with no end. This chapter moves that block of knowledge from the prompt into the model's weights, using a technique called Context Distillation in its on-policy version (OPCD). The most beautiful part: the teacher and the student are the exact same model — the only thing that differs is who gets to see the prompt.

[LLM 7/10] Model Distillation: The Teacher's Wrong Answers Are the Most Valuable Part

· 27 min read
Kobkrit Viriyayudhakorn
CEO, iApp Technology

In chapter 6 we distilled a context into the weights of the same model. In this chapter we distill an entire model into a smaller one. The two chapters are a deliberate pair: context distillation changes what the model knows without having to tell it anymore — model distillation changes the size of the model while trying not to change what it can do. And the heart of this chapter cuts hard against intuition: the most valuable thing a teacher can hand its student is not the right answer, but the way the teacher is wrong — and the dial called temperature is what makes that visible.

[LLM 8/10] Guardrails: The Real Safety Fence Isn't a Model, It's a Threshold

· 23 min read
Kobkrit Viriyayudhakorn
CEO, iApp Technology

The Thai chatbots my team and I deploy for real customers don't only meet polite questions — people ask for recipes for illegal things, people try to trick the bot into insulting others, and there was a day the model volunteered a customer's phone number all by itself. In this chapter we build protection in both directions: a classifier that checks incoming prompts for danger and an outbound PII filter. But the central point of the chapter isn't the model — it's the fact that a guardrail is a threshold decision under asymmetric costs, and the "94% accuracy" figure people love to show off is very nearly meaningless.

[LLM 9/10] Benchmarking: An Accuracy Number Without a Confidence Interval Is a Rumor

· 25 min read
Kobkrit Viriyayudhakorn
CEO, iApp Technology

Since chapter 1, this series has repeated the same sentence every time it reports a number: "accuracy without a confidence interval is not an experimental result, it's a rumor" — and promised a full explanation in chapter 9. This is that chapter. We won't train a single step. Instead we'll build a three-mode evaluation system from scratch, put every checkpoint trained across the series on real Thai exams, and prove that the settings nobody writes down in papers move the very same model's score by more than the leaderboard gaps people argue about.

[LLM 10/10] Deployment: You're Not Waiting on Compute, You're Waiting on Weights to Travel

· 26 min read
Kobkrit Viriyayudhakorn
CEO, iApp Technology

Across nine chapters we've injected knowledge, taught format, arranged preferences, distilled models, kept models from breaking, and measured honestly. But even our best model is still just a checkpoint file that nobody can call. This final chapter puts it into real service, and proves the single sentence that governs every decision in LLM serving: decoding one token at a time is not limited by compute power, it is limited by memory bandwidth — we'll compute the speed ceiling from the GPU's datasheet before writing a single line of code, then measure the real thing against it.