Absolutely! Punctuation restoration is a common NLP task, and there are several multilingual models available for this purpose. Here’s a quick overview and some recommendations:
1. Pretrained Multilingual Models for Punctuation Restoration
- Model:
oliverguhr/fullstop-punctuation-multilang-large
- Languages: English, German, French, Spanish, Italian, Dutch, Polish, Portuguese, Russian, Turkish, Arabic, Chinese, Japanese, Korean, Hindi, and more.
- Platform: Hugging Face Transformers
- Usage Example (Python):
from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
tokenizer = AutoTokenizer.from_pretrained("oliverguhr/fullstop-punctuation-multilang-large")
model = AutoModelForTokenClassification.from_pretrained("oliverguhr/fullstop-punctuation-multilang-large")
nlp = pipeline("ner", model=model, tokenizer=tokenizer, aggregation_strategy="simple")
text = "hello how are you i am fine thank you"
result = nlp(text)
print(result)
- Documentation: Hugging Face Model Card
- Framework: DeepPavlov
- Languages: English, Russian, and more (with some models)
- Usage: DeepPavlov provides ready-to-use pipelines for punctuation restoration.
- Languages: English, Russian, Ukrainian, and Kazakh.
- Features: Fast, lightweight, and easy to use.
2. How to Use (Example with Hugging Face Model)
Here’s a more detailed example using the oliverguhr/fullstop-punctuation-multilang-large model:
from transformers import pipeline
# Load the pipeline
punctuation_pipeline = pipeline(
"text2text-generation",
model="oliverguhr/fullstop-punctuation-multilang-large"
)
# Input text (no punctuation)
input_text = "bonjour comment ca va je vais bien merci"
# Restore punctuation
result = punctuation_pipeline(input_text)
print(result[0]['generated_text'])
3. Custom Training
If you need a model for a specific language or domain, you can fine-tune a multilingual transformer (like mBERT, XLM-RoBERTa) on your own punctuation-labeled data.
4. Online Demos
Let me know if you need code for a specific language, framework, or have a particular use case!