Views
No views yet
CAMeL-Lab/text-editing-coda is a text editing model tailored for grammatical error correction (GEC) in dialectal Arabic (DA).
The model is based on AraBERTv02, which we fine-tuned using the MADAR CODA corpus.
This model was introduced in our ACL 2025 paper, Enhancing Text Editing for Grammatical Error Correction: Arabic as a Case Study, where we refer to it as SWEET (Subword Edit Error Tagger).
It achieved SOTA performance on the MADAR CODA dataset. Details about the training procedure, data preprocessing, and hyperparameters are available in the paper.
The fine-tuning code and associated resources are publicly available on our GitHub repository: https://github.com/CAMeL-Lab/text-editing.CAMeL-Lab/text-editing-coda model, you must clone our text editing GitHub repository and follow the installation requirements.
We used this SWEET model to report results on the MADAR CODA dev and test sets in our paper.1from transformers import BertTokenizer, BertForTokenClassification
2import torch
3import torch.nn.functional as F
4from gec.tag import rewrite
5
6tokenizer = BertTokenizer.from_pretrained('CAMeL-Lab/text-editing-coda')
7model = BertForTokenClassification.from_pretrained('CAMeL-Lab/text-editing-coda')
8
9text = 'أنا بعطيك رقم تلفونو و عنوانو'.split()
10
11tokenized_text = tokenizer(text, return_tensors="pt", is_split_into_words=True)
12
13with torch.no_grad():
14 logits = model(**tokenized_text).logits
15 preds = F.softmax(logits.squeeze(), dim=-1)
16 preds = torch.argmax(preds, dim=-1).cpu().numpy()
17 edits = [model.config.id2label[p] for p in preds[1:-1]]
18 assert len(edits) == len(tokenized_text['input_ids'][0][1:-1])
19
20print(edits) # ['R_[ا]K*', 'K*I_[ا]K', 'K*', 'K*', 'K*', 'K*', 'K*R_[ه]', 'K*', 'MK*', 'R_[ه]']
21subwords = tokenizer.convert_ids_to_tokens(tokenized_text['input_ids'][0][1:-1])
22output_sent = rewrite(subwords=[subwords], edits=[edits])[0][0]
23print(output_sent) # انا باعطيك رقم تلفونه وعنوانه1@inter{alhafni-habash-2025-enhancing,
2 title={Enhancing Text Editing for Grammatical Error Correction: Arabic as a Case Study},
3 author={Bashar Alhafni and Nizar Habash},
4 year={2025},
5 eprint={2503.00985},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL},
8 url={https://arxiv.org/abs/2503.00985},
9}