Downloads · 30 days
0
k050506koch/gpt2-story-tinetuned
gpt2-story-tinetuned is a machine learning model from k050506koch. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This repository contains multiple models trained using the GPT-2 architecture for generating creative stories, superhero names, and abilities. The models are designed to assist in generating narrative content based on…
Downloads · 30 days
0
Access
Public
Updated Sep 3, 2024
Repo size
15.4 GB
Likes
0
Public
Click a slice to open those files.
.safetensors10.9 GB · 69%
From the Hugging Face model README
This repository contains multiple models trained using the GPT-2 architecture for generating creative stories, superhero names, and abilities. The models are designed to assist in generating narrative content based on user prompts.
The models were trained on a custom dataset stored in batch_ds_v2.txt, which includes various story prompts, superhero names, and abilities. The dataset was preprocessed to extract relevant parts for training.
The models were evaluated based on their ability to generate coherent and contextually relevant text. Specific metrics were not provided, but qualitative assessments were made during development.
To use the models for inference, you can send a POST request to the /generate/<model_path> endpoint of the Flask application. The input should be a JSON object containing the input_text key.
{
"input_text": "[Ivan Ivanov, Lead Software Engineer, Superhero for Justice, Writing code, fixing issues, solving problems, Masculine, Long Hair, Adult]<|endoftext|>"
}
You can load a model and its tokenizer as follows:
from transformers import GPT2LMHeadModel, GPT2Tokenizer
model_name = "v2/story/small" # Change to your desired model path
model = GPT2LMHeadModel.from_pretrained(model_name)
tokenizer = GPT2Tokenizer.from_pretrained(model_name)
To generate text using the loaded model, use the following code:
input_text = "Once upon a time"
input_ids = tokenizer.encode(input_text, return_tensors="pt")
output = model.generate(input_ids, max_length=50, do_sample=True)
generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
print(generated_text)