# Instruction tuning keeps next-token loss and masks non-target tokens

> Original title: Instruction Tuning 或者 SFT 沿用预训练的训练目标：

- Source: Dongxi NLP
- Published: 2026-10-23T06:35:25.000Z
- Bad Influence: https://badinfluence.news/items/cv1ydwa6ggurii8x772n6oj37
- Original: https://x.com/dongxi_nlp/status/2113519647567880419

## Summary

Dongxi NLP says instruction tuning (SFT) uses the same objective as pretraining, predicting the next token with cross-entropy loss. The post says each data pair is converted to a chat-template token sequence, with a loss mask marking which tokens contribute to the loss.

## Post

Instruction Tuning 或者 SFT 沿用预训练的训练目标：

在每个位置预测下一个 token，用 cross-entropy loss 衡量预测和正确 token 之间的差距，通过训练提高正确 token 的概率。

其中，用模型的 chat template 把每对数据转换成对话格式的 token 序列，然后用 loss mask（ 标出需要计算损失的 token，是 recipe 中重要的部分。

来看后训练系列第二篇，Instruction Tuning

[Video](https://badinfluence.news/api/img-proxy?u=https%3A%2F%2Fpbs.twimg.com%2Famplify_video_thumb%2F2113518738184060928%2Fimg%2F0Urbj0QOvRU4qrzc.jpg&mode=thumb&exp=1795737600&sig=4f0a049c8ed98c89)

## Quoted post @dongxi_nlp

> https://x.com/i/article/2113363792482480128

https://x.com/dongxi_nlp/status/2113394315967795538
