Views
No views yet

1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model = AutoModelForCausalLM.from_pretrained("instruction-pretrain/medicine-Llama3-8B")
4tokenizer = AutoTokenizer.from_pretrained("instruction-pretrain/medicine-Llama3-8B")
5
6# Put your input here, NO prompt template is required
7user_input = '''Question: Which of the following is an example of monosomy?
8Options:
9- 46,XX
10- 47,XXX
11- 69,XYY
12- 45,X
13
14Please provide your choice first and then provide explanations if possible.'''
15
16inputs = tokenizer(user_input, return_tensors="pt", add_special_tokens=True).input_ids.to(model.device)
17outputs = model.generate(input_ids=inputs, max_new_tokens=400)[0]
18
19answer_start = int(inputs.shape[-1])
20pred = tokenizer.decode(outputs[answer_start:], skip_special_tokens=True)
21
22print(pred)1@inproceedings{
2cheng2024adapting,
3title={Adapting Large Language Models via Reading Comprehension},
4author={Daixuan Cheng and Shaohan Huang and Furu Wei},
5booktitle={The Twelfth International Conference on Learning Representations},
6year={2024},
7url={https://openreview.net/forum?id=y886UXPEZ0}
8}