File size: 2,411 Bytes
d7d5bd5
 
 
 
 
 
 
df3589a
d7d5bd5
 
 
 
 
3e6cb23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
d7d5bd5
 
 
 
 
df3589a
 
 
d7d5bd5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
df3589a
d7d5bd5
 
 
df3589a
 
 
 
d7d5bd5
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
---
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