Views
No views yet
localgrammar-qwen25-3b-lora-v1 is a LoRA adapter for unsloth/qwen2.5-3b-instruct-unsloth-bnb-4bit specialized for local English rewriting.| 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. |
TASK_PHRASING tag. If you want a general phrasing rewrite, use:TASK_CLARITY for sentence-level rewordingTASK_COHERENCE for flow and structure improvementsYou are a precise local writing engine. Follow the requested task exactly. Preserve the user's meaning.1LANG_EN | TASK_...
2Instruction: ...
3Input: ...1LANG_EN | TASK_GRAMMAR
2Instruction: Fix grammar, spelling, punctuation, and agreement errors with minimal edits. Preserve meaning and style.
3Input: She go to school yesterday.1import torch
2from peft import PeftModel
3from transformers import AutoModelForCausalLM, AutoTokenizer
4
5base_model_id = "unsloth/qwen2.5-3b-instruct-unsloth-bnb-4bit"
6adapter_id = "johan237/localgrammar-qwen25-3b-lora-v1"
7
8tokenizer = AutoTokenizer.from_pretrained(adapter_id, trust_remote_code=True)
9base_model = AutoModelForCausalLM.from_pretrained(
10 base_model_id,
11 trust_remote_code=True,
12 device_map="auto",
13)
14model = PeftModel.from_pretrained(base_model, adapter_id)
15model.eval()
16
17messages = [
18 {
19 "role": "system",
20 "content": (
21 "You are a precise local writing engine. "
22 "Follow the requested task exactly. Preserve the user's meaning."
23 ),
24 },
25 {
26 "role": "user",
27 "content": (
28 "LANG_EN | TASK_GRAMMAR\n"
29 "Instruction: Fix grammar, spelling, punctuation, and agreement "
30 "errors with minimal edits. Preserve meaning and style.\n"
31 "Input: She go to school yesterday."
32 ),
33 },
34]
35
36text = tokenizer.apply_chat_template(
37 messages,
38 tokenize=False,
39 add_generation_prompt=True,
40)
41inputs = tokenizer(text, return_tensors="pt").to(model.device)
42
43with torch.inference_mode():
44 output_ids = model.generate(
45 **inputs,
46 max_new_tokens=64,
47 do_sample=False,
48 temperature=0.0,
49 )
50
51generated_ids = output_ids[0][inputs["input_ids"].shape[-1]:]
52print(tokenizer.decode(generated_ids, skip_special_tokens=True))She went to school yesterday.grammarly/coeditjhu-clsp/jflegfacebook/assetchaojiang06/wiki_auto42,24742,0352,212TASK_GRAMMAR: 20,000TASK_SIMPLIFY: 15,000TASK_COHERENCE: 8,000TASK_CLARITY: 1,247adapter_config.json:r=16lora_alpha=32lora_dropout=0q_projk_projv_projo_projgate_projup_projdown_proj1 epoch1855 total training steps250 steps250 steps0.400720.19.10.24.05.5.02.5.1+cu1214.3.00.22.2TASK_CLARITY has much less training data than grammar or simplificationQwen/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_auto1@misc{vonwerra2022trl,
2 title = {TRL: Transformer Reinforcement Learning},
3 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},
4 year = {2020},
5 journal = {GitHub repository},
6 publisher = {GitHub},
7 howpublished = {\url{https://github.com/huggingface/trl}}
8}