Instructions to use ModelsLab/punctuate-indic-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ModelsLab/punctuate-indic-v1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="ModelsLab/punctuate-indic-v1")# Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("ModelsLab/punctuate-indic-v1") model = AutoModelForTokenClassification.from_pretrained("ModelsLab/punctuate-indic-v1", device_map="auto") - Notebooks
- Google Colab
- Kaggle
| license: mit | |
| datasets: | |
| - CohereForAI/aya_collection_language_split | |
| metrics: | |
| - f1 | |
| - recall | |
| - precision | |
| language: | |
| - te | |
| - kn | |
| - gu | |
| - mr | |
| - ml | |
| - bn | |
| - pa | |
| - ta | |
| library_name: transformers | |
| This is based on [Kredor's work](https://huggingface.co/kredor/punctuate-all). But the languages are: Telugu, Tamil, Malayalam, Kannada, Gujarathi, Panjabi, Marathi and Bengali. | |
| ----- report ----- | |
| precision recall f1-score support | |
| 0 0.99 0.99 0.99 18156530 | |
| . 0.95 0.95 0.95 987478 | |
| , 0.82 0.79 0.80 1064002 | |
| ? 0.97 0.96 0.97 316902 | |
| - 0.94 0.86 0.90 226991 | |
| : 0.94 0.96 0.95 262314 | |
| accuracy 0.97 21014217 | |
| macro avg 0.93 0.92 0.93 21014217 | |
| weighted avg 0.97 0.97 0.97 21014217 | |
| ----- confusion matrix ----- | |
| t/p 0 . , ? - : | |
| 0 1.0 0.0 0.0 0.0 0.0 0.0 | |
| . 0.0 1.0 0.0 0.0 0.0 0.0 | |
| , 0.2 0.0 0.8 0.0 0.0 0.0 | |
| ? 0.0 0.0 0.0 1.0 0.0 0.0 | |
| - 0.1 0.0 0.0 0.0 0.9 0.0 | |
| : 0.0 0.0 0.0 0.0 0.0 1.0 | |
| ## Install | |
| To get started install the package from [pypi](https://pypi.org/project/deepmultilingualpunctuation/): | |
| ```bash | |
| pip install deepmultilingualpunctuation | |
| ``` | |
| ### Restore Punctuation | |
| ```python | |
| from deepmultilingualpunctuation import PunctuationModel | |
| model = PunctuationModel('ModelsLab/punctuate-indic-v1') | |
| text = "హ్యారీ చాలా చిన్న వ్యవసాయ కలిగి ఒక పెద్ద పొలం కావాలని కలలు కనేవాడు ఒకసారి తన తండ్రి బిల్ ను అడిగాడు అక్కడి భూమి నాకు కావాలి నేను దాన్ని ఎలా పొందగలను" | |
| result = model.restore_punctuation(text) | |
| print(result) | |
| ``` | |
| **output** | |
| > హ్యారీ చాలా చిన్న వ్యవసాయ కలిగి ఒక పెద్ద పొలం కావాలని కలలు కనేవాడు ఒకసారి తన తండ్రి బిల్ ను అడిగాడు, అక్కడి భూమి నాకు కావాలి, నేను దాన్ని ఎలా పొందగలను? | |
| ### Predict Labels | |
| ```python | |
| from deepmultilingualpunctuation import PunctuationModel | |
| model = PunctuationModel('ModelsLab/punctuate-indic-v1') | |
| text = "హ్యారీ చాలా చిన్న వ్యవసాయ కలిగి ఒక పెద్ద పొలం కావాలని కలలు కనేవాడు ఒకసారి తన తండ్రి బిల్ ను అడిగాడు అక్కడి భూమి నాకు కావాలి నేను దాన్ని ఎలా పొందగలను" | |
| clean_text = model.preprocess(text) | |
| labled_words = model.predict(clean_text) | |
| print(labled_words) | |
| ``` | |
| **output** | |
| > ['హ్యారీ', '0', 0.7721978], | |
| ['చాలా', '0', 0.9996537], | |
| ['చిన్న', '0', 0.9703038], | |
| ['వ్యవసాయ', '0', 0.99389863], | |
| ['కలిగి', '0', 0.66695035], | |
| ['ఒక', '0', 0.99995697], | |
| ['పెద్ద', '0', 0.9995778], | |
| ['పొలం', '0', 0.999982], | |
| ['కావాలని', '0', 0.9995049], | |
| ['కలలు', '0', 0.99998343], | |
| ['కనేవాడు', '0', 0.3442819], | |
| ['ఒకసారి', '0', 0.925744], | |
| ['తన', '0', 0.9999279], | |
| ['తండ్రి', '0', 0.82426786], | |
| ['బిల్', '0', 0.9998516], | |
| ['ను', '0', 0.99997056], | |
| ['అడిగాడు', ',', 0.55599153], | |
| ['అక్కడి', '0', 0.9996816], | |
| ['భూమి', '0', 0.9978115], | |
| ['నాకు', '0', 0.9999769], | |
| ['కావాలి', ',', 0.873619], | |
| ['నేను', '0', 0.99976164], | |
| ['దాన్ని', '0', 0.999979], | |
| ['ఎలా', '0', 0.99997866], | |
| ['పొందగలను', '?', 0.9895349] | |