Tiny Qwen2 Language Model on TinyStories

This project contains a pre-trained compact Qwen2-based language model on the TinyStories dataset. More details are provided by TinyLM.

Example Usage

from transformers import Qwen2ForCausalLM
from transformers import LlamaTokenizerFast

tokenizer = LlamaTokenizerFast.from_pretrained("wencan25/tinystories_qwen2")

input_texts = ["Once upon a time"]

inputs = tokenizer(
    input_texts,
    add_special_tokens=False,
    truncation=False,
    return_tensors="pt",
)["input_ids"]

model = Qwen2ForCausalLM.from_pretrained("wencan25/tinystories_qwen2")

outputs = model.generate(
    inputs, max_new_tokens=256, eos_token_id=0, do_sample=True, num_beams=5
)

output_texts = tokenizer.decode(outputs[0])

print(output_texts)

Example Output

Once upon a time, there was a little boy named Tim. Tim loved to play outside with his friends. They would run, jump, and laugh all day long.
One day, Tim and his friends were playing in the park. They were having so much fun! But then, something unexpected happened. A big wind came and blew Tim's hat away. Tim was sad and didn't know what to do.
Tim's mom saw him and said, "Don't worry, Tim. We will find your hat." They looked everywhere for the hat. Finally, they found it under a big tree. Tim was so happy and thanked his mom. From that day on, Tim and his friends played together every day, and they all became the best of friends.
Downloads last month
5
Safetensors
Model size
25.2M params
Tensor type
F32
·
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Dataset used to train wencan25/tinystories_qwen2