647. Al Mathematical Olympiad - Progress Prize 2 | ai-mathematical-olympiad-progress-prize-2
感谢所有参与者,尤其是那些创建了出色的 Notebook、模型和引人入胜讨论的人。我学到了很多。感谢 Kaggle 和主办方在整个漫长、充满挑战但令人兴奋的竞赛过程中提供的持续支持。
我开发了许多方法,其中一些灵感来自讨论和公开的 Notebook。 below 我主要分享我迄今为止成功的方法,公开得分为 28。
由于想法是学习 Qwen-QWQ 32B 如何解决问题,我需要与 AIMO2 竞赛相关的问题。因此,我也包含了参考集,见下文。
1. 在共享 GPU 上初始化三个模型,如下所示
2. 生成文本,形成输入,前向传播并计算损失
SYSTEM_PROMPT = """你是最强大的数学专家。请用深度推理解决问题。你很细心,总是重新检查你的推导。在足够自信之前,你永远不会直接给出答案。你应该一步一步地思考。在取模 1000 后,将最终答案返回到 \\\\boxed{} 中。"""
MAX_SEQ_LEN = 4096 # 教师文本生成中的最大序列长度
sampling_params = SamplingParams(max_tokens=MAX_SEQ_LEN, temperature=0.7, skip_special_tokens=False)
generated_text = teacher_model.generate(
prompts=teacher_prompt,
sampling_params=sampling_params
)
# 现在使用教师模型和学生模型的分词器获取 input_ids 和 attention_mask
teacher_logits = teacher_logits_model(input_ids=teacher_input_ids, attention_mask=teacher_attention_mask).logits
student_logits = model(input_ids=student_input_ids, attention_mask=student_attention_mask).logits
student_log_logits = torch.nn.functional.log_softmax(student_logits, dim=-1).to('cuda')
teacher_log_logits = torch.nn.functional.log_softmax(teacher_logits, dim=-1).to('cuda')
loss = torch.nn.functional.kl_div(student_log_logits, teacher_log_logits, log_target=True, reduction='batchmean')
training_args = TrainingArguments(
output_dir="./qwen14b_distilled",
per_device_train_batch_size=2,
num_train_epochs=1,
logging_dir="./logs",
logging_steps=1,
learning_rate=1e-6,
weight_decay=0.01,
save_strategy="steps",
save_steps=20,
remove_unused_columns=False,
report_to="none",
)
AIME2024/2025: 43/60
参考集:7/10
公开 leaderboard: 28 (max_seq_len=8192*3//2 + 1024, top_p=0.9, min_p=0.05, temperature=1.0)。我还使用了 vLLM Engine 类(不是 LLM),并且当给定答案达到 33% (频率) 时可以取消请求,相对于 max_num_seqs=12