Edit model card

GPT2-Poet

Model description

GPT2-Poet is a GPT-2 transformer model fine Tuned on a large corpus of English Poems dataset in a self-supervised fashion. This means it was pretrained on the raw texts only, with no humans labelling them in any way with an automatic process to generate inputs and labels from those texts. More precisely, it was trained to guess the next word in sentences.

More precisely, inputs are sequences of continuous text of a certain length and the targets are the same sequence, shifted one token (word or piece of word) to the right. The model uses internally a mask-mechanism to make sure the predictions for the token i only uses the inputs from 1 to i but not the future tokens.

This way, the model learns an inner representation of the English language that can then be used to extract features useful for downstream tasks.

Intended uses & limitations

You can use the raw model for text generation or fine-tune it to a downstream task. See the model hub to look for fine-tuned versions on a task that interests you.

Usage

You can use this model for English Poem generation:

>>> from transformers import TFGPT2LMHeadModel, GPT2Tokenizer
>>> tokenizer = GPT2Tokenizer.from_pretrained("ashiqabdulkhader/GPT2-Poet")
>>> model = TFGPT2LMHeadModel.from_pretrained("ashiqabdulkhader/GPT2-Poet")
>>> text = "The quick brown fox"
>>> input_ids = tokenizer.encode(text, return_tensors='tf')
>>> sample_outputs = model.generate(
    input_ids,
    do_sample=True,
    max_length=100,
    top_k=0,
    top_p=0.9,
    temperature=1.0,
    num_return_sequences=3
)
>>> print("Output:", tokenizer.decode(sample_outputs[0], skip_special_tokens=True))
Downloads last month
792
Inference Examples
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.

Space using ashiqabdulkhader/GPT2-Poet 1