MCPcopy Index your code
hub / github.com/devvrit/matformer / preprocess_data

Function preprocess_data

train.py:11–13  ·  view source on GitHub ↗
(example, tokenizer)

Source from the content-addressed store, hash-verified

9device = torch.device( 'cuda' ) if torch.cuda.is_available() else torch.device( 'cpu' )
10
11def preprocess_data(example, tokenizer):
12 tokenizer.pad_token = tokenizer.eos_token
13 return tokenizer(example["text"], truncation=True, padding="max_length", max_length=512)
14
15def collate_fn(batch):
16 input_ids = torch.stack([torch.tensor(b["input_ids"]) for b in batch])

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected