nikolasmoya's picture
Update README.md
3e6cb23
|
raw
history blame
No virus
2.41 kB
---
license: mit
base_model: roberta-base
tags:
- generated_from_trainer
metrics:
- accuracy
- matthews_correlation
model-index:
- name: c4-binary-english-grammar-checker
results: []
---
# Usage instructions:
The recommendation is to split the text into sentences and evaluate sentence by sentence, you can do that using spacy:
```
import spacy
def clean_up_sentence(text: str) -> str:
text = text.replace("---", "")
text = text.replace("\n", " ")
text = text.strip()
if not text.endswith(('.', '!', '?', ":")):
# Since we are breaking a longer text into sentences ourselves, we should always end a sentence with a period.
text = text + "."
return text
sentence_splitter = spacy.load("en_core_web_sm")
spacy_document = sentence_splitter("This is a long text. It has two or more sentence. Spacy will break it down into sentences.")
results = []
for sentence in spacy_document.sents:
clean_text = clean_up_sentence(str(sentence))
classification = grammar_checker(clean_text)[0]
results.append({
"label": classification['label'],
"score": classification['score'],
"sentence": clean_text
})
pd.DataFrame.from_dict(results)
```
# c4-binary-english-grammar-checker
This model is a fine-tuned version of [roberta-base](https://huggingface.co/roberta-base) on the None dataset.
It achieves the following results on the evaluation set:
- Loss: 0.3546
- Accuracy: 0.8577
- Matthews Correlation: 0.7192
## Model description
More information needed
## Intended uses & limitations
More information needed
## Training and evaluation data
More information needed
## Training procedure
### Training hyperparameters
The following hyperparameters were used during training:
- learning_rate: 2e-05
- train_batch_size: 16
- eval_batch_size: 16
- seed: 42
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
- lr_scheduler_type: linear
- num_epochs: 2
### Training results
| Training Loss | Epoch | Step | Validation Loss | Accuracy | Matthews Correlation |
|:-------------:|:-----:|:------:|:---------------:|:--------:|:--------------------:|
| 0.363 | 1.0 | 200000 | 0.3634 | 0.8487 | 0.7025 |
| 0.3032 | 2.0 | 400000 | 0.3546 | 0.8577 | 0.7192 |
### Framework versions
- Transformers 4.32.1
- Pytorch 2.0.1+cu118
- Datasets 2.14.4
- Tokenizers 0.13.3