jianghc commited on
Commit
6cc104c
1 Parent(s): 4076823

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +44 -0
README.md ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Quickstart
2
+
3
+ ```python
4
+ import torch
5
+ from transformers import GPT2LMHeadModel, GPT2Tokenizer
6
+
7
+
8
+ path = "jianghc/medical_chatbot"
9
+ device = "cuda" if torch.cuda.is_available() else "cpu"
10
+ tokenizer = GPT2Tokenizer.from_pretrained(path)
11
+ model = GPT2LMHeadModel.from_pretrained(path).to(device)
12
+
13
+ prompt_input = (
14
+ "The conversation between human and AI assistant.\n"
15
+ "[|Human|] {input}\n"
16
+ "[|AI|]"
17
+ )
18
+ sentence = prompt_input.format_map({'input': "what is parkinson's disease?"})
19
+ inputs = tokenizer(sentence, return_tensors="pt").to(device)
20
+
21
+ with torch.no_grad():
22
+ beam_output = model.generate(**inputs,
23
+ min_new_tokens=1,
24
+ max_length=512,
25
+ num_beams=3,
26
+ repetition_penalty=1.2,
27
+ early_stopping=True,
28
+ eos_token_id=198
29
+ )
30
+ print(tokenizer.decode(beam_output[0], skip_special_tokens=True))
31
+ ```
32
+
33
+ ## Example Outputs
34
+ ```
35
+ The conversation between human and AI assistant.
36
+ [|Human|] what is parkinson's disease?
37
+ [|AI|] Parkinson's disease is a neurodegenerative disorder that affects movement. It is caused by the loss of dopamine-producing cells in the brain.
38
+ ```
39
+
40
+ ```
41
+ The conversation between human and AI assistant.
42
+ [|Human|] what type of honey is best for a bad covid cough?
43
+ [|AI|] Manuka honey has been shown to have anti-inflammatory and antibacterial properties that can help alleviate symptoms of a bad covid cough.
44
+ ```