I帽igo L贸pez-Riob贸o Botana commited on
Commit
6d0a43c
1 Parent(s): e73e92c

Update README.md

Browse files

# DialoGPT-medium-spanish-chitchat
### Description

This is a **transformer-decoder** [gpt2 model](https://huggingface.co/gpt2), adapted for **single turn dialogue tasks**. We fine-tuned a [DialoGPT-medium](https://huggingface.co/microsoft/DialoGPT-medium) model from Microsoft, following the CLM (Causal Language Modelling) objective.
We used one of the datasets available in the [Bot Framework Tools repository](https://github.com/microsoft/botframework-cli). We processed [the professional-styled personality chat dataset in Spanish](https://github.com/microsoft/botframework-cli/blob/main/packages/qnamaker/docs/chit-chat-dataset.md), the file is available [here](https://qnamakerstore.blob.core.windows.net/qnamakerdata/editorial/spanish/qna_chitchat_professional.tsv)
---
### Example inference script

To run this model in inference mode
```python
from transformers import AutoModelForCausalLM, AutoTokenizer

CHAT_TURNS = 5
MAX_LENGTH=1000

model = AutoModelForCausalLM.from_pretrained('ITG/DialoGPT-medium-spanish-chitchat')
tokenizer = AutoTokenizer.from_pretrained('ITG/DialoGPT-medium-spanish-chitchat')
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model.to(device)
for i in range(CHAT_TURNS):
user_input = input(f"Step - {i} >> user prompt ->")
with torch.no_grad():
# User turn, where "user_input" is the question (single-turn dialogue task)
user_inputs_ids = tokenizer.encode(user_input + tokenizer.eos_token, return_tensors="pt")
user_inputs_ids = user_inputs_ids.to(device)
# The chat history adds the generated tokens for the answer
chat_history = model.generate(user_inputs_ids, max_length=MAX_LENGTH,
pad_token_id=tokenizer.eos_token_id)
# decode just the last generated output tokens from the model (do not include the user prompt again)
step_model_answer = tokenizer.decode(chat_history[:, user_inputs_ids.shape[-1]:][0],
skip_special_tokens=True)
print(f"Step - {i} >> DialoGPT-spanish model answer -> {step_model_answer}")

```

### Fine-tuning in different dataset

For fine-tuning this model, you can start from the DialoGPT base model

Files changed (1) hide show
  1. README.md +4 -1
README.md CHANGED
@@ -1,3 +1,6 @@
1
  ---
2
  license: cc-by-nc-nd-4.0
3
- ---
 
 
 
 
1
  ---
2
  license: cc-by-nc-nd-4.0
3
+ language:
4
+ - es
5
+ pipeline_tag: text-generation
6
+ ---