Instructions to use pere/nb-nn-dev2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use pere/nb-nn-dev2 with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "translation" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # pip install "transformers<5.0.0" from transformers import pipeline pipe = pipeline("translation", model="pere/nb-nn-dev2")# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("pere/nb-nn-dev2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from pere/nb-nn-dev2: direct link, hf CLI and curl.
- Browser
- Download file 1.3 kB
-
https://huggingface.co/pere/nb-nn-dev2/resolve/main/README.md
- Command line
-
hf download hf://pere/nb-nn-dev2/README.md
-
curl -L -o README.md https://huggingface.co/pere/nb-nn-dev2/resolve/main/README.md
1.3 kB
metadata
language: 'no'
license: cc-by-4.0
tags:
- translation
datasets:
- oscar
widget:
- text: Skriv inn en tekst som du ønsker å oversette til en annen målform.
Norwegian T5 - Translation Bokmål Nynorsk - Development
Description
This is the development version of the Bokmål-Nynorsk translator. If you want something that is stable, Please do run this version instead.
Here is an example of how to use the model from Python
# Import libraries
from transformers import T5ForConditionalGeneration, AutoTokenizer
model = T5ForConditionalGeneration.from_pretrained('pere/nb-nn-dev',from_flax=True)
tokenizer = AutoTokenizer.from_pretrained('pere/nb-nn-dev')
#Encode the text
text = "Hun vil ikke gi bort sine personlige data."
inputs = tokenizer.encode(text, return_tensors="pt")
outputs = model.generate(inputs, max_length=255, num_beams=4, early_stopping=True)
#Decode and print the result
print(tokenizer.decode(outputs[0]))
Or if you like to use the pipeline instead
# Set up the pipeline
from transformers import pipeline
translator = pipeline("translation", model='pere/nb-nn-dev')
# Do the translation
text = "Hun vil ikke gi bort sine personlige data."
print(translator(text, max_length=255))