Views
No views yet
@article{USTC-ChiMed-GPT,
title="{ChiMed-GPT: A Chinese Medical Large Language Model with Full Training Regime and Better Alignment to Human Preferences}",
author={Yuanhe Tian, Ruyi Gan, Yan Song, Jiaxing Zhang, Yongdong Zhang},
journal={arXiv preprint arXiv:2311.06025},
year={2023},
}1from transformers import AutoTokenizer
2from transformers import LlamaForCausalLM
3import torch
4
5query="[human]:感冒怎么处理?\n[bot]:"
6model = LlamaForCausalLM.from_pretrained('SYNLP/ChiMed-GPT-1.0', torch_dtype=torch.float16, device_map="auto").eval()
7tokenizer = AutoTokenizer.from_pretrained(ckpt)
8input_ids = tokenizer(query, return_tensors="pt").input_ids.to('cuda:0')
9generate_ids = model.generate(
10 input_ids,
11 max_new_tokens=512,
12 do_sample = True,
13 top_p = 0.9)
14output = tokenizer.batch_decode(generate_ids)[0]
15print(output)