Download README.md from Tristan21b/OpenModel: direct link, hf CLI and curl.
- Browser
- Download file 841 Bytes
-
https://huggingface.co/Tristan21b/OpenModel/resolve/main/README.md
- Command line
-
hf download hf://Tristan21b/OpenModel/README.md
-
curl -L -o README.md https://huggingface.co/Tristan21b/OpenModel/resolve/main/README.md
license: afl-3.0
Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="baidu/ERNIE-4.5-21B-A3B-Thinking") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)
Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("baidu/ERNIE-4.5-21B-A3B-Thinking") model = AutoModelForCausalLM.from_pretrained("baidu/ERNIE-4.5-21B-A3B-Thinking") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))