roneneldan/TinyStories
Viewer • Updated • 2.14M • 93.2k • 1.1k
How to use clfegg/gpt-tinystories-vi-subset with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="clfegg/gpt-tinystories-vi-subset") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("clfegg/gpt-tinystories-vi-subset")
model = AutoModelForCausalLM.from_pretrained("clfegg/gpt-tinystories-vi-subset", device_map="auto")How to use clfegg/gpt-tinystories-vi-subset with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "clfegg/gpt-tinystories-vi-subset"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "clfegg/gpt-tinystories-vi-subset",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/clfegg/gpt-tinystories-vi-subset
How to use clfegg/gpt-tinystories-vi-subset with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "clfegg/gpt-tinystories-vi-subset" \
--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": "clfegg/gpt-tinystories-vi-subset",
"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 "clfegg/gpt-tinystories-vi-subset" \
--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": "clfegg/gpt-tinystories-vi-subset",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use clfegg/gpt-tinystories-vi-subset with Docker Model Runner:
docker model run hf.co/clfegg/gpt-tinystories-vi-subset
A GPT-2 model designed to create short stories in Vietnamese.
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="clfegg/gpt-tinystories-vi-subset")
pipe("một buổi sáng, tôi",max_new_tokens=250)
def stories_generate(input):
response=pipe(input,max_new_tokens=128)[0]['generated_text']
text = response.split("<")[0]
text = text.replace("_", " ")
return text
print(stories_generate("một ngày nọ"))
# [{'generated_text': 'một ngày nọ, một cô bé tên Lily đi dạo. Cô bé nhìn thấy một cái cây lớn với rất nhiều lá. Lily muốn leo lên cây nhưng cô bé quá nhỏ. Lily nhờ mẹ giúp đỡ. Mẹ cô nói, " " Đừng lo, Lily. Chúng ta có thể trèo lên cây. " " Lily trèo lên cây và trèo lên cây. Cô trèo lên cây và trèo lên cây. Khi cô leo lên đến đỉnh, cô thấy một con chim nhỏ. Con chim nói, " " Cảm ơn, Lily! " " Lily mỉm cười và nói, " " Cảm ơn mẹ! " " Họ trở thành những người bạn tốt và chơi cùng nhau mỗi ngày. "}]