Edit model card

Model Card: GPT2_Shakespeare

Model Description

This model is a fine-tuned version of the GPT-2 base model, fine-tuned on a dataset consisting of works by William Shakespeare to generate text in his tone and style. The model is designed to generate coherent and contextually relevant text, mimicking the unique style and phrasing found in the dataset.

Model Details

  • Model Type: GPT-2 (Base)

  • Training Dataset: Works by William Shakespeare Github

  • Intended Use Cases:

    • Creative writing assistance
    • Educational purposes for studying literary styles
    • Text generation in the style of William Shakespeare

Usage

You can easily use this model to generate text in Python using the Hugging Face transformers library.

Installation

Ensure you have the transformers library installed:

pip install transformers

Inference

from transformers import GPT2LMHeadModel, GPT2Tokenizer

# Load the fine-tuned model and tokenizer
model_name = "sartajbhuvaji/gpt2_B_Shakespeare"
model = GPT2LMHeadModel.from_pretrained(model_name)
tokenizer = GPT2Tokenizer.from_pretrained(model_name)

# Prepare input text
input_text = "To be, or not to be, that is the question:"
input_ids = tokenizer.encode(input_text, return_tensors="pt")

# Generate text
output = model.generate(
    input_ids,
    max_length=200,
    num_return_sequences=1,
    no_repeat_ngram_size=2,
    do_sample=True,
    top_k=50,
    top_p=0.95
)

# Decode the generated text
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
print(generated_text)

Limitations and Biases

This model has been trained on a specific dataset, and its responses will reflect the content and style of that dataset. The model may generate text that reflects the biases present in the original data. This model is not suitable for generating factual information or for use cases requiring highly accurate and unbiased outputs.

Ethical Considerations

Use this model responsibly. The text generated by the model should not be used for misleading or harmful purposes. Note that this model might reflect historical biases inherent in the original text sources. Acknowledgments This model is based on the GPT-2 architecture by OpenAI and has been fine-tuned using the Hugging Face transformers library.

Downloads last month
19
Safetensors
Model size
124M params
Tensor type
F32
·
Inference Examples
Unable to determine this model's library. Check the docs .

Model tree for sartajbhuvaji/gpt2_B_Shakespeare

Finetuned
(1129)
this model