Token Classification
Transformers
Safetensors
Vietnamese
mbart
feature-extraction
vietnamese
spell-check
spelling-correction
grammatical-error-correction
error-detection
bartpho
custom_code
Eval Results (legacy)
Instructions to use bravend/bartpho-syllable-vi-spellcheck with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use bravend/bartpho-syllable-vi-spellcheck with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="bravend/bartpho-syllable-vi-spellcheck", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("bravend/bartpho-syllable-vi-spellcheck", trust_remote_code=True) model = AutoModel.from_pretrained("bravend/bartpho-syllable-vi-spellcheck", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download tokenization_spellcheck.py from bravend/bartpho-syllable-vi-spellcheck: direct link, hf CLI and curl.
- Browser
- Download file 1.08 kB
-
https://huggingface.co/bravend/bartpho-syllable-vi-spellcheck/resolve/main/tokenization_spellcheck.py
- Command line
-
hf download hf://bravend/bartpho-syllable-vi-spellcheck/tokenization_spellcheck.py
-
curl -L -o tokenization_spellcheck.py https://huggingface.co/bravend/bartpho-syllable-vi-spellcheck/resolve/main/tokenization_spellcheck.py
1.08 kB
| """BartphoTokenizer whose SentencePiece model is restricted to the 40K reduced vocab. | |
| Stock BartphoTokenizer segments with the full 250K-piece SentencePiece model and | |
| only afterwards maps pieces to the 40K fairseq dictionary: any piece outside the | |
| dictionary becomes a single ``<unk>`` even when its characters are all known. | |
| Restricting SentencePiece to the final vocabulary makes rare strings fall back to | |
| smaller known pieces. The model was trained with this tokenizer, so inference must | |
| use it too (load with ``AutoTokenizer.from_pretrained(..., trust_remote_code=True)``). | |
| """ | |
| from transformers import BartphoTokenizer as _BartphoTokenizer | |
| class RestrictedBartphoTokenizer(_BartphoTokenizer): | |
| def __init__(self, *args, **kwargs): | |
| super().__init__(*args, **kwargs) | |
| self.restrict_sp_to_vocab() | |
| def restrict_sp_to_vocab(self): | |
| sp = self.sp_model | |
| sp.set_vocabulary([p for p in self.get_vocab() if sp.piece_to_id(p) != sp.unk_id()]) | |
| def __setstate__(self, d): | |
| super().__setstate__(d) | |
| self.restrict_sp_to_vocab() | |