Vidyuth commited on
Commit
b3e495b
1 Parent(s): 89ff902

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +29 -2
README.md CHANGED
@@ -69,7 +69,34 @@ Users (both direct and downstream) should be made aware of the risks, biases and
69
 
70
  ## How to Get Started with the Model
71
 
72
- Use the code below to get started with the model.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
  [More Information Needed]
75
 
@@ -77,7 +104,7 @@ Use the code below to get started with the model.
77
 
78
  ### Training Data
79
 
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
 
82
  [More Information Needed]
83
 
 
69
 
70
  ## How to Get Started with the Model
71
 
72
+ import torch
73
+ from transformers import GPT2LMHeadModel, GPT2Tokenizer
74
+
75
+
76
+ path = "Vidyuth/GPT2-finetuned-medical-instructions"
77
+ device = "cuda" if torch.cuda.is_available() else "cpu"
78
+ tokenizer = GPT2Tokenizer.from_pretrained(path)
79
+ model = GPT2LMHeadModel.from_pretrained(path).to(device)
80
+
81
+ prompt_input = (
82
+ "The conversation between human and AI assistant.\n"
83
+ "[|Human|] {input}\n"
84
+ "[|AI|]"
85
+ )
86
+ sentence = prompt_input.format_map({'input': "what is parkinson's disease?"})
87
+ inputs = tokenizer(sentence, return_tensors="pt").to(device)
88
+
89
+ with torch.no_grad():
90
+ beam_output = model.generate(**inputs,
91
+ min_new_tokens=1,
92
+ max_length=512,
93
+ num_beams=3,
94
+ repetition_penalty=1.2,
95
+ early_stopping=True,
96
+ eos_token_id=198
97
+ )
98
+ print(tokenizer.decode(beam_output[0], skip_special_tokens=True))
99
+
100
 
101
  [More Information Needed]
102
 
 
104
 
105
  ### Training Data
106
 
107
+ <!https://huggingface.co/datasets/Mohammed-Altaf/medical-instruction-120k>
108
 
109
  [More Information Needed]
110