You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
File c:\Users\PAVILION\AppData\Local\Programs\Python\Python310\lib\site-packages\pyabsa\tasks\AspectSentimentTripletExtraction\prediction\predictor.py:228, in AspectSentimentTripletExtractor._run_prediction(self, save_path, print_result, **kwargs)
225 all_results = []
226 with torch.no_grad():
227 data_loader = DataIterator(
--> 228 self.dataset.convert_examples_to_features(), self.config
229 )
230 if len(self.dataset) > 1:
231 it = tqdm(data_loader, desc="Predicting")
File c:\Users\PAVILION\AppData\Local\Programs\Python\Python310\lib\site-packages\pyabsa\tasks\AspectSentimentTripletExtraction\dataset_utils\data_utils_for_inference.py:155, in ASTEInferenceDataset.convert_examples_to_features(self, **kwargs)
153 for data in it:
154 try:
--> 155 feat = Instance(
156 self.tokenizer,
157 data,
158 self.config.post_vocab,
159 self.config.deprel_vocab,
160 self.config.postag_vocab,
161 self.config.syn_post_vocab,
162 self.config,
163 )
164 _data.append(feat)
165 except IndexError as e:
File c:\Users\PAVILION\AppData\Local\Programs\Python\Python310\lib\site-packages\pyabsa\tasks\AspectSentimentTripletExtraction\dataset_utils\aste_utils.py:246, in Instance.init(self, tokenizer, sentence_pack, post_vocab, deprel_vocab, postag_vocab, synpost_vocab, config)
244 for row in range(start, end + 1):
245 for col in range(s, e + 1):
--> 246 self.word_pair_pos[row][col] = postag_vocab.stoi.get(
247 tuple(sorted([self.postag[i], self.postag[j]]))
248 )
250 """4. generate synpost index of the word pair"""
251 self.word_pair_synpost = torch.zeros(
252 config.max_seq_len, config.max_seq_len
253 ).long()
TypeError: can't assign a NoneType to a torch.LongTensor
Describe the bug
Cannot run batch_predict on the Aspect_Sentiment_Triplet_Extraction.ipynb tutorial provided.
Expected behavior
Should be able to run batch_predict()
The text was updated successfully, but these errors were encountered:
PyABSA Version (Required)
pyabsa 2.3.1
transformers 4.29.1
torch 2.1.0.dev20230628+cu121
ABSADataset Version (Required if you use integrated datasets)
2.0
Code To Reproduce (Required)
from pyabsa import available_checkpoints
from pyabsa import TaskCodeOption
ckpts = available_checkpoints(
TaskCodeOption.Aspect_Sentiment_Triplet_Extraction,
show_ckpts=True
)
print(ckpts)
triplet_extractor = ASTE.AspectSentimentTripletExtractor(
checkpoint="english"
)
triplet_extractor.batch_predict(
target_file=ASTE.ASTEDatasetList.Laptop14,
print_result=True,
save_result=False,
ignore_error=True,
eval_batch_size=16,
)
Full Console Output (Required)
TypeError Traceback (most recent call last)
Cell In[7], line 1
----> 1 triplet_extractor.batch_predict(
2 target_file=ASTE.ASTEDatasetList.Laptop14,
3 print_result=True,
4 save_result=False,
5 ignore_error=True,
6 eval_batch_size=16,
7 )
File c:\Users\PAVILION\AppData\Local\Programs\Python\Python310\lib\site-packages\pyabsa\tasks\AspectSentimentTripletExtraction\prediction\predictor.py:187, in AspectSentimentTripletExtractor.batch_predict(self, target_file, print_result, save_result, ignore_error, **kwargs)
183 raise FileNotFoundError("Can not find inference datasets!")
185 self.dataset.prepare_infer_dataset(target_file, ignore_error=ignore_error)
--> 187 return self._run_prediction(
188 save_path=save_path if save_result else None, print_result=print_result
189 )
File c:\Users\PAVILION\AppData\Local\Programs\Python\Python310\lib\site-packages\pyabsa\tasks\AspectSentimentTripletExtraction\prediction\predictor.py:228, in AspectSentimentTripletExtractor._run_prediction(self, save_path, print_result, **kwargs)
225 all_results = []
226 with torch.no_grad():
227 data_loader = DataIterator(
--> 228 self.dataset.convert_examples_to_features(), self.config
229 )
230 if len(self.dataset) > 1:
231 it = tqdm(data_loader, desc="Predicting")
File c:\Users\PAVILION\AppData\Local\Programs\Python\Python310\lib\site-packages\pyabsa\tasks\AspectSentimentTripletExtraction\dataset_utils\data_utils_for_inference.py:155, in ASTEInferenceDataset.convert_examples_to_features(self, **kwargs)
153 for data in it:
154 try:
--> 155 feat = Instance(
156 self.tokenizer,
157 data,
158 self.config.post_vocab,
159 self.config.deprel_vocab,
160 self.config.postag_vocab,
161 self.config.syn_post_vocab,
162 self.config,
163 )
164 _data.append(feat)
165 except IndexError as e:
File c:\Users\PAVILION\AppData\Local\Programs\Python\Python310\lib\site-packages\pyabsa\tasks\AspectSentimentTripletExtraction\dataset_utils\aste_utils.py:246, in Instance.init(self, tokenizer, sentence_pack, post_vocab, deprel_vocab, postag_vocab, synpost_vocab, config)
244 for row in range(start, end + 1):
245 for col in range(s, e + 1):
--> 246 self.word_pair_pos[row][col] = postag_vocab.stoi.get(
247 tuple(sorted([self.postag[i], self.postag[j]]))
248 )
250 """4. generate synpost index of the word pair"""
251 self.word_pair_synpost = torch.zeros(
252 config.max_seq_len, config.max_seq_len
253 ).long()
TypeError: can't assign a NoneType to a torch.LongTensor
Describe the bug
Cannot run batch_predict on the Aspect_Sentiment_Triplet_Extraction.ipynb tutorial provided.
Expected behavior
Should be able to run batch_predict()
The text was updated successfully, but these errors were encountered: