pytorch gpt2 text-generation transformers license:afl-3.0
---
license: afl-3.0
---
# Docto Bot

## Usage (HuggingFace Transformers)
```
pip install -U transformers
```

```python
import random
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("docto/Docto-Bot")
model = AutoModelForCausalLM.from_pretrained("docto/Docto-Bot")
special_token = '<|endoftext|>'

prompt_text = 'Question: I am having fever\nAnswer:'
#prompt_text = f'Question: {userinput}\nAnswer:'
encoded_prompt = tokenizer.encode(prompt_text,
                                  add_special_tokens = False,
                                  return_tensors = 'pt')
output_sequences = model.generate(
    input_ids = encoded_prompt,
    max_length = 700,
    temperature = 0.9,
    top_k = 20,
    top_p = 0.9,
    repetition_penalty = 1,
    do_sample = True,
    num_return_sequences = 4
)
result = tokenizer.decode(random.choice(output_sequences))
result = result[result.index("Answer: "):result.index(special_token)]
print(result[8:])
```

## Training Data
The Docto-Bot was trained on [Medical Question/Answer dataset](https://github.com/LasseRegin/medical-question-answer-data)