Downloads · 30 days
11
29% of all-time downloads
mzbac/gemma-2-9b-grammar-correction
gemma-2-9b-grammar-correction is a text generation model from mzbac. Use it when you need the model to write or continue text. It is set up for transformers.
neither 经理或员工 has been informed about the meeting neither 经理或员工 has been informed about the meeting<endofturn
Downloads · 30 days
11
29% of all-time downloads
All-time downloads
38
Public
Parameters
9.2B
33.7 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors18.5 GB · 100%
From the Hugging Face model README
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_id = "mzbac/gemma-2-9b-grammar-correction"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
)
messages = [
{
"role": "user",
"content": "Please correct, polish, or translate the text delimited by triple backticks to standard English\nText=```neither 经理或员工 has been informed about the meeting```",
},
]
input_ids = tokenizer.apply_chat_template(
messages, add_generation_prompt=True, return_tensors="pt"
).to(model.device)
terminators = [tokenizer.eos_token_id, tokenizer.convert_tokens_to_ids("<|im_end|>")]
outputs = model.generate(
input_ids,
max_new_tokens=256,
eos_token_id=terminators,
do_sample=True,
temperature=0.1,
)
response = outputs[0]
print(tokenizer.decode(response))
# <bos><start_of_turn>user
# Please correct, polish, or translate the text delimited by triple backticks to standard English
# Text=```neither 经理或员工 has been informed about the meeting```<end_of_turn>
# <start_of_turn>model
# Output=Neither the manager nor the employees have been informed about the meeting.<end_of_turn>
# <eos>