Views
No views yet
google/gemma-3-270m-it model, hosted for backup and testing purposes by Maaz Waheed.Maazwaheed.Maazwaheed)google/gemma-3-270m-ittransformers library.1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model_id = "Maazwaheed/mallow-gemma-3-270m-it"
5
6# Load the tokenizer
7tokenizer = AutoTokenizer.from_pretrained(model_id)
8
9# Load the model
10model = AutoModelForCausalLM.from_pretrained(
11 model_id,
12 torch_dtype=torch.bfloat16, # Use bfloat16 for better performance/memory
13 device_map="auto"
14)
15
16# Example Chat Interaction
17chat = [
18 {"role": "user", "content": "Explain the concept of quantum entanglement in simple terms."},
19]
20
21prompt = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
22
23inputs = tokenizer.encode(prompt, add_special_tokens=True, return_tensors="pt").to(model.device)
24outputs = model.generate(inputs, max_new_tokens=100)
25
26print(tokenizer.decode(outputs[0]))