OPD
OPD copied to clipboard
Full-Vocabulary OPD
Hi, thanks for the great work. Could you provide some guidance on how to implement full-vocab OPD?
Thank you for your question. 😊 I have two ideas here: one simple one and one that is a bit more advanced.
- The simplest way is to set top-k directly to the vocabulary size. Then the top-k KL will be the same as the full-vocabulary KL. The downside is that every time we switch to another model, we need to change this value again.
- A slightly better way is to read the model’s vocabulary size when loading the model, and then set top-k to that value automatically. This would make it more flexible. 👍
Although DeepSeek v4 uses full-vocabulary OPD, I still think using only top-k for OPD is enough and should have very little bias. As we discussed in the paper, a small group of tokens covers most of the probability mass, and the remaining tokens produce very small gradients.
Also, using the full vocabulary can bring a much higher GPU memory cost 💾, which may not be worth it in practice.
Thanks a lot!