how to fine tune a GPT-2 model?
i'm using huggingface transformers package to load a pretrained GPT-2 model. I want to use GPT-2 for text generation, but the pretrained version isn't enough so I want to fine tune it with a bunch of personal text data.
i'm not sure how I should prepare my data and train the model. I have tokenized the text data I have to train GPT-2 on, but i'm not sure what the "labels" will be for text generation since this isn't a classification problem.
How do I train GPT-2 on this data using Keras API?
my model:
modelName = "gpt2"
generator = pipeline('text-generation', model=modelName)
my tokenizer:
tokenizer = AutoTokenizer.from_pretrained(modelName)
my tokenized dataset:
from datasets import Dataset
def tokenize_function(examples):
return tokenizer(examples['dataset']) # 'dataset' column contains a string of text. Each row is a string of text (in sequence)
dataset = Dataset.from_pandas(conversation)
tokenized_dataset = dataset.map(tokenize_function, batched=False)
print(tokenized_dataset)
How should I use this tokeni开发者_如何学Gozed dataset to fine tune my GPT-2 model?
精彩评论