Views
No views yet
pip install transformers==4.57.6modeling_gptbert.py, you should therefore load the model with trust_remote_code=True.1import torch
2from transformers import AutoTokenizer, AutoModelForMaskedLM
3
4# Import model
5tokenizer = AutoTokenizer.from_pretrained(
6 "HPLT/hplt_gpt_bert_base_3_0_lit_Latn",
7)
8model = AutoModelForMaskedLM.from_pretrained(
9 "HPLT/hplt_gpt_bert_base_3_0_lit_Latn",
10 trust_remote_code=True,
11 use_safetensors=False,
12)
13model = model.eval()
14input_text = f"Norwegian is a {tokenizer.mask_token} Germanic language"
15print(input_text)
16# Tokenize text (with a mask token inside)
17input_text = tokenizer(
18 input_text,
19 return_tensors="pt",
20)
21# Inference
22with torch.no_grad():
23 output_p = model(**input_text)
24
25# Unmask the text
26output_text = torch.where(
27 input_text.input_ids == tokenizer.mask_token_id,
28 output_p.logits.argmax(-1),
29 input_text.input_ids
30)
31
32# Decoding; should output: 'Norwegian is a North Germanic language'
33print(tokenizer.decode(output_text[0].tolist()))1import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM
3
4tokenizer = AutoTokenizer.from_pretrained(
5 "HPLT/hplt_gpt_bert_base_3_0_lit_Latn",
6)
7model = AutoModelForCausalLM.from_pretrained(
8 "HPLT/hplt_gpt_bert_base_3_0_lit_Latn",
9 trust_remote_code=True,
10 use_safetensors=False,
11)
12text = f"The Norwegian Constitution"
13print(text, flush=True)
14# Define tokens that should end the generation
15eos_token_ids = [
16 token_id
17 for token_id in range(tokenizer.vocab_size)
18 if '.' in tokenizer.decode([token_id])
19]
20
21# Generation function
22@torch.no_grad()
23def generate(text):
24 input_ids = tokenizer(text, return_tensors='pt').input_ids
25 prediction = model.generate(
26 input_ids,
27 max_new_tokens=63,
28 do_sample=False,
29 eos_token_id=eos_token_ids,
30 )
31 return tokenizer.decode(prediction[0]).strip()
32
33# Example usage, should output '[CLS]The Norwegian Constitution[SEP]is a document that defines the rights and responsibilities of the Norwegian people and their representatives.'
34print(generate(text), flush=True)AutoModel, AutoModelForMaskedLM, AutoModelForCausalLM, AutoModelForSequenceClassification, AutoModelForTokenClassification, AutoModelForQuestionAnswering and AutoModeltForMultipleChoice.stepXXX: for example, step18750.transformers using the argument revision:model = AutoModelForSeq2SeqLM.from_pretrained("HPLT/hplt_gpt_bert_base_3_0_lit_Latn", revision="step21875", trust_remote_code=True)1from huggingface_hub import list_repo_refs
2out = list_repo_refs("HPLT/hplt_gpt_bert_base_3_0_lit_Latn")
3print([b.name for b in out.branches])1@inproceedings{charpentier-samuel-2024-bert,
2 title = "{GPT} or {BERT}: why not both?",
3 author = "Charpentier, Lucas Georges Gabriel and
4 Samuel, David",
5 booktitle = "The 2nd BabyLM Challenge at the 28th Conference on Computational Natural Language Learning",
6 month = nov,
7 year = "2024",
8 address = "Miami, FL, USA",
9 publisher = "Association for Computational Linguistics",
10 url = "https://aclanthology.org/2024.conll-babylm.24/",
11 pages = "262--283"
12}1@misc{oepen2025hplt30largescalemultilingual,
2 title={{HPLT 3.0}: {V}ery Large-Scale Multilingual Resources for {LLM} and {MT}. Mono- and Bi-lingual Data, Multilingual Evaluation, and Pre-Trained Models},
3 author={Stephan Oepen and Nikolay Arefev and Mikko Aulamo and Marta Bañón and Maja Buljan and Laurie Burchell and Lucas Charpentier and Pinzhen Chen and Mariia Fedorova and Ona de Gibert and Barry Haddow and Jan Hajič and Jindřich Helcl and Andrey Kutuzov and Veronika Laippala and Zihao Li and Risto Luukkonen and Bhavitvya Malik and Vladislav Mikhailov and Amanda Myntti and Dayyán O'Brien and Lucie Poláková and Sampo Pyysalo and Gema Ramírez Sánchez and Janine Siewert and Pavel Stepachev and Jörg Tiedemann and Teemu Vahtola and Dušan Variš and Fedor Vitiugin and Tea Vojtěchová and Jaume Zaragoza},
4 year={2025},
5 eprint={2511.01066},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL},
8 url={https://arxiv.org/abs/2511.01066},
9}