Question about the SFT loss function implementation in `training_step`
Hi @Zewei-Zhou , thank you for realeasing the code of this work!
I have a question related to the loss function definition in SFTAutoVLA, since its computation is not very clear with respect to what is defined in the paper. In the paper, the SFT loss is defined by the combination of the overall causal modelling + an auxiliary one focused only on action tokens:
However, in the class SFTAutoVLA, the returned loss in training_step() is only $L_{LM}$ if there is no CoT data for that batch, with no $L{action}$. I can assume the reason is that with no CoT, then output.loss() would be basically related to the only generated action tokens, however I would like to double check on that since, after a first round of SFT training, the model apperently was not able to produce any action token on the nuScenes benchmark. Thank you in advance for the clarification : ).
I have exactly the same problem: after SFT, the model don't generates action tokens in inference — only CoT text.
Did you find a good way to balance the two losses, or use any method to force action token generation?
Thanks a lot for any advice!
Hey! Unfortunately I didn't have much time to debug in these days but what I have realized is that the formula written in the paper might be actually not exactly correct. What I mean is that, if you notice in the formula in the paper, $\lambda{cot}$ would also involve $L_{action}$, which is a loss that does not have anything to do with the Chain-of-Thought. The correct formula, in my opinion, would be:
L^{SFT}_i = w_i L_{LM, i} + \lambda_a L_{action, i}
which, coincidentally, It's the same way of how is it implemented into the code. Otherwise, since the initial loss for actions would be really high since it's computed for new tokens added to the model vocabulary, the total loss for CoT samples for be even higher for the multiplier (like, 200-300 CE), making it probably hard to converge. I am not entirely sure of course, but It would make sense.
Hey @Zewei-Zhou , any update on this or am I overlooking something?
Hi everyone,
I'd like to clarify the formulation and the intuition behind the SFT loss function:
-
First, please note that $\mathcal{L}{LM}$ represents the standard next-token prediction loss calculated across all target tokens (including both reasoning and actions). For samples without Chain-of-Thought (CoT) data, $\mathcal{L}{LM}$ and $\mathcal{L}_{action}$ are practically identical.
-
When CoT is present, the action tokens are heavily diluted by the much longer reasoning text, weakening the gradient signal for action learning. Since action execution requires significantly higher precision than textual reasoning, we explicitly introduce the auxiliary $\mathcal{L}_{action}$ for CoT samples to ensure sufficient supervision on actions.
-
Because CoT samples are much scarcer in the dataset compared to action-only samples, we apply a larger weight ($\lambda_{cot}$) to boost the reasoning loss and balance the joint training.
Regarding whether $w_i$ is multiplied inside or outside the parentheses:
L_i^{SFT} = w_i ( \mathcal{L}_{LM, i} + \mathcal{L}_{action, i} ) \quad \text{vs.} \quad L_i^{SFT} = w_i \mathcal{L}_{LM, i} + \lambda_a \mathcal{L}_{action, i}
In practice, these approaches are equivalent during training, and the core objective is simply to tune these loss weights appropriately for different sample types to balance the gradients.