roneneldan/TinyStoriesInstruct
Viewer • Updated • 22M • 1.19k • 44
How to use SauravP97/tiny-stories-19M-instruct with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="SauravP97/tiny-stories-19M-instruct") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("SauravP97/tiny-stories-19M-instruct")
model = AutoModelForCausalLM.from_pretrained("SauravP97/tiny-stories-19M-instruct")How to use SauravP97/tiny-stories-19M-instruct with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "SauravP97/tiny-stories-19M-instruct"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "SauravP97/tiny-stories-19M-instruct",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/SauravP97/tiny-stories-19M-instruct
How to use SauravP97/tiny-stories-19M-instruct with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "SauravP97/tiny-stories-19M-instruct" \
--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": "SauravP97/tiny-stories-19M-instruct",
"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 "SauravP97/tiny-stories-19M-instruct" \
--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": "SauravP97/tiny-stories-19M-instruct",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use SauravP97/tiny-stories-19M-instruct with Docker Model Runner:
docker model run hf.co/SauravP97/tiny-stories-19M-instruct
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("SauravP97/tiny-stories-19M-instruct")
model = AutoModelForCausalLM.from_pretrained("SauravP97/tiny-stories-19M-instruct")This is a fine-tuned variant of the TinyStories 19M Base Model View. The model has been fine-tuned on the Tiny Stories Instruct dataset: View
from transformers import AutoTokenizer, AutoModelForCausalLM
prompt = '''
Story: Once upon a time, there was a big, fat penguin named Puddles. Puddles loved to play with his friends on the ice.
One day, Puddles saw a big block of ice and decided to cut it. He used his sharp beak to cut the ice into small pieces.
Puddles and his friends had fun sliding on the ice pieces. They laughed and played until it was time to go home.
Puddles went to bed that night feeling happy and proud that he was able to cut the ice.
Summary:
'''
tokenizer = AutoTokenizer.from_pretrained("EleutherAI/gpt-neo-125M")
model_id = 'SauravP97/tiny-stories-19M-instruct'
pretrained_model = AutoModelForCausalLM.from_pretrained(model_id)
inputs = tokenizer(prompt, return_tensors="pt")
# Generate
output_tokens = pretrained_model.generate(
inputs.input_ids,
max_new_tokens=100,
do_sample=True,
temperature=1,
top_k=50,
pad_token_id=tokenizer.eos_token_id,
eos_token_id=tokenizer.eos_token_id,
)
print(tokenizer.decode(output_tokens)[0])
Story: Once upon a time, there was a big, fat penguin named Puddles. Puddles loved to play with his friends on the ice.
One day, Puddles saw a big block of ice and decided to cut it. He used his sharp beak to cut the ice into small pieces.
Puddles and his friends had fun sliding on the ice pieces. They laughed and played until it was time to go home.
Puddles went to bed that night feeling happy and proud that he was able to cut the ice.
Summary:
Summary: Puddles the penguin, a big fat penguin, cuts a block into small pieces to play with his friends on the ice.<|endoftext|>
Unable to build the model tree, the base model loops to the model itself. Learn more.
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="SauravP97/tiny-stories-19M-instruct")