Downloads · 30 days
13
19% of all-time downloads
johan237/localgrammar-qwen25-3b-lora-v1
localgrammar-qwen25-3b-lora-v1 is a text generation model from johan237. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as other.
localgrammar-qwen25-3b-lora-v1 is a LoRA adapter for unsloth/qwen2.5-3b-instruct-unsloth-bnb-4bit specialized for local English rewriting.
Downloads · 30 days
13
19% of all-time downloads
All-time downloads
68
Public
Repo size
131 MB
Likes
0
Public
Click a slice to open those files.
.safetensors120 MB · 91%
From the Hugging Face model README
localgrammar-qwen25-3b-lora-v1 is a LoRA adapter for unsloth/qwen2.5-3b-instruct-unsloth-bnb-4bit specialized for local English rewriting.
It was fine-tuned for four controlled rewrite tasks:
| App action | Training tag | Purpose |
|---|---|---|
grammar | TASK_GRAMMAR | Fix grammar, spelling, punctuation, and agreement errors with minimal edits while preserving meaning and style. |
simplify | TASK_SIMPLIFY | Make the text simpler and easier to understand while preserving meaning. |
clarity | TASK_CLARITY | Make the text clearer and easier to understand while preserving meaning. |
coherence | TASK_COHERENCE | Improve flow, structure, and coherence while preserving meaning. |
There is no separate TASK_PHRASING tag. If you want a general phrasing rewrite, use:
TASK_CLARITY for sentence-level rewordingTASK_COHERENCE for flow and structure improvementsThis repository contains the adapter weights and tokenizer assets. It is not a standalone base model.
This adapter is intended for:
It is not intended as a general-purpose open-ended chat assistant.
The adapter expects the task to be stated explicitly in the user message.
During fine-tuning, each example used:
You are a precise local writing engine. Follow the requested task exactly. Preserve the user's meaning.LANG_EN | TASK_...
Instruction: ...
Input: ...
Example for grammar correction:
LANG_EN | TASK_GRAMMAR
Instruction: Fix grammar, spelling, punctuation, and agreement errors with minimal edits. Preserve meaning and style.
Input: She go to school yesterday.
Load this adapter on top of the base model with PEFT.
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base_model_id = "unsloth/qwen2.5-3b-instruct-unsloth-bnb-4bit"
adapter_id = "johan237/localgrammar-qwen25-3b-lora-v1"
tokenizer = AutoTokenizer.from_pretrained(adapter_id, trust_remote_code=True)
base_model = AutoModelForCausalLM.from_pretrained(
base_model_id,
trust_remote_code=True,
device_map="auto",
)
model = PeftModel.from_pretrained(base_model, adapter_id)
model.eval()
messages = [
{
"role": "system",
"content": (
"You are a precise local writing engine. "
"Follow the requested task exactly. Preserve the user's meaning."
),
},
{
"role": "user",
"content": (
"LANG_EN | TASK_GRAMMAR\n"
"Instruction: Fix grammar, spelling, punctuation, and agreement "
"errors with minimal edits. Preserve meaning and style.\n"
"Input: She go to school yesterday."
),
},
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
with torch.inference_mode():
output_ids = model.generate(
**inputs,
max_new_tokens=64,
do_sample=False,
temperature=0.0,
)
generated_ids = output_ids[0][inputs["input_ids"].shape[-1]:]
print(tokenizer.decode(generated_ids, skip_special_tokens=True))
Expected output:
She went to school yesterday.
This adapter was fine-tuned with supervised fine-tuning on a chat-formatted English rewrite dataset assembled for local writing assistance.
The training set was built from:
grammarly/coeditjhu-clsp/jflegfacebook/assetchaojiang06/wiki_autoThe dataset compiler:
42,24742,0352,212Task distribution:
TASK_GRAMMAR: 20,000TASK_SIMPLIFY: 15,000TASK_COHERENCE: 8,000TASK_CLARITY: 1,247Dataset usage:
From adapter_config.json:
r=16lora_alpha=32lora_dropout=0q_projk_projv_projo_projgate_projup_projdown_projFrom the saved trainer state:
1 epoch1855 total training steps250 steps250 steps0.40072The exported training metadata reported:
0.19.10.24.05.5.02.5.1+cu1214.3.00.22.2TASK_CLARITY has much less training data than grammar or simplificationThe base model Qwen/Qwen2.5-3B-Instruct is published on Hugging Face under the qwen-research license. This adapter should be used and redistributed in compliance with the upstream base-model license and the terms of the source datasets.
Qwen/Qwen2.5-3B-Instructunsloth/qwen2.5-3b-instruct-unsloth-bnb-4bitgrammarly/coeditjhu-clsp/jflegfacebook/assetchaojiang06/wiki_autoIf you use this adapter, cite the base model, the source datasets, and your own project/repository in addition to standard library citations.
TRL citation:
@misc{vonwerra2022trl,
title = {TRL: Transformer Reinforcement Learning},
author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallou{\'e}dec},
year = {2020},
journal = {GitHub repository},
publisher = {GitHub},
howpublished = {\url{https://github.com/huggingface/trl}}
}