1from transformers import AutoModelForCausalLM, AutoTokenizer
2tokenizer = AutoTokenizer.from_pretrained("cxllin/StableMed-3b")
3model = AutoModelForCausalLM.from_pretrained(
4 "stabilityai/stablelm-3b-4e1t",
5 trust_remote_code=True,
6 torch_dtype="auto",
7)
8model.cuda()
9inputs = tokenizer("The weather is always wonderful", return_tensors="pt").to("cuda")
10tokens = model.generate(
11 **inputs,
12 max_new_tokens=64,
13 temperature=0.75,
14 top_p=0.95,
15 do_sample=True,
16)
17print(tokenizer.decode(tokens[0], skip_special_tokens=True))
The model is a decoder-only transformer similar to the LLaMA (
Touvron et al., 2023) architecture with the following modifications: