transformers tensorboard safetensors t5 text2text-generation nb nn dataset:NbAiLab/nbnn_translation autotrain_compatible endpoints_compatible text-generation-inference region:us
---
datasets:
- NbAiLab/nbnn_translation
language:
- nb
- nn
widget:
- text: Jeg heter John.
---

# Model Description: mT5 Small (Bokmål to Nynorsk Translation)

**Note: This fine-tuned model is intended for testing purposes only.**

## Model Name
Kushtrim/mT5-small-nbo-nno-test

## Overview
The mT5 Small Bokmål-Nynorsk Translator is a test model fine-tuned for translating text between two closely related Norwegian languages: Bokmål and Nynorsk. This model is based on the mT5 architecture, which is a variant of the T5 (Text-To-Text Transfer Transformer) architecture developed by Google fine-tuned on [NbAiLab/nbnn_translation](https://huggingface.co/datasets/NbAiLab/nbnn_language_detection) dataset. T5 is designed for a wide range of text generation tasks, and mT5 (multilingual T5) is a multilingual variant that excels in handling multiple languages.

## Language Pairs
- Source Language: Bokmål (Norwegian Bokmål)
- Target Language: Nynorsk (Norwegian Nynorsk)

## Key Features
- Translation: The primary function of this model is to provide high-quality translations from Bokmål to Nynorsk. It understands the nuances of both languages, ensuring accurate and contextually relevant translations.

- Small Footprint: The "Small" variant of mT5 is designed for applications that require a more lightweight model. It provides a balance between performance and computational efficiency, making it suitable for a variety of translation tasks.

## Intended Use
The mT5 Small Bokmål-Nynorsk Translator is intended for a range of applications that require translating text between the Bokmål and Nynorsk languages. Use cases include but are not limited to:

1. Document Translation: Translate documents, articles, or web pages from Bokmål to Nynorsk and vice versa.

## Limitations
1. Vocabulary: Like all models, mT5 Small has a fixed vocabulary, and it may struggle with translating very rare or domain-specific terms.

2. Context Sensitivity: The model's translations are context-sensitive to some extent, but complex contextual understanding may still pose challenges.

3. Length Constraints: Extremely long sentences may be truncated or split for translation.

## Usage Instructions
```python
from transformers import pipeline, AutoTokenizer, AutoModelForSeq2SeqLM

tokenizer = AutoTokenizer.from_pretrained("Kushtrim/mT5-small-nbo-nno-test")
model = AutoModelForSeq2SeqLM.from_pretrained("Kushtrim/mT5-small-nbo-nno-test")

text = "Jeg heter John."

ids = tokenizer(text, return_tensors="pt").input_ids

outputs = model.generate(ids, num_beams=10, num_return_sequences=1, no_repeat_ngram_size=1, remove_invalid_values=True)
print("Output:\n" + 100 * '-')
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
```

**Note:** When using this model, it's recommended to evaluate the translations for your specific use case and potentially post-edit them to ensure linguistic and contextual accuracy, as machine translation models can have limitations, especially for languages with nuanced differences like Bokmål and Nynorsk.