Update README.md
Browse files
README.md
CHANGED
@@ -9,4 +9,35 @@ tags:
|
|
9 |
- medical
|
10 |
---
|
11 |
|
12 |
-
This is a finetuned version of [gamino/wiki_medical_terms](https://huggingface.co/datasets/gamino/wiki_medical_terms)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
- medical
|
10 |
---
|
11 |
|
12 |
+
This is a finetuned version of [gamino/wiki_medical_terms](https://huggingface.co/datasets/gamino/wiki_medical_terms)
|
13 |
+
|
14 |
+
## Model description
|
15 |
+
|
16 |
+
GPT-2 is a transformers model pre-trained on a very large corpus of English data in a self-supervised fashion. This
|
17 |
+
means it was pre-trained on the raw texts only, with no humans labeling them in any way (which is why it can use lots
|
18 |
+
of publicly available data) with an automatic process to generate inputs and labels from those texts. More precisely,
|
19 |
+
it was trained to guess the next word in sentences.
|
20 |
+
|
21 |
+
More precisely, inputs are sequences of continuous text of a certain length and the targets are the same sequence,
|
22 |
+
shifting one token (word or piece of word) to the right. The model uses a masking mechanism to make sure the
|
23 |
+
predictions for the token `i` only use the inputs from `1` to `i` but not the future tokens.
|
24 |
+
|
25 |
+
This way, the model learns an inner representation of the English language that can then be used to extract features
|
26 |
+
useful for downstream tasks. The model is best at what it was trained for, however, which is generating texts from a
|
27 |
+
prompt.
|
28 |
+
|
29 |
+
### To use this model
|
30 |
+
|
31 |
+
```python
|
32 |
+
>>> from transformers import AutoTokenizer, AutoModelForCausalLM
|
33 |
+
>>> model_name = "Sharathhebbar24/chat_gpt2_dpo"
|
34 |
+
>>> model = AutoModelForCausalLM.from_pretrained(model_name)
|
35 |
+
>>> tokenizer = AutoTokenizer.from_pretrained(model_name)
|
36 |
+
>>> def generate_text(prompt):
|
37 |
+
>>> inputs = tokenizer.encode(prompt, return_tensors='pt')
|
38 |
+
>>> outputs = model.generate(inputs, max_length=64, pad_token_id=tokenizer.eos_token_id)
|
39 |
+
>>> generated = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
40 |
+
>>> return generated[:generated.rfind(".")+1]
|
41 |
+
>>> prompt = "What is Paracetemol"
|
42 |
+
>>> res = generate_text(prompt)
|
43 |
+
>>> res
|