# Stable Code 3B PaddlePaddle 权重## 转换方式加载原始模型 (dtype=bfloat16),通过 `model.state_dict()` 获取 Paddle 格式权重,按 <2GB 分片保存为 pdparams。参考转换脚本 `convert_weights.py`## 加载方式```pythonfrom paddleformers.transformers import StableLmForCausalLM, StableLmTokenizermodel = StableLmForCausalLM.from_pretrained( "./convert-weight", dtype="bloat16", load_checkpoint_format="pdparams",)model.eval()tokenizer = StableLmTokenizer.from_pretrained( "stabilityai/stable-code-3b", trust_remote_code=False, download_hub="modelscope",)prompt = "def hello_world():"inputs = tokenizer(prompt, return_tensors="np")input_ids = paddle.to_tensor(inputs["input_ids"])with paddle.no_grad(): gen = model.generate( input_ids, max_new_tokens=50, do_sample=False, pad_token_id=tokenizer.eos_token_id, )output_text = tokenizer.decode(gen[0][0].tolist(), skip_special_tokens=True)print(output_text)```