The model was fine-tuned to fix punctuation (i.e., Pnx) errors. 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
.
Intended uses
To use the
CAMeL-Lab/text-editing-qalb14-pnx
model, you must clone our text editing
GitHub repository
and follow the installation requirements.
We used this SWEET
Pnx
model to report results on the QALB-2014 dev and test sets in our
paper
.
This model is intended to be used with SWEET
NoPnx
(
CAMeL-Lab/text-editing-qalb14-nopnx
) model.
How to use
Clone our text editing
GitHub repository
and follow the installation requirements
from transformers import BertTokenizer, BertForTokenClassification
import torch
import torch.nn.functional as F
from gec.tag import rewrite
nopnx_tokenizer = BertTokenizer.from_pretrained('CAMeL-Lab/text-editing-qalb14-nopnx')
nopnx_model = BertForTokenClassification.from_pretrained('CAMeL-Lab/text-editing-qalb14-nopnx')
pnx_tokenizer = BertTokenizer.from_pretrained('CAMeL-Lab/text-editing-qalb14-pnx')
pnx_model = BertForTokenClassification.from_pretrained('CAMeL-Lab/text-editing-qalb14-pnx')
defpredict(model, tokenizer, text, decode_iter=1):
for _ inrange(decode_iter):
tokenized_text = tokenizer(text, return_tensors="pt", is_split_into_words=True)
with torch.no_grad():
logits = model(**tokenized_text).logits
preds = F.softmax(logits.squeeze(), dim=-1)
preds = torch.argmax(preds, dim=-1).cpu().numpy()
edits = [model.config.id2label[p] for p in preds[1:-1]]
assertlen(edits) == len(tokenized_text['input_ids'][0][1:-1])
subwords = tokenizer.convert_ids_to_tokens(tokenized_text['input_ids'][0][1:-1])
text = rewrite(subwords=[subwords], edits=[edits])[0][0]
return text
text = 'يجب الإهتمام ب الصحه و لا سيما ف ي الصحه النفسيه ياشباب المستقبل،،'.split()
output_sent = predict(nopnx_model, nopnx_tokenizer, text, decode_iter=2)
output_sent = predict(pnx_model, pnx_tokenizer, output_sent.split(), decode_iter=1)
print(output_sent) # يجب الاهتمام بالصحة ولا سيما في الصحة النفسية يا شباب المستقبل .
Citation
@inter{alhafni-habash-2025-enhancing,
title={Enhancing Text Editing for Grammatical Error Correction: Arabic as a Case Study},
author={Bashar Alhafni and Nizar Habash},
year={2025},
eprint={2503.00985},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2503.00985},
}
Runs of CAMeL-Lab text-editing-qalb14-pnx on huggingface.co
33
Total runs
-6
24-hour runs
-19
3-day runs
-23
7-day runs
-90
30-day runs
More Information About text-editing-qalb14-pnx huggingface.co Model
text-editing-qalb14-pnx huggingface.co is an AI model on huggingface.co that provides text-editing-qalb14-pnx's model effect (), which can be used instantly with this CAMeL-Lab text-editing-qalb14-pnx model. huggingface.co supports a free trial of the text-editing-qalb14-pnx model, and also provides paid use of the text-editing-qalb14-pnx. Support call text-editing-qalb14-pnx model through api, including Node.js, Python, http.
text-editing-qalb14-pnx huggingface.co is an online trial and call api platform, which integrates text-editing-qalb14-pnx's modeling effects, including api services, and provides a free online trial of text-editing-qalb14-pnx, you can try text-editing-qalb14-pnx online for free by clicking the link below.
CAMeL-Lab text-editing-qalb14-pnx online free url in huggingface.co:
text-editing-qalb14-pnx is an open source model from GitHub that offers a free installation service, and any user can find text-editing-qalb14-pnx on GitHub to install. At the same time, huggingface.co provides the effect of text-editing-qalb14-pnx install, users can directly use text-editing-qalb14-pnx installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
text-editing-qalb14-pnx install url in huggingface.co: