Instructions to use tuanle/GPT2_Poet with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tuanle/GPT2_Poet with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="tuanle/GPT2_Poet")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("tuanle/GPT2_Poet") model = AutoModelForCausalLM.from_pretrained("tuanle/GPT2_Poet") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use tuanle/GPT2_Poet with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tuanle/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": "tuanle/GPT2_Poet", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/tuanle/GPT2_Poet
- SGLang
How to use tuanle/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 "tuanle/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": "tuanle/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 "tuanle/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": "tuanle/GPT2_Poet", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use tuanle/GPT2_Poet with Docker Model Runner:
docker model run hf.co/tuanle/GPT2_Poet
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
GPT-2 Fine-tuning With Vietnamese Six Eight Poems
Model description
This is a Vietnamese GPT-2 Six Eight Poet Model which is trained on the 10mb of Six Eight poems dataset, based on the Vietnamese Wiki GPT2 pretrained model (https://huggingface.co/danghuy1999/gpt2-viwiki)
Purpose
This model was made only for fun and experimental study
Dataset
The dataset is about 10k lines of Vietnamese Six Eight poems
Result
- Train Loss: 2.7
- Val loss: 4.5
How to use
You can use this model to generate Six Eight poems given any starting words
Example
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
tokenizer = AutoTokenizer.from_pretrained("tuanle/GPT2_Poet")
model = AutoModelForCausalLM.from_pretrained("tuanle/GPT2_Poet").to(device)
text = "hỏi rằng nàng"
input_ids = tokenizer.encode(text, return_tensors='pt').to(device)
min_length = 60
max_length = 100
sample_outputs = model.generate(input_ids,pad_token_id=tokenizer.eos_token_id,
do_sample=True,
max_length=max_length,
min_length=min_length,
# temperature = .8,
# top_k= 100,
top_p = 0.8,
num_beams= 10,
# early_stopping=True,
no_repeat_ngram_size= 2,
num_return_sequences= 3)
for i, sample_output in enumerate(sample_outputs):
print(">> Generated text {}\n\n{}".format(i+1, tokenizer.decode(sample_output.tolist(), skip_special_tokens=True)))
print('\n---')
Demo
- Input: "hỏi rằng nàng"
- Output:
hỏi rằng nàng đã nói ra
cớ sao nàng lại hỏi han sự tình
vân tiên nói lại những lời
thưa rằng ở chốn am mây một mình
từ đây mới biết rõ ràng
ở đây cũng gặp một người ở đây
hai người gặp lại gặp nhau
thấy lời nàng mới hỏi tra việc này
nguyệt nga hỏi việc bấy lâu
khen rằng đạo sĩ ở đầu cửa thiền
- Downloads last month
- 4