Downloads · 30 days
5
13% of all-time downloads
ChrisZhang312/kie-gemma-3-270m-it
kie-gemma-3-270m-it is a machine learning model from ChrisZhang312. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
Fine-tuned Gemma-3-270m model that turns unstructured email/news/post to structured 5W1H (What, Where, When, Why, Who, How) JSON format.
Downloads · 30 days
5
13% of all-time downloads
All-time downloads
39
Public
Parameters
268M
574 MB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors536 MB · 93%
From the Hugging Face model README
Fine-tuned Gemma-3-270m model that turns unstructured email/news/post to structured 5W1H (What, Where, When, Why, Who, How) JSON format.
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
MODEL_PATH = "/home/chris/Documents/research/phishing-email/model/kie-gemma-3-270m-it"
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
model = AutoModelForCausalLM.from_pretrained(
MODEL_PATH,
dtype=torch.bfloat16, # use bfloat16 if supported, else float16/cpu
device_map="auto" # automatically use GPU if available
)
def chat(system_prompt: str, user_prompt: str, max_new_tokens: int = 4096):
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": user_prompt}
]
input_ids = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_tensors="pt"
).to(model.device)
outputs = model.generate(
input_ids=input_ids,
max_new_tokens=max_new_tokens,
temperature=0.1,
top_p=0.95,
)
response = tokenizer.decode(outputs[0][input_ids.shape[-1]:], skip_special_tokens=True)
return response
if __name__ == "__main__":
system_prompt = "Extract given email to 5W1H in JSON format"
user_prompt = """
{Copy and paste text to be converted to 5W1H JSON here}
"""
reply = chat(system_prompt, user_prompt)
print("Assistant: \n", reply)
Refer GGUF version of this model https://huggingface.co/ChrisZhang312/kie-gemma-3-270m-it-gguf for more detail