Hello everyone,
I’m currently encountering an issue while training a Named Entity Recognition (NER) model using JSON data in UiPath’s AI Center. Specifically, I’m getting a TypeError with the message ‘list indices must be integers or slices, not str’. I believe the problem lies in how I’m accessing elements of a list within my code, but I’m having trouble identifying the exact cause.
Here’s a brief overview of what I’m doing: I have JSON files containing text data for leave requests, along with labeled entities such as names, dates, and reasons. I’m attempting to train a NER model using this data, but I keep encountering the aforementioned error.
I’ve checked the format of my JSON files, and they seem to be correctly structured with “text” and “entities” fields. However, I suspect there may be an issue with how I’m parsing or processing the JSON data in my code.
If anyone has encountered a similar issue or has expertise in training NER models with JSON data in UiPath’s AI Center, I would greatly appreciate any insights or suggestions you could provide. Thank you in advance for your help!
This is the error log :-
2024-04-03 14:56:19,979 - uipath_core.trainer_run:main:83 - INFO: Starting training job...
2024-04-03 14:56:20,108 - matplotlib:_get_config_or_cache_dir:484 - WARNING: Matplotlib created a temporary config/cache directory at /tmp/matplotlib-qre6sgwr because the default path (/home/aicenter/.config/matplotlib) is not a writable directory; it is highly recommended to set the MPLCONFIGDIR environment variable to a writable directory, in particular to speed up the import of Matplotlib and to better support multiprocessing.
2024-04-03 14:56:20,427 - matplotlib.font_manager:_load_fontmanager:1443 - INFO: generated new fontManager
2024-04-03 14:56:22,184 - uipath_core.storage.azure_storage_client:download:118 - INFO: Dataset from bucket folder training-aee14565-bca2-495f-8d45-f3cee36aeef7/670a117d-bba2-4a8d-8b59-6f8f572bb359/85ad1b6b-caa6-4a18-b051-7f7248edfc06 with size 1 downloaded successfully
2024-04-03 14:56:22,184 - uipath_core.training_plugin:download_dataset:513 - WARNING: Deleting already existing folder name: /data/dataset/test
2024-04-03 14:56:22,211 - uipath_core.storage.azure_storage_client:download:118 - INFO: Dataset from bucket folder training-aee14565-bca2-495f-8d45-f3cee36aeef7/670a117d-bba2-4a8d-8b59-6f8f572bb359/49c8f670-5f56-4169-9a74-b971874fa645 with size 1 downloaded successfully
2024-04-03 14:56:22,211 - uipath_core.training_plugin:process_data_model:151 - INFO: Start process model data...
2024-04-03 14:56:22,211 - uipath_core.training_plugin:initialize_model:124 - INFO: Start model initialization...
2024-04-03 14:56:22,350 - uipath_core.training_plugin:initialize_model:127 - INFO: Model initialized successfully
2024-04-03 14:56:22,350 - root:get_data_processor:40 - INFO: Using Json Data Processor ...
2024-04-03 14:56:22,350 - root:process_files:24 - INFO: Processing JSON files
2024-04-03 14:56:22,350 - root:process_files:28 - INFO: Reading NER_Training.json ...
2024-04-03 14:56:22,351 - uipath_core.training_plugin:process_data:529 - ERROR: Failed to process data, error: list indices must be integers or slices, not str
2024-04-03 14:56:22,351 - uipath_core.training_plugin:model_run:179 - ERROR: Training failed for pipeline type: FULL_TRAINING, error: list indices must be integers or slices, not str
2024-04-03 14:56:22,386 - uipath_core.trainer_run:main:100 - ERROR: Training Job failed, error: list indices must be integers or slices, not str
Traceback (most recent call last):
File "/home/aicenter/.local/lib/python3.8/site-packages/uipath_core/trainer_run.py", line 95, in main
wrapper.run()
File "/microservice/training_wrapper.py", line 58, in run
return self.training_plugin.model_run()
File "/home/aicenter/.local/lib/python3.8/site-packages/uipath_core/training_plugin.py", line 195, in model_run
raise ex
File "/home/aicenter/.local/lib/python3.8/site-packages/uipath_core/training_plugin.py", line 167, in model_run
self.run_full_training()
File "/home/aicenter/.local/lib/python3.8/site-packages/uipath_core/training_plugin.py", line 212, in run_full_training
self.process_data()
File "/home/aicenter/.local/lib/python3.8/site-packages/uipath_core/training_plugin.py", line 530, in process_data
raise e
File "/home/aicenter/.local/lib/python3.8/site-packages/uipath_core/training_plugin.py", line 527, in process_data
self.process_data_model(self.local_dataset_directory)
File "/home/aicenter/.local/lib/python3.8/site-packages/uipath_core/training_plugin.py", line 152, in process_data_model
response = self.model.process_data(directory)
File "/microservice/train.py", line 67, in process_data
self.df_train, self.df_test = preprocess.preprocess_data(self.opt, split=True)
File "<frozen aicenter.ner.preprocess>", line 52, in preprocess_data
File "<frozen aicenter.ner.data_processors.base_data_processor>", line 24, in process_data
File "<frozen aicenter.ner.data_processors.json_data_processor>", line 29, in process_files
File "<frozen aicenter.ner.data_processors.json_data_processor>", line 42, in process_file
File "<frozen aicenter.ner.data_processors.base_data_processor>", line 30, in read_field
TypeError: list indices must be integers or slices, not str
2024-04-03 14:56:22,386 - uipath_core.trainer_run:main:107 - INFO: Job run stopped.