The mainstream pretraining objective is Next-Token Prediction (autoregressive cross-entropy
L=−∑logP(xt∣x<t)); code models often use FIM (Fill-in-the-Middle): the document is split into prefix/suffix/middle, and with ~50% probability the model predicts the middle from both sides, learning bidirectional context. The optimizer standard is AdamW (β₁=0.9, β₂=0.95, weight decay=0.1) with gradient clipping (global norm 1.0) and a warmup + cosine LR schedule; on a loss spike, training rolls back to the last checkpoint before the spike and resumes.