x5tne/playdate-dataset-1k
Viewer • Updated • 1.01k • 14
How to use x5tne/playdate-distilgpt2-1k with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="x5tne/playdate-distilgpt2-1k") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("x5tne/playdate-distilgpt2-1k")
model = AutoModelForCausalLM.from_pretrained("x5tne/playdate-distilgpt2-1k")How to use x5tne/playdate-distilgpt2-1k with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "x5tne/playdate-distilgpt2-1k"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "x5tne/playdate-distilgpt2-1k",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/x5tne/playdate-distilgpt2-1k
How to use x5tne/playdate-distilgpt2-1k with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "x5tne/playdate-distilgpt2-1k" \
--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": "x5tne/playdate-distilgpt2-1k",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "x5tne/playdate-distilgpt2-1k" \
--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": "x5tne/playdate-distilgpt2-1k",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use x5tne/playdate-distilgpt2-1k with Docker Model Runner:
docker model run hf.co/x5tne/playdate-distilgpt2-1k
This is a proof of concept model, not to be used in production. Script example below.
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
MODEL_PATH = "x5tne/playdate-distilgpt2-1k"
# Load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
model = AutoModelForCausalLM.from_pretrained(MODEL_PATH)
model.eval()
# Example prompt
prompt = """<system shy>
<summary>none</summary>
<user>Hi [namehere]! How are you today?</user>
<assistant>"""
# Encode input
inputs = tokenizer(prompt, return_tensors="pt")
# Generate output
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=100,
do_sample=True,
temperature=0.9,
top_p=0.9,
repetition_penalty=1.15
)
# Decode generated tokens
response = tokenizer.decode(outputs[0][inputs['input_ids'].shape[1]:], skip_special_tokens=True)
print("Assistant response:")
print(response)
Base model
distilbert/distilgpt2