Views
No views yet
1Model_CONFIG = {
2 "vocab_size": tokenizer.vocab_size, # Update vocab size to match tokenizer (256000)
3 "context_length": 2048, # Reduced context length for T4 GPU memory constraints
4 "emb_dim": 640,
5 "n_heads": 4,
6 "n_layers": 18,
7 "hidden_dim": 2048,
8 "head_dim": 256,
9 "qk_norm": True,
10 "n_kv_groups": 1,
11 "rope_local_base": 10_000.0,
12 "rope_base": 1_000_000.0,
13 "sliding_window": 512,
14 "layer_types": [
15 "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention",
16 "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention",
17 "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "sliding_attention", "full_attention"
18 ],
19 "dtype": torch.bfloat16,
20 "query_pre_attn_scalar": 256,
21}
221from transformers import AutoTokenizer
2import torch
3
4# Load tokenizer
5tokenizer = AutoTokenizer.from_pretrained("google/gemma-3-270m-it")
6
7# Load model (you need to implement the architecture or use the provided code)
8# See the original implementation for model architecture
9
10# Generate text
11prompt = "सर्वोच्च अदालतको निर्णय अनुसार"
12inputs = tokenizer(prompt, return_tensors="pt")
13# ... generation code ...