# Trouble with fine tuning DialoGPT-large

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftrouble-with-fine-tuning-dialogpt-large%2F8161%3E%5C
**Category:** Beginners\
**Created:** [July 8, 2021, 4:16am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftrouble-with-fine-tuning-dialogpt-large%2F8161 "2021-07-08T04:16:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![epstee](https://avatars.discourse-cdn.com/v4/letter/e/8e8cbc/32.png) [@epstee](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fepstee)%5C
**Post date:** [July 8, 2021, 4:16am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftrouble-with-fine-tuning-dialogpt-large%2F8161%2F1 "2021-07-08T04:16:56Z")

</div>

I’m trying to fine tune the DialoGPT-large model but I’m still really new to ML and am probably misusing the trainer API. I already went through the tutorial and the colab examples but I still can’t figure out the issue.

error:

```auto
Traceback (most recent call last):
  File "/.../main.py", line 26, in <module>
    tokenized_datasets = raw_datasets.map(tokenize_function, batched=True)
TypeError: TextEncodeInput must be Union[TextInputSequence, Tuple[InputSequence, InputSequence]]

```

code:

```auto
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

### CONFIG
weights = "microsoft/DialoGPT-large"

# Initialize tokenizer and model
print("Loading model... ", end='', flush=True)
tokenizer = AutoTokenizer.from_pretrained(weights)
model = AutoModelForCausalLM.from_pretrained(weights)
print('DONE')

### FINE TUNING ###
from datasets import load_dataset
from transformers import AutoTokenizer, DataCollatorWithPadding
raw_datasets = load_dataset("glue", "mrpc")

tokenizer.pad_token = tokenizer.eos_token
tokenizer.pad_token = tokenizer.eos_token

def tokenize_function(example):
    return tokenizer([example["sentence1"], example["sentence2"]], truncation=True)

tokenized_datasets = raw_datasets.map(tokenize_function, batched=True)
data_collator = DataCollatorWithPadding(tokenizer=tokenizer)

from transformers import TrainingArguments
training_args = TrainingArguments("test-trainer")

from transformers import Trainer
trainer = Trainer(
    model,
    training_args,
    train_dataset=tokenized_datasets["train"],
    eval_dataset=tokenized_datasets["validation"],
    data_collator=data_collator,
    tokenizer=tokenizer,
)

trainer.train()

predictions = trainer.predict(tokenized_datasets["validation"])
print(predictions.predictions.shape, predictions.label_ids.shape)

```

---

<div class="post-metadata">

**Author:** ![rachelcorey](https://avatars.discourse-cdn.com/v4/letter/r/258eb7/32.png) [@rachelcorey](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Frachelcorey)%5C
**Post date:** [January 7, 2022, 7:11am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftrouble-with-fine-tuning-dialogpt-large%2F8161%2F2 "2022-01-07T07:11:42Z")

</div>

Hello,

I’ve had this same error. It’s due to there being nonetypes in your data. So when you are creating your dataframe from the data, change your code to specify values, and convert it to a list:

```auto
for i in data.index.values.tolist():

```

If you’re still having issues after that, try the following code on your dataframe object:

```auto
df = df.dropna()

```

Hope this helps you, good luck. 🙂
