YAML Metadata
Warning:
empty or missing yaml metadata in repo card
(https://huggingface.co/docs/hub/model-cards#model-card-metadata)
Usage
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_id = "mzbac/Qwen2-7B-grammar-correction"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
)
messages = [
{
"role": "system",
"content": "Please correct, polish, or translate the text delimited by triple backticks to standard English.",
},
{
"role": "user",
"content": "Text=```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))
# <|im_start|>system
# Please correct, polish, or translate the text delimited by triple backticks to standard English.<|im_end|>
# <|im_start|>user
# Text=```neither ็ป็ๆๅๅทฅ has been informed about the meeting```<|im_end|>
# <|im_start|>assistant
# Output=Neither the manager nor the employees have been informed about the meeting.<|im_end|>
- Downloads last month
- 22
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social
visibility and check back later, or deploy to Inference Endpoints (dedicated)
instead.