515. Google AI4Code – Understand Code in Python Notebooks | AI4Code
首先,我要感谢 Kaggle、Google 和 X 主办了这场有趣的比赛。
在我的方法中,Notebook 中的所有 Markdown 单元格和代码单元格都会被分词并连接起来,形成一个长输入序列。所有的 Markdown 单元格在前,随后是所有的代码单元格,它们之间用 [SEP] token 分隔。此外,还为 Markdown (MKDS) 和代码 (CDS) 分别添加了特殊的分隔 token。输入通过 Transformer 后,每个单元格的 token 通过平均池化和一个线性层聚合,映射为一个单一数值。在训练过程中,每个单元格的输出通过成对排序损失进行惩罚,该损失考虑了 Notebook 内所有单元格的组合。在推理时,我们只需对每个单元格的输出进行排序即可得到正确的顺序。

https://github.com/GuanshuoXu/Google-AI4Code-Understand-Code-in-Python-Notebooks
torch.nn.MarginRankingLoss 比 BCE 和 MSE 损失效果更好deberta-v3-large 是 Huggingface 中处理此任务最佳的 Transformer 模型