LinjieMu commited on
Commit
aed569b
·
verified ·
1 Parent(s): d5fc6e9

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +36 -5
README.md CHANGED
@@ -1,5 +1,36 @@
1
- ---
2
- license: other
3
- license_name: '-'
4
- license_link: https://ai.meta.com/llama/license
5
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: '-'
4
+ license_link: https://ai.meta.com/llama/license
5
+ ---
6
+
7
+ ```python
8
+ import transformers
9
+ import torch
10
+
11
+ # 1. Load Model & Tokenizer
12
+ model_id = "XXX/MedCEG"
13
+ tokenizer = transformers.AutoTokenizer.from_pretrained(model_id)
14
+ model = transformers.AutoModelForCausalLM.from_pretrained(
15
+ model_id,
16
+ torch_dtype=torch.bfloat16,
17
+ device_map="auto",
18
+ )
19
+
20
+ # 2. Define Input
21
+ question = "A 78-year-old Caucasian woman presented with..."
22
+ suffix = "\nPut your final answer in \\boxed{}."
23
+ messages = [{"role": "user", "content": question + suffix}]
24
+
25
+ # 3. Generate
26
+ input_ids = tokenizer.apply_chat_template(
27
+ messages,
28
+ add_generation_prompt=True,
29
+ return_tensors="pt"
30
+ ).to(model.device)
31
+
32
+ outputs = model.generate(input_ids, max_new_tokens=8196, do_sample=False)
33
+ decoded_response = tokenizer.decode(outputs[0][input_ids.shape[-1]:], skip_special_tokens=True)
34
+
35
+ print(decoded_response)
36
+ ```