-
Notifications
You must be signed in to change notification settings - Fork 91
Description
import aspect_based_sentiment_analysis as absa
nlp = absa.load()
text = ("We are great fans of Slack, but we wish the subscriptions "
"were more accessible to small startups.")
slack, price = nlp(text, aspects=['slack', 'price'])
assert price.sentiment == absa.Sentiment.negative
assert slack.sentiment == absa.Sentiment.positive
RecursionError Traceback (most recent call last)
Cell In[7], line 1
----> 1 nlp = absa.load()
File /opt/conda/lib/python3.10/site-packages/aspect_based_sentiment_analysis/loads.py:34, in load(name, text_splitter, reference_recognizer, pattern_recognizer, **model_kwargs)
32 try:
33 config = BertABSCConfig.from_pretrained(name, **model_kwargs)
---> 34 model = BertABSClassifier.from_pretrained(name, config=config)
35 tokenizer = transformers.BertTokenizer.from_pretrained(name)
36 professor = Professor(reference_recognizer, pattern_recognizer)
File /opt/conda/lib/python3.10/site-packages/transformers/modeling_tf_utils.py:2949, in TFPreTrainedModel.from_pretrained(cls, pretrained_model_name_or_path, config, cache_dir, ignore_mismatched_sizes, force_download, local_files_only, token, revision, use_safetensors, *model_args, **kwargs)
2946 model_kwargs["load_weight_prefix"] = load_weight_prefix + "/" + model_kwargs.get("name")
2948 # Instantiate model.
-> 2949 model = cls(config, *model_args, **model_kwargs)
2951 if tf_to_pt_weight_rename is None and hasattr(model, "tf_to_pt_weight_rename"):
2952 # TODO Matt: This is a temporary workaround to allow weight renaming, but requires a method
2953 # to be defined for each class that requires a rename. We can probably just have a class-level
2954 # dict and a single top-level method or something and cut down a lot of boilerplate code
2955 tf_to_pt_weight_rename = model.tf_to_pt_weight_rename
File /opt/conda/lib/python3.10/site-packages/keras/src/models/model.py:146, in Model.new(cls, *args, **kwargs)
143 from keras.src.models import functional
145 return functional.Functional(*args, **kwargs)
--> 146 return typing.cast(Model, super().new(cls))
File /opt/conda/lib/python3.10/site-packages/keras/src/layers/layer.py:231, in Layer.new(cls, *args, **kwargs)
228 obj._post_build()
229 obj._lock_state()
--> 231 obj.build = build_wrapper
232 return obj
File /opt/conda/lib/python3.10/site-packages/keras/src/layers/layer.py:1352, in Layer.setattr(self, name, value)
1350 value = self._tracker.track(value)
1351 elif name != "_tracker":
-> 1352 self._initialize_tracker()
1353 return super().setattr(name, value)
File /opt/conda/lib/python3.10/site-packages/keras/src/utils/tracking.py:26, in no_automatic_dependency_tracking..wrapper(*args, **kwargs)
23 @wraps(fn)
24 def wrapper(*args, **kwargs):
25 with DotNotTrackScope():
---> 26 return fn(*args, **kwargs)
File /opt/conda/lib/python3.10/site-packages/keras/src/layers/layer.py:307, in Layer._initialize_tracker(self)
305 metrics = []
306 seed_generators = []
--> 307 self._tracker = tracking.Tracker(
308 {
309 "trainable_variables": (
310 lambda x: isinstance(x, backend.Variable) and x.trainable,
311 trainable_variables,
312 ),
313 "non_trainable_variables": (
314 lambda x: isinstance(x, backend.Variable)
315 and not x.trainable,
316 non_trainable_variables,
317 ),
318 "metrics": (lambda x: isinstance(x, Metric), metrics),
319 "layers": (
320 lambda x: isinstance(x, Layer)
321 and not isinstance(x, Metric),
322 layers,
323 ),
324 "seed_generators": (
325 lambda x: isinstance(x, backend.random.SeedGenerator),
326 seed_generators,
327 ),
328 },
329 exclusions={"non_trainable_variables": ["trainable_variables"]},
330 )
331 if backend.backend() == "tensorflow":
332 # Remove attribute tracking for lists (TF-specific attribute)
333 _self_setattr_tracking = getattr(
334 self, "_self_setattr_tracking", True
335 )
File /opt/conda/lib/python3.10/site-packages/keras/src/layers/layer.py:1353, in Layer.setattr(self, name, value)
1351 elif name != "_tracker":
1352 self._initialize_tracker()
-> 1353 return super().setattr(name, value)
File /opt/conda/lib/python3.10/site-packages/keras/src/backend/tensorflow/trackable.py:28, in KerasAutoTrackable.setattr(self, name, value)
24 if getattr(self, "_self_setattr_tracking", True):
25 value = sticky_attribute_assignment(
26 trackable=self, value=value, name=name
27 )
---> 28 super().setattr(name, value)
File /opt/conda/lib/python3.10/site-packages/tf_keras/src/engine/training.py:388, in Model.setattr(self, name, value)
381 except AttributeError:
382 raise RuntimeError(
383 "It looks like you are subclassing Model and you "
384 "forgot to call super().init()."
385 " Always start with this line."
386 )
--> 388 super().setattr(name, value)
File /opt/conda/lib/python3.10/site-packages/tf_keras/src/engine/base_layer.py:3152, in Layer.setattr(self, name, value)
3147 # Wraps data structures in Trackable, unwraps NoDependency objects.
3148 value = tf.internal.tracking.sticky_attribute_assignment(
3149 trackable=self, value=value, name=name
3150 )
-> 3152 reference_counts = self._obj_reference_counts
3153 reference_counts[value] = reference_counts.get(value, 0) + 1
3155 # When replacing an existing tf.Variable with a new one, we want to
3156 # check its existing position in the
3157 # self._trainable/non_trainable_variable, so that we can put it back to
3158 # the original position.
File /opt/conda/lib/python3.10/site-packages/tf_keras/src/engine/base_layer.py:3042, in Layer._obj_reference_counts(self)
3039 @Property
3040 def _obj_reference_counts(self):
3041 """A dict counting the number of attributes referencing an object."""
-> 3042 self._maybe_create_attribute(
3043 "_obj_reference_counts_dict",
3044 object_identity.ObjectIdentityDictionary(),
3045 )
3046 return self._obj_reference_counts_dict
File /opt/conda/lib/python3.10/site-packages/tensorflow/python/trackable/base.py:202, in no_automatic_dependency_tracking.._method_wrapper(self, *args, **kwargs)
200 def _method_wrapper(self, *args, **kwargs):
201 previous_value = getattr(self, "_self_setattr_tracking", True)
--> 202 self._self_setattr_tracking = False # pylint: disable=protected-access
203 try:
204 result = method(self, *args, **kwargs)
File /opt/conda/lib/python3.10/site-packages/keras/src/layers/layer.py:1352, in Layer.setattr(self, name, value)
1350 value = self._tracker.track(value)
1351 elif name != "_tracker":
-> 1352 self._initialize_tracker()
1353 return super().setattr(name, value)
File /opt/conda/lib/python3.10/site-packages/keras/src/utils/tracking.py:26, in no_automatic_dependency_tracking..wrapper(*args, **kwargs)
23 @wraps(fn)
24 def wrapper(*args, **kwargs):
25 with DotNotTrackScope():
---> 26 return fn(*args, **kwargs)
File /opt/conda/lib/python3.10/site-packages/keras/src/layers/layer.py:307, in Layer._initialize_tracker(self)
305 metrics = []
306 seed_generators = []
--> 307 self._tracker = tracking.Tracker(
308 {
309 "trainable_variables": (
310 lambda x: isinstance(x, backend.Variable) and x.trainable,
311 trainable_variables,
312 ),
313 "non_trainable_variables": (
314 lambda x: isinstance(x, backend.Variable)
315 and not x.trainable,
316 non_trainable_variables,
317 ),
318 "metrics": (lambda x: isinstance(x, Metric), metrics),
319 "layers": (
320 lambda x: isinstance(x, Layer)
321 and not isinstance(x, Metric),
322 layers,
323 ),
324 "seed_generators": (
325 lambda x: isinstance(x, backend.random.SeedGenerator),
326 seed_generators,
327 ),
328 },
329 exclusions={"non_trainable_variables": ["trainable_variables"]},
330 )
331 if backend.backend() == "tensorflow":
332 # Remove attribute tracking for lists (TF-specific attribute)
333 _self_setattr_tracking = getattr(
334 self, "_self_setattr_tracking", True
335 )
File /opt/conda/lib/python3.10/site-packages/keras/src/layers/layer.py:1353, in Layer.setattr(self, name, value)
1351 elif name != "_tracker":
1352 self._initialize_tracker()
-> 1353 return super().setattr(name, value)
File /opt/conda/lib/python3.10/site-packages/keras/src/backend/tensorflow/trackable.py:28, in KerasAutoTrackable.setattr(self, name, value)
24 if getattr(self, "_self_setattr_tracking", True):
25 value = sticky_attribute_assignment(
26 trackable=self, value=value, name=name
27 )
---> 28 super().setattr(name, value)
File /opt/conda/lib/python3.10/site-packages/tf_keras/src/engine/training.py:388, in Model.setattr(self, name, value)
381 except AttributeError:
382 raise RuntimeError(
383 "It looks like you are subclassing Model and you "
384 "forgot to call super().init()."
385 " Always start with this line."
386 )
--> 388 super().setattr(name, value)
File /opt/conda/lib/python3.10/site-packages/tf_keras/src/engine/base_layer.py:3152, in Layer.setattr(self, name, value)
3147 # Wraps data structures in Trackable, unwraps NoDependency objects.
3148 value = tf.internal.tracking.sticky_attribute_assignment(
3149 trackable=self, value=value, name=name
3150 )
-> 3152 reference_counts = self._obj_reference_counts
3153 reference_counts[value] = reference_counts.get(value, 0) + 1
3155 # When replacing an existing tf.Variable with a new one, we want to
3156 # check its existing position in the
3157 # self._trainable/non_trainable_variable, so that we can put it back to
3158 # the original position.
File /opt/conda/lib/python3.10/site-packages/tf_keras/src/engine/base_layer.py:3042, in Layer._obj_reference_counts(self)
3039 @Property
3040 def _obj_reference_counts(self):
3041 """A dict counting the number of attributes referencing an object."""
-> 3042 self._maybe_create_attribute(
3043 "_obj_reference_counts_dict",
3044 object_identity.ObjectIdentityDictionary(),
3045 )
3046 return self._obj_reference_counts_dict
File /opt/conda/lib/python3.10/site-packages/tensorflow/python/trackable/base.py:202, in no_automatic_dependency_tracking.._method_wrapper(self, *args, **kwargs)
200 def _method_wrapper(self, *args, **kwargs):
201 previous_value = getattr(self, "_self_setattr_tracking", True)
--> 202 self._self_setattr_tracking = False # pylint: disable=protected-access
203 try:
204 result = method(self, *args, **kwargs)
[... skipping similar frames: Layer.setattr at line 1352 (327 times), Layer.setattr at line 1353 (327 times), Layer._initialize_tracker at line 307 (327 times), no_automatic_dependency_tracking..wrapper at line 26 (327 times), KerasAutoTrackable.setattr at line 28 (326 times), Model.setattr at line 388 (326 times), Layer.setattr at line 3152 (326 times), no_automatic_dependency_tracking.._method_wrapper at line 202 (326 times), Layer._obj_reference_counts at line 3042 (326 times)]
File /opt/conda/lib/python3.10/site-packages/keras/src/backend/tensorflow/trackable.py:28, in KerasAutoTrackable.setattr(self, name, value)
24 if getattr(self, "_self_setattr_tracking", True):
25 value = sticky_attribute_assignment(
26 trackable=self, value=value, name=name
27 )
---> 28 super().setattr(name, value)
File /opt/conda/lib/python3.10/site-packages/tf_keras/src/engine/training.py:388, in Model.setattr(self, name, value)
381 except AttributeError:
382 raise RuntimeError(
383 "It looks like you are subclassing Model and you "
384 "forgot to call super().init()."
385 " Always start with this line."
386 )
--> 388 super().setattr(name, value)
File /opt/conda/lib/python3.10/site-packages/tf_keras/src/engine/base_layer.py:3152, in Layer.setattr(self, name, value)
3147 # Wraps data structures in Trackable, unwraps NoDependency objects.
3148 value = tf.internal.tracking.sticky_attribute_assignment(
3149 trackable=self, value=value, name=name
3150 )
-> 3152 reference_counts = self._obj_reference_counts
3153 reference_counts[value] = reference_counts.get(value, 0) + 1
3155 # When replacing an existing tf.Variable with a new one, we want to
3156 # check its existing position in the
3157 # self._trainable/non_trainable_variable, so that we can put it back to
3158 # the original position.
File /opt/conda/lib/python3.10/site-packages/tf_keras/src/engine/base_layer.py:3042, in Layer._obj_reference_counts(self)
3039 @Property
3040 def _obj_reference_counts(self):
3041 """A dict counting the number of attributes referencing an object."""
-> 3042 self._maybe_create_attribute(
3043 "_obj_reference_counts_dict",
3044 object_identity.ObjectIdentityDictionary(),
3045 )
3046 return self._obj_reference_counts_dict
File /opt/conda/lib/python3.10/site-packages/tensorflow/python/trackable/base.py:202, in no_automatic_dependency_tracking.._method_wrapper(self, *args, **kwargs)
200 def _method_wrapper(self, *args, **kwargs):
201 previous_value = getattr(self, "_self_setattr_tracking", True)
--> 202 self._self_setattr_tracking = False # pylint: disable=protected-access
203 try:
204 result = method(self, *args, **kwargs)
File /opt/conda/lib/python3.10/site-packages/keras/src/layers/layer.py:1352, in Layer.setattr(self, name, value)
1350 value = self._tracker.track(value)
1351 elif name != "_tracker":
-> 1352 self._initialize_tracker()
1353 return super().setattr(name, value)
File /opt/conda/lib/python3.10/site-packages/keras/src/utils/tracking.py:26, in no_automatic_dependency_tracking..wrapper(*args, **kwargs)
23 @wraps(fn)
24 def wrapper(*args, **kwargs):
25 with DotNotTrackScope():
---> 26 return fn(*args, **kwargs)
File /opt/conda/lib/python3.10/site-packages/keras/src/layers/layer.py:307, in Layer._initialize_tracker(self)
305 metrics = []
306 seed_generators = []
--> 307 self._tracker = tracking.Tracker(
308 {
309 "trainable_variables": (
310 lambda x: isinstance(x, backend.Variable) and x.trainable,
311 trainable_variables,
312 ),
313 "non_trainable_variables": (
314 lambda x: isinstance(x, backend.Variable)
315 and not x.trainable,
316 non_trainable_variables,
317 ),
318 "metrics": (lambda x: isinstance(x, Metric), metrics),
319 "layers": (
320 lambda x: isinstance(x, Layer)
321 and not isinstance(x, Metric),
322 layers,
323 ),
324 "seed_generators": (
325 lambda x: isinstance(x, backend.random.SeedGenerator),
326 seed_generators,
327 ),
328 },
329 exclusions={"non_trainable_variables": ["trainable_variables"]},
330 )
331 if backend.backend() == "tensorflow":
332 # Remove attribute tracking for lists (TF-specific attribute)
333 _self_setattr_tracking = getattr(
334 self, "_self_setattr_tracking", True
335 )
File /opt/conda/lib/python3.10/site-packages/keras/src/layers/layer.py:1353, in Layer.setattr(self, name, value)
1351 elif name != "_tracker":
1352 self._initialize_tracker()
-> 1353 return super().setattr(name, value)
File /opt/conda/lib/python3.10/site-packages/keras/src/backend/tensorflow/trackable.py:25, in KerasAutoTrackable.setattr(self, name, value)
22 pass
24 if getattr(self, "_self_setattr_tracking", True):
---> 25 value = sticky_attribute_assignment(
26 trackable=self, value=value, name=name
27 )
28 super().setattr(name, value)
File /opt/conda/lib/python3.10/site-packages/keras/src/backend/tensorflow/trackable.py:43, in sticky_attribute_assignment(trackable, name, value)
31 def sticky_attribute_assignment(trackable, name, value):
32 """Adds dependencies, called from setattr.
33
34 Args:
(...)
41 The value which should be stored in the attribute.
42 """
---> 43 if isinstance(
44 value, (tracking.TrackedList, tracking.TrackedDict, tracking.TrackedSet)
45 ) and hasattr(trackable, "_tracked"):
46 trackable._tracked.append(name)
47 if not tracking.is_tracking_enabled():
RecursionError: maximum recursion depth exceeded in instancecheck