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
import nlpaug.augmenter.word as naw
aug = naw.ContextualWordEmbsAug()
text="Transformers are the most popular toys"
print(f"original text:{text}")
print(f"Augmented text: {aug.augment(text)}")
original text:Transformers are the most popular toys
RuntimeError Traceback (most recent call last)
Input In [28], in <cell line: 3>()
1 text="Transformers are the most popular toys"
2 print(f"original text:{text}")
----> 3 print(f"Augmented text: {aug.augment(text)}")
File ~/.local/lib/python3.9/site-packages/nlpaug/base_augmenter.py:98, in Augmenter.augment(self, data, n, num_thread)
96 elif self.class.name in ['AbstSummAug', 'BackTranslationAug', 'ContextualWordEmbsAug', 'ContextualWordEmbsForSentenceAug']:
97 for _ in range(aug_num):
---> 98 result = action_fx(clean_data)
99 if isinstance(result, list):
100 augmented_results.extend(result)
File ~/.local/lib/python3.9/site-packages/nlpaug/augmenter/word/context_word_embs.py:471, in ContextualWordEmbsAug.substitute(self, data)
468 if not len(masked_texts):
469 continue
--> 471 outputs = self.model.predict(masked_texts, target_words=original_tokens, n=2)
473 # Update doc
474 for original_token, aug_input_pos, output, masked_text in zip(original_tokens, aug_input_poses, outputs, masked_texts):
import nlpaug.augmenter.word as naw
aug = naw.ContextualWordEmbsAug()
text="Transformers are the most popular toys"
print(f"original text:{text}")
print(f"Augmented text: {aug.augment(text)}")
original text:Transformers are the most popular toys
RuntimeError Traceback (most recent call last)
Input In [28], in <cell line: 3>()
1 text="Transformers are the most popular toys"
2 print(f"original text:{text}")
----> 3 print(f"Augmented text: {aug.augment(text)}")
File ~/.local/lib/python3.9/site-packages/nlpaug/base_augmenter.py:98, in Augmenter.augment(self, data, n, num_thread)
96 elif self.class.name in ['AbstSummAug', 'BackTranslationAug', 'ContextualWordEmbsAug', 'ContextualWordEmbsForSentenceAug']:
97 for _ in range(aug_num):
---> 98 result = action_fx(clean_data)
99 if isinstance(result, list):
100 augmented_results.extend(result)
File ~/.local/lib/python3.9/site-packages/nlpaug/augmenter/word/context_word_embs.py:471, in ContextualWordEmbsAug.substitute(self, data)
468 if not len(masked_texts):
469 continue
--> 471 outputs = self.model.predict(masked_texts, target_words=original_tokens, n=2)
473 # Update doc
474 for original_token, aug_input_pos, output, masked_text in zip(original_tokens, aug_input_poses, outputs, masked_texts):
File ~/.local/lib/python3.9/site-packages/nlpaug/model/lang_models/bert.py:113, in Bert.predict(self, texts, target_words, n)
111 seed = {'temperature': self.temperature, 'top_k': self.top_k, 'top_p': self.top_p}
112 target_token_logits = self.control_randomness(target_token_logits, seed)
--> 113 target_token_logits, target_token_idxes = self.filtering(target_token_logits, seed)
114 if len(target_token_idxes) != 0:
115 new_tokens = self.pick(target_token_logits, target_token_idxes, target_word=target_token, n=10)
File ~/.local/lib/python3.9/site-packages/nlpaug/model/lang_models/language_models.py:146, in LanguageModels.filtering(self, logits, seed)
144 if 'cuda' in self.device:
145 idxes = idxes.cpu()
--> 146 idxes = idxes.detach().numpy().tolist()
147 else:
148 idxes = np.arange(len(logits)).tolist()
RuntimeError: Numpy is not available
The text was updated successfully, but these errors were encountered: