-
-
Save manujosephv/65b7bf15247f6b9ae3aa3f842519b01a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tokenizer = AutoTokenizer.from_pretrained('gpt2') | |
MAX_LEN = 100 | |
train_m = "" | |
with open(train_path, "r", encoding='utf-8') as f: | |
for line in f.readlines(): | |
if len(line.split())>MAX_LEN: | |
continue | |
train_m += (tokenizer.special_tokens_map['bos_token']+line.rstrip()+tokenizer.special_tokens_map['eos_token']) | |
with open(train_mod_path, "w", encoding='utf-8') as f: | |
f.write(train_m) | |
test_m = "" | |
with open(test_path, "r", encoding='utf-8') as f: | |
for line in f.readlines(): | |
if len(line.split())>MAX_LEN: | |
continue | |
test_m += (tokenizer.special_tokens_map['bos_token']+line.rstrip()+tokenizer.special_tokens_map['eos_token']) | |
with open(test_mod_path, "w", encoding='utf-8') as f: | |
f.write(test_m) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment