Views
No views yet
1from transformers import AutoTokenizer, AutoModelForCausalLM
2
3model_name = 'mllmTeam/PhoneLM-1.5B-Instruct'
4question = "Hello, who are you?"
5prompt = [{"role": "user", "content": question}]
6
7model = AutoModelForCausalLM.from_pretrained(model_name, device_map='cuda', trust_remote_code=True)
8
9tokenizer = AutoTokenizer.from_pretrained(model_name)
10input_text = tokenizer.apply_chat_template(prompt, tokenize=False, add_generation_prompt=True)
11
12inp = tokenizer(input_text, return_tensors="pt")
13inp = {k: v.to('cuda') for k, v in inp.items()}
14out = model.generate(**inp,
15 max_length=256,
16 do_sample=True,
17 temperature=0.7,
18 top_p=0.7
19 )
20text = tokenizer.decode(out[0], skip_special_tokens=True)
21print(text)PhoneLM 1.5B models are auto-regressive language models based on the transformer decoder architecture.| Hidden Size | Layers | Heads | Sequence Length |
|---|---|---|---|
| 2560 | 19 | 16 | 2048 |
@misc{yi2024phonelmanefficientcapablesmall,
title={PhoneLM:an Efficient and Capable Small Language Model Family through Principled Pre-training},
author={Rongjie Yi and Xiang Li and Weikai Xie and Zhenyan Lu and Chenghua Wang and Ao Zhou and Shangguang Wang and Xiwen Zhang and Mengwei Xu},
year={2024},
eprint={2411.05046},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2411.05046},
}