Views
No views yet

modeling_norbert.py, you should therefore load the model with trust_remote_code=True.1import torch
2from transformers import AutoTokenizer, AutoModelForMaskedLM
3
4tokenizer = AutoTokenizer.from_pretrained("ltg/norbert3-small")
5model = AutoModelForMaskedLM.from_pretrained("ltg/norbert3-small", trust_remote_code=True)
6
7mask_id = tokenizer.convert_tokens_to_ids("[MASK]")
8input_text = tokenizer("Nå ønsker de seg en[MASK] bolig.", return_tensors="pt")
9output_p = model(**input_text)
10output_text = torch.where(input_text.input_ids == mask_id, output_p.logits.argmax(-1), input_text.input_ids)
11
12# should output: '[CLS] Nå ønsker de seg en ny bolig.[SEP]'
13print(tokenizer.decode(output_text[0].tolist()))AutoModel, AutoModelMaskedLM, AutoModelForSequenceClassification, AutoModelForTokenClassification, AutoModelForQuestionAnswering and AutoModeltForMultipleChoice.1@inproceedings{samuel-etal-2023-norbench,
2 title = "{N}or{B}ench {--} A Benchmark for {N}orwegian Language Models",
3 author = "Samuel, David and
4 Kutuzov, Andrey and
5 Touileb, Samia and
6 Velldal, Erik and
7 {\O}vrelid, Lilja and
8 R{\o}nningstad, Egil and
9 Sigdel, Elina and
10 Palatkina, Anna",
11 booktitle = "Proceedings of the 24th Nordic Conference on Computational Linguistics (NoDaLiDa)",
12 month = may,
13 year = "2023",
14 address = "T{\'o}rshavn, Faroe Islands",
15 publisher = "University of Tartu Library",
16 url = "https://aclanthology.org/2023.nodalida-1.61",
17 pages = "618--633",
18 abstract = "We present NorBench: a streamlined suite of NLP tasks and probes for evaluating Norwegian language models (LMs) on standardized data splits and evaluation metrics. We also introduce a range of new Norwegian language models (both encoder and encoder-decoder based). Finally, we compare and analyze their performance, along with other existing LMs, across the different benchmark tests of NorBench.",
19}
20