Instructions to use aspis/gpt2-genre-story-generation with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use aspis/gpt2-genre-story-generation with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="aspis/gpt2-genre-story-generation")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("aspis/gpt2-genre-story-generation") model = AutoModelForCausalLM.from_pretrained("aspis/gpt2-genre-story-generation", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use aspis/gpt2-genre-story-generation with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "aspis/gpt2-genre-story-generation" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "aspis/gpt2-genre-story-generation", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/aspis/gpt2-genre-story-generation
- SGLang
How to use aspis/gpt2-genre-story-generation with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "aspis/gpt2-genre-story-generation" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "aspis/gpt2-genre-story-generation", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "aspis/gpt2-genre-story-generation" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "aspis/gpt2-genre-story-generation", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use aspis/gpt2-genre-story-generation with Docker Model Runner:
docker model run hf.co/aspis/gpt2-genre-story-generation
GPT-2 fine-tuned for short story generation
Gpt-2 for short story generation with genres.
Model description
Gpt-2 model fine-tuned on sample of BookCorpus dataset for short story generation, allows for the following genres (tokens to use as input under parenthesis):
- Romance (romance)
- Adventure (adventure)
- Mystery & detective (mystery-&-detective)
- Fantasy (fantasy)
- Humor & comedy (humor-&-comedy)
- Paranormal (paranormal)
- Science fiction (science-fiction)
Heavily inspired by https://huggingface.co/pranavpsv
Intended uses & limitations
This can be used for text generation.
How to use:
>>> from transformers import pipeline, TextGenerationPipeline, GPT2LMHeadModel, AutoTokenizer
>>> model_name = "aspis/gpt2-genre-story-generation"
>>> model = GPT2LMHeadModel.from_pretrained(model_name)
>>> tokenizer = AutoTokenizer.from_pretrained(model_name)
>>> generator = TextGenerationPipeline(model=model, tokenizer=tokenizer)
# Input should be of format "<BOS> <Genre token> Optional starter text"
>>> input_prompt = "<BOS> <adventure>"
>>> story = generator(input_prompt, max_length=80, do_sample=True,
repetition_penalty=1.5, temperature=1.2,
top_p=0.95, top_k=50)
>>> print(story)
[{'generated_text': '<BOS> <adventure> "How come they got that one?" asked Louran. The leader of the House, a young man with blonde hair and an odd grin...that didn\'t look so bad to her if she did have a smile on its face. She had known about this before. And now he\'d admitted it himself;'}]
Training data
The model was trained using the BookCorpus dataset by getting the different genres per book and dividing the text into paragraphs.
- Downloads last month
- 32
docker model run hf.co/aspis/gpt2-genre-story-generation