Back to all models
text-generation mask_token:
Query this model
πŸ”₯ This model is currently loaded and running on the Inference API. ⚠️ This model could not be loaded by the inference API. ⚠️ This model can be loaded on the Inference API on-demand.
JSON Output
API endpoint  

⚑️ Upgrade your account to access the Inference API

Share Copied link to clipboard

Monthly model downloads

lvwerra/gpt2-imdb lvwerra/gpt2-imdb
last 30 days



Contributed by

lvwerra Leandro von Werra
6 models

How to use this model directly from the πŸ€—/transformers library:

Copy to clipboard
from transformers import AutoTokenizer, AutoModelWithLMHead tokenizer = AutoTokenizer.from_pretrained("lvwerra/gpt2-imdb") model = AutoModelWithLMHead.from_pretrained("lvwerra/gpt2-imdb")


What is it?

A GPT2 (gpt2) language model fine-tuned on the IMDB dataset.

Training setting

The GPT2 language model was fine-tuned for 1 epoch on the IMDB dataset. All comments were joined into a single text file separated by the EOS token:

import pandas as pd
df = pd.read_csv("imdb-dataset.csv")
imdb_str = " <|endoftext|> ".join(df['review'].tolist())

with open ('imdb.txt', 'w') as f:

To train the model the script in the transformer library was used:

    --train_data_file imdb.txt 
    --output_dir gpt2-imdb 
    --model_type gpt2 
    --model_name_or_path gpt2