roneneldan/TinyStories
Viewer โข Updated โข 2.14M โข 149k โข 1.22k
How to use skmbkang/tinystories-gpt2-30m with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="skmbkang/tinystories-gpt2-30m") # pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("skmbkang/tinystories-gpt2-30m")
model = AutoModelForCausalLM.from_pretrained("skmbkang/tinystories-gpt2-30m", device_map="auto")How to use skmbkang/tinystories-gpt2-30m with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "skmbkang/tinystories-gpt2-30m"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "skmbkang/tinystories-gpt2-30m",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/skmbkang/tinystories-gpt2-30m
How to use skmbkang/tinystories-gpt2-30m with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "skmbkang/tinystories-gpt2-30m" \
--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": "skmbkang/tinystories-gpt2-30m",
"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 "skmbkang/tinystories-gpt2-30m" \
--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": "skmbkang/tinystories-gpt2-30m",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use skmbkang/tinystories-gpt2-30m with Docker Model Runner:
docker model run hf.co/skmbkang/tinystories-gpt2-30m
GPT-2 ๊ตฌ์กฐ(6 layers, 6 heads, 384 dim, context 256, ์ฝ 30M ํ๋ผ๋ฏธํฐ)๋ฅผ PyTorch๋ก ์ง์ ๊ตฌํํด
TinyStories๋ก ์ฒ์๋ถํฐ ์ฌ์ ํ์ตํ ๋ค, GPT2LMHeadModel ํ์์ผ๋ก ๋ณํํ ํ์ต์ฉ ๋ชจ๋ธ์
๋๋ค.
from transformers import AutoModelForCausalLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("skmbkang/tinystories-gpt2-30m")
model = AutoModelForCausalLM.from_pretrained("skmbkang/tinystories-gpt2-30m")
ids = tok("Once upon a time", return_tensors="pt")
out = model.generate(**ids, max_new_tokens=100, do_sample=True, temperature=0.8, top_k=50)
print(tok.decode(out[0], skip_special_tokens=True))
์ด๋ฆฐ์ด์ฉ ์งง์ ์์ด ์ด์ผ๊ธฐ๋ง ํ์ตํ์ต๋๋ค. ์ผ๋ฐ ์ง์, ๋ค๋ฅธ ์ธ์ด, ์ฌ์ค ์ ํ์ฑ์ด ํ์ํ ์ฉ๋์๋ ๋ง์ง ์์ต๋๋ค.