Views
No views yet
[!NOTE] Note: "-Paddle" models use PaddlePaddle weights, while "-PT" models use Transformer-style PyTorch weights.
| Key | Value |
|---|---|
| Modality | Text |
| Training Stage | Posttraining |
| Params | 0.36B |
| Layers | 18 |
| Heads(Q/KV) | 16 / 2 |
| Context Length | 131072 |
transformers librarytransformers library (version 4.54.0 or newer) installed to use this model.1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model_name = "baidu/ERNIE-4.5-0.3B-PT"
5
6# load the tokenizer and the model
7tokenizer = AutoTokenizer.from_pretrained(model_name)
8model = AutoModelForCausalLM.from_pretrained(
9 model_name,
10 device_map="auto",
11 torch_dtype=torch.bfloat16,
12)
13
14# prepare the model input
15prompt = "Give me a short introduction to large language model."
16messages = [
17 {"role": "user", "content": prompt}
18]
19text = tokenizer.apply_chat_template(
20 messages,
21 tokenize=False,
22 add_generation_prompt=True
23)
24model_inputs = tokenizer([text], add_special_tokens=False, return_tensors="pt").to(model.device)
25
26# conduct text completion
27generated_ids = model.generate(
28 **model_inputs,
29 max_new_tokens=1024
30)
31output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
32
33# decode the generated ids
34generate_text = tokenizer.decode(output_ids, skip_special_tokens=True)
35print("generate_text:", generate_text)vllm serve baidu/ERNIE-4.5-0.3B-PT1@misc{ernie2025technicalreport,
2 title={ERNIE 4.5 Technical Report},
3 author={Baidu ERNIE Team},
4 year={2025},
5 eprint={},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL},
8 url={}
9}