Views
No views yet
model.safetensors and save it into your local path, e.g., ./weights/model.safetensors1from transformers import AutoModelForSeq2SeqLM
2from safetensors.torch import load_file
3
4NUM_LABELS = 6 * 64
5
6weight = load_file('./weights/model.safetensors')
7model = AutoModelForSeq2SeqLM.from_pretrained('google-t5/t5-small')
8model.lm_head = torch.nn.Linear(model.config.hidden_size, NUM_LABELS, bias=False)
9model.load_state_dict(w)1bs = 2
2seq_len = 10
3prompt_ids = torch.randint(0, 100,(bs, seq_len))
4attention_mask = torch.ones(bs, seq_len)
5decode_ids = torch.randint(0, 100, (bs, 1))
6decode_token_patterns = model(input_ids=prompt_ids, attention_mask=attention_mask, decoder_input_ids=decode_ids)