Download overcorrection_warning.js from anmol-unitmole/05-grammar-error-correction-t5-encoder-decoder: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/spaces/anmol-unitmole/05-grammar-error-correction-t5-encoder-decoder/resolve/main/overcorrection_warning.js
- Command line
-
hf download hf://spaces/anmol-unitmole/05-grammar-error-correction-t5-encoder-decoder/overcorrection_warning.js
-
curl -L -o overcorrection_warning.js https://huggingface.co/spaces/anmol-unitmole/05-grammar-error-correction-t5-encoder-decoder/resolve/main/overcorrection_warning.js
1.04 kB
| export function detectOvercorrection(tracked, meaning, sourceMarkedCorrect = false, categories = []) { | |
| const editRatio = tracked.changedTokenCount / Math.max(1, tracked.sourceTokenCount); | |
| const reasons = []; | |
| if (editRatio > 0.45) reasons.push('A large share of source tokens changed.'); | |
| if (meaning.score < 0.72) reasons.push('Meaning-preservation score is below the review threshold.'); | |
| if (!meaning.numberPreserved) reasons.push('A number changed.'); | |
| if (!meaning.namedEntitiesPreserved) reasons.push('A named entity may have changed.'); | |
| if (sourceMarkedCorrect && tracked.changedTokenCount > 0) reasons.push('The source was marked correct but changed.'); | |
| if (categories.filter((category) => category === 'Style / fluency').length >= 2) reasons.push('Style changes dominate the correction.'); | |
| return { | |
| flag: reasons.length > 0, | |
| editRatio, | |
| reasons, | |
| message: reasons.length ? 'The model may have over-corrected this text. Please review the changes carefully.' : 'No over-correction warning detected.', | |
| }; | |
| } | |