Views
No views yet
transformers library. Since this is an instruction-tuned model, it is recommended to use the chat template for prompting.1pip install transformers accelerate torch
21
2import torch
3from transformers import AutoModelForCausalLM, AutoTokenizer
4
5model_id = "manuelaschrittwieser/myemoji_generator-gemma-3-270m-it"
6
7tokenizer = AutoTokenizer.from_pretrained(model_id)
8model = AutoModelForCausalLM.from_pretrained(
9 model_id,
10 torch_dtype=torch.bfloat16, # Use bfloat16 or float16 if your GPU supports it for faster/lower-memory inference
11 device_map="auto"
12)
13
14# Define the user prompt for emoji generation
15prompt = "Translate the following feeling into exactly 3 emojis: I just finished a very long and difficult project."
16
17# Apply the instruction-tuned chat template
18chat = [
19 {"role": "user", "content": prompt},
20]
21formatted_prompt = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
22
23# Generate output
24input_ids = tokenizer(formatted_prompt, return_tensors="pt").to(model.device)
25
26output = model.generate(
27 **input_ids,
28 max_new_tokens=20, # Keep tokens low since the output is short (emojis)
29 do_sample=True,
30 temperature=0.7,
31 top_p=0.9,
32 pad_token_id=tokenizer.eos_token_id # Set pad token to EOS for generation
33)
34
35# Decode and print the model's response
36response = tokenizer.decode(output[0], skip_special_tokens=True)
37
38# The output might be formatted like a conversation, so we extract the model's part
39print(response.split("<start_of_turn>model")[-1].strip())
40# Example output: "Done! 😮💨🏆🥳"
41(Text, Emoji Sequence) pairs designed to teach the model how to map natural language to emoji output. (Replace this with specific dataset details if you have them, e.g., "Trained on the 5k-sample myemoji_dataset.")1@misc{manuelaschrittwieser_myemoji_generator_2025,
2 author = {Schrittwieser, Manuela},
3 title = {myemoji\_generator-gemma-3-270m-it},
4 year = {2025},
5 publisher = {Hugging Face},
6 url = {[https://huggingface.co/manuelaschrittwieser/myemoji_generator-gemma-3-270m-it](https://huggingface.co/manuelaschrittwieser/myemoji_generator-gemma-3-270m-it)}
7}
81@article{gemma2024,
2 title={Gemma: Open Models from Google for Responsible AI Development},
3 author={Google},
4 journal={arXiv:2403.02720},
5 year={2024}
6}