Views
No views yet

1from transformers import GPT2LMHeadModel, GPT2Tokenizer
2import torch
3
4# Load model and tokenizer
5model_id = "mission-impossible-lms/local-shuffle-w5-gpt2"
6model = GPT2LMHeadModel.from_pretrained(model_id)
7tokenizer = GPT2Tokenizer.from_pretrained(model_id)
8
9# Set up the prompt and encode it
10prompt = "He clean"
11inputs = tokenizer(prompt, return_tensors="pt")
12
13# Generate text
14output = model.generate(inputs.input_ids, max_length=20)
15
16# Decode and print the generated text
17generated_text = tokenizer.decode(output[0], skip_special_tokens=True)
18print(generated_text)main branch of this model repo loads the
last model checkpoint (3000). To access the other checkpoints,
use the revision argument:model = GPT2LMHeadModel.from_pretrained(model_id, revision="checkpoint-500")1@inproceedings{kallini-etal-2024-mission,
2 title = "Mission: Impossible Language Models",
3 author = "Kallini, Julie and
4 Papadimitriou, Isabel and
5 Futrell, Richard and
6 Mahowald, Kyle and
7 Potts, Christopher",
8 editor = "Ku, Lun-Wei and
9 Martins, Andre and
10 Srikumar, Vivek",
11 booktitle = "Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers)",
12 month = aug,
13 year = "2024",
14 address = "Bangkok, Thailand",
15 publisher = "Association for Computational Linguistics",
16 url = "https://aclanthology.org/2024.acl-long.787",
17 doi = "10.18653/v1/2024.acl-long.787",
18 pages = "14691--14714",
19}