CoolFace
Modelpublic

shanaka95/gemma-4-2b-finetuned-grammar2

sourceHugging Faceapache-2.0updated 4mo agoView on Hugging Face
0likes21downloads
Model Card

Gemma-4-E2B-it: CoEdIT Text Editing Model ✍️

  • —Developed by: Shanaka Anuradha
  • —License: Apache-2.0
  • —Base Model: google/gemma-4-E2B-it (optimized via unsloth/gemma-4-E2B-it)
  • —Finetuning Dataset: grammarly/coedit
  • —Language: English
  • —Task Focus: Text Editing, Grammatical Error Correction (GEC), Paraphrasing, Simplification, and Style Transfer.

This model is a specialized text-editing assistant fine-tuned on the Grammarly CoEdIT dataset. It takes an instruction alongside a source text and generates a revised, improved, or structurally altered version of that text based on the provided command.

This model was trained 2x faster and with significantly reduced memory usage thanks to Unsloth.

<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>


🎯 Intended Uses & Capabilities

This model is explicitly trained to follow natural language instructions for text revision tasks. You can prompt it to perform various editing operations:

  • —Grammatical Error Correction (GEC): "Fix grammatical errors in this sentence: ..."
  • —Text Simplification: "Make this text easier to understand: ..."
  • —Paraphrasing: "Rewrite this sentence in a different way: ..."
  • —Formality Transfer: "Make this text more formal: ..."
  • —Coherence & Flow: "Improve the flow and coherence of this paragraph: ..."
  • —Neutralization: "Make this sentence more neutral: ..."

Out-of-Scope Use

While highly capable at text revision, this model is not designed for open-ended chatbot conversations, long-form creative story generation, or answering factual trivia. Its strength lies in structural and stylistic transformations of existing text.


💻 How to Use

You can easily load and use this model via the transformers library.

python
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

model_id = "shanaka95/your-model-name-here" # Replace with your actual repo name

# Load tokenizer and model
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    device_map="auto",
    torch_dtype=torch.float16
)

# Format the input prompt (Instruction + Source Text)
instruction = "Fix all grammatical errors in this text:"
source_text = "When I grow up, I start to understand what he said is quite right."
prompt = f"{instruction} {source_text}"

inputs = tokenizer(prompt, return_tensors="pt").to("cuda")

# Generate the edited text
outputs = model.generate(**inputs, max_new_tokens=128)
edited_text = tokenizer.decode(outputs[0], skip_special_tokens=True)

print(edited_text)
# Expected output: "When I grow up, I will start to understand that what he said is quite right."