Instructions to use ashiqabdulkhader/GPT2-Poet with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ashiqabdulkhader/GPT2-Poet with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ashiqabdulkhader/GPT2-Poet")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ashiqabdulkhader/GPT2-Poet") model = AutoModelForCausalLM.from_pretrained("ashiqabdulkhader/GPT2-Poet") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use ashiqabdulkhader/GPT2-Poet with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ashiqabdulkhader/GPT2-Poet" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ashiqabdulkhader/GPT2-Poet", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/ashiqabdulkhader/GPT2-Poet
- SGLang
How to use ashiqabdulkhader/GPT2-Poet 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 "ashiqabdulkhader/GPT2-Poet" \ --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": "ashiqabdulkhader/GPT2-Poet", "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 "ashiqabdulkhader/GPT2-Poet" \ --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": "ashiqabdulkhader/GPT2-Poet", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use ashiqabdulkhader/GPT2-Poet with Docker Model Runner:
docker model run hf.co/ashiqabdulkhader/GPT2-Poet
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
- 12