Guides

Modern Anchor Enforcement

How SLM suppresses deprecated patterns at inference time.

The problem

Qwen2.5-Coder-7B-Instruct was trained on older Anchor examples that use declare_id!, which is deprecated in Anchor 0.30+. Even with a clear system prompt, the model defaults to the old pattern in ~90% of code-generation requests.

The fix

LiteLLM forwards logit_bias: {"18471": -30} to SGLang. Token 18471 is the declare prefix in Qwen2.5's tokenizer. A bias of -30 is strong enough that the model never emits declare_id! but soft enough that it still generates valid Rust.

Results

  • Before: ~60% of code samples contained declare_id!
  • After: 0/24 tests. All code compiles without modification.