trainer.train doesnt work I am using transformers package and it gives me error like this:

some trash for stackoverflow ai::him,” she said. “He is not nice to anyone. I don’t want to tell stories because they are horrendous. You know, you just don’t talk about it. There are kids and grandkids involved.” When asked to chat about Elon, Errol responded via e-mail: “Elon was a very independent and focused child at home with me. He loved computer science before anyone even knew what it was in South Africa and his ability was widely recognized by the time he was 12 years old. Elon and his brother Kimbal’s activities as children and young men were so many and //////////////////////////////////////////// raceback (most recent call last): File “C:UserstasDesktopKodpythonPDFEXTRACTORtrain22.py”, line 77, in <module> trainer.train() File “C:UserstasAppDataLocalPackagesPythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0LocalCachelocal-packagesPython311site-packagestransformerstrainer.py”, line 1780, in train return inner_training_loop( ^^^^^^^^^^^^^^^^^^^^ File “C:UserstasAppDataLocalPackagesPythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0LocalCachelocal-packagesPython311site-packagestransformerstrainer.py”, line 2085, in _inner_training_loop for step, inputs in enumerate(epoch_iterator): File “C:UserstasAppDataLocalPackagesPythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0LocalCachelocal-packagesPython311site-packagesacceleratedata_loader.py”, line 452, in _iter_ current_batch = next(dataloader_iter) ^^^^^^^^^^^^^^^^^^^^^ File “C:UserstasAppDataLocalPackagesPythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0LocalCachelocal-packagesPython311site-packagestorchutilsdatadataloader.py”, line 631, in _next_ data = self._next_data() ^^^^^^^^^^^^^^^^^ File “C:UserstasAppDataLocalPackagesPythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0LocalCachelocal-packagesPython311site-packagestorchutilsdatadataloader.py”, line 675, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “C:UserstasAppDataLocalPackagesPythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0LocalCachelocal-packagesPython311site-packagestorchutilsdata_utilsfetch.py”, line 51, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “C:UserstasAppDataLocalPackagesPythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0LocalCachelocal-packagesPython311site-packagestorchutilsdata_utilsfetch.py”, line 51, in <listcomp> data = [self.dataset[idx] for idx in possibly_batched_index] ~~~~~~~~~~~~^^^^^ File “C:UserstasAppDataLocalPackagesPythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0LocalCachelocal-packagesPython311site-packagesdatasetsdataset_dict.py”, line 80, in _getitem_ raise KeyError( KeyError: “Invalid key: 0. Please first select a split. For example: `my_dataset_dictionary[‘train’][0]`. Available splits: [‘train’]” 0%| | 0/1 [00:00<?, ?it/s] &//////////////////////////////////////////////// varied that it’s difficult to name just one, as they travelled together with me extensively in S. Africa and the world at large, visiting all the continents regularly from the age of six onwards. Elon and his brother and sister were and continue to be exemplary, in every way a father could want. I’m very proud of what Elon’s accomplished.” //////////////////////////////////////////////////////////////////////// HERE is the code:::::::::::::::::::: from tokenizers import ByteLevelBPETokenizer from tokenizers.models import BPE from transformers import GPT2Config, GPT2LMHeadModel,GPT2Tokenizer,DataCollatorForLanguageModeling import torch from tokenizers import Tokenizer tokenizer = Tokenizer(BPE(unk_token=”[x]”)) from torch import nn from datasets import load_dataset from transformers import Trainer,TrainingArguments TRAIN_BASE = False import os paths = [“python_code_text_data.txt”] os.environ[“WANDB_DISABLED”] = “true” if TRAIN_BASE: tokenizer = ByteLevelBPETokenizer() tokenizer.train(files=paths, vocab_size=52_000, min_frequency=2, special_tokens=[ “<s>”, “<pad>”, “</s>”, “<unk>”, “<mask>”, ]) tokenizer.save_model(“tokenizer”) inp = ‘print(“Hello world!”)’ tokenizer = GPT2Tokenizer.from_pretrained(“tokenizer”) # Add special tokens if not already present (assuming tokenizer is loaded from “tokenizer” directory) special_tokens = { “eos_token”: “</s>”, “bos_token”: “<s>”, “unk_token”: “<unk>”, “pad_token”: “<pad>”, “mask_token”: “<mask>”, } if not all(t in tokenizer.get_vocab() for t in special_tokens.values()): tokenizer.add_special_tokens(special_tokens) t = tokenizer.encode(inp) print(t) print(tokenizer.decode(t)) config = GPT2Config( vocab_size=tokenizer.vocab_size, bos_token_id=tokenizer.bos_token_id, eos_token_id=tokenizer.eos_token_id, ) model = GPT2LMHeadModel(config) dataset = load_dataset(“text”, data_files=paths) def encode(lines): return tokenizer(lines[‘text’], add_special_tokens=True, truncation=True, max_length=512) # Corrected typo dataset.set_transform(encode) data_collator = DataCollatorForLanguageModeling(tokenizer=tokenizer, mlm=False, mlm_probability=0.15) training_args = TrainingArguments( output_dir=”GPyT”, overwrite_output_dir=True, num_train_epochs=1, per_device_train_batch_size=10, save_steps=100, save_total_limit=2, prediction_loss_only=True, remove_unused_columns=False, report_to=”tensorboard” ) trainer = Trainer( model=model, args=training_args, data_collator=data_collator, train_dataset=dataset, ) #sasa trainer.train() trainer.save_model(“GPyT”)

solving my problem please please please please please

New contributor

Recep is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật