Views
No views yet
1from huggingface_hub import hf_hub_download
2import torch
3
4# Download model weights
5model_path = hf_hub_download(
6 repo_id="vuminhtue/gemma3_270m_150k_tinystories",
7 filename="Gemma3_270m_150k_model_params.pt"
8)
9
10# Download config
11config_path = hf_hub_download(
12 repo_id="vuminhtue/gemma3_270m_150k_tinystories",
13 filename="config.json"
14)1import torch
2import tiktoken
3from Gemma3_model import Gemma3Model # You need this file from the original code
4
5# Set up configuration
6GEMMA3_CONFIG = {
7 "vocab_size": 256000,
8 "context_length": 8192,
9 "emb_dim": 2048,
10 "n_heads": 8,
11 "n_layers": 18,
12 "hidden_dim": 16384,
13 "head_dim": 256,
14 "dtype": torch.bfloat16,
15}
16
17# Load model
18model = Gemma3Model(GEMMA3_CONFIG)
19device = "cuda" if torch.cuda.is_available() else "cpu"
20model.load_state_dict(torch.load(model_path, map_location=device))
21model = model.to(device)
22model.eval()
23
24# Generate text
25tokenizer = tiktoken.get_encoding("gpt2")
26# Your generation code here...1@misc{gemma3-tinystories-2025,
2 author = {Your Name},
3 title = {Gemma3-270M Pre-trained on TinyStories},
4 year = {2025},
5 publisher = {HuggingFace},
6 howpublished = {\url{https://huggingface.co/vuminhtue/gemma3_270m_150k_tinystories}},
7}