A
BART
model trained on a Swedish corpus consisting of 15 billion tokens (about 80GB of text). The model was trained with
Fairseq
, and converted to be compatible with Huggingface.
from transformers import BartForConditionalGeneration, PreTrainedTokenizerFast, AutoTokenizer
model = BartForConditionalGeneration.from_pretrained("KBLab/bart-base-swedish-cased")
tok = AutoTokenizer.from_pretrained("KBLab/bart-base-swedish-cased")
model.eval()
input_ids = tok.encode(
"Jag har ätit en utsökt <mask> på restaurang vid <mask> .", return_tensors="pt"
)
# Simple greedy search
output_ids = model.generate(
input_ids,
min_length=15,
max_length=25,
num_beams=1,
do_sample=False,
)
tok.decode(output_ids[0])
# '</s><s> Jag har ätit en utsökt middag på restaurang vid havet på restaurang vid havet på restaurang vid havet.</s>'# Sampling
output_ids = model.generate(
input_ids,
min_length=15,
max_length=20,
num_beams=1,
do_sample=True,
)
tok.decode(output_ids[0])
#'</s><s> Jag har ätit en utsökt god mat som de tagit in på restaurang vid avröjda</s>'# Beam search
output_ids = model.generate(
input_ids,
min_length=15,
max_length=25,
no_repeat_ngram_size=3,
num_beams=8,
early_stopping=True,
do_sample=True,
num_return_sequences=6
)
tok.decode(output_ids[0])
# '</s><s> Jag har ätit en utsökt middag på restaurang vid havet. Jag har varit ute och gått en sväng.</s><pad><pad>'# Diverse beam generation
output_ids = model.generate(
input_ids,
min_length=50,
max_length=100,
no_repeat_ngram_size=3,
num_beams=8,
early_stopping=True,
do_sample=False,
num_return_sequences=6,
num_beam_groups=8,
diversity_penalty=2.0,
)
tok.decode(output_ids[0])
# '</s><s> Jag har ätit en utsökt middag på restaurang vid havet på restaurang. Jag har varit på restaurang i två dagar... Jag..,..!!!.. Så.. Nu.. Hej.. Vi.. Här.</s>'
Acknowledgements
We gratefully acknowledge the HPC RIVR consortium (
www.hpc-rivr.si
) and EuroHPC JU (
eurohpc-ju.europa.eu/
) for funding this research by providing computing resources of the HPC system Vega at the Institute of Information Science (
www.izum.si
).
Runs of KBLab bart-base-swedish-cased on huggingface.co
2.9K
Total runs
906
24-hour runs
1.1K
3-day runs
1.2K
7-day runs
2.4K
30-day runs
More Information About bart-base-swedish-cased huggingface.co Model
bart-base-swedish-cased huggingface.co
bart-base-swedish-cased huggingface.co is an AI model on huggingface.co that provides bart-base-swedish-cased's model effect (), which can be used instantly with this KBLab bart-base-swedish-cased model. huggingface.co supports a free trial of the bart-base-swedish-cased model, and also provides paid use of the bart-base-swedish-cased. Support call bart-base-swedish-cased model through api, including Node.js, Python, http.
bart-base-swedish-cased huggingface.co is an online trial and call api platform, which integrates bart-base-swedish-cased's modeling effects, including api services, and provides a free online trial of bart-base-swedish-cased, you can try bart-base-swedish-cased online for free by clicking the link below.
KBLab bart-base-swedish-cased online free url in huggingface.co:
bart-base-swedish-cased is an open source model from GitHub that offers a free installation service, and any user can find bart-base-swedish-cased on GitHub to install. At the same time, huggingface.co provides the effect of bart-base-swedish-cased install, users can directly use bart-base-swedish-cased installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
bart-base-swedish-cased install url in huggingface.co: