This repository contains an easy and intuitive approach to few-shot classification using sentence-transformers or spaCy models, or zero-shot classification with Huggingface.
MIT License
208
stars
15
forks
source link
ValueError: Couldn't deep-copy config: maximum recursion depth exceeded while calling a Python object #11
I am trying to reproduce your example on my data and using python 3.8.13 and spacy 3.4.1
This is my code:
import spacy
import classy_classification
nlp = spacy.load("en_core_web_sm")
nlp.add_pipe(
"text_categorizer",
config={
"data": data,
"model": "spacy"
}
)
prompt="""
Either the well was very deep, or she fell very slowly, for she had
plenty of time as she went down to look about her and to wonder what
was going to happen next. First, she tried to look down and make out
what she was coming to, but it was too dark to see anything; then she
looked at the sides of the well, and noticed that they were filled with
cupboards and book-shelves; here and there she saw maps and pictures
hung upon pegs. She took down a jar from one of the shelves as she
passed; it was labelled “ORANGE MARMALADE”, but to her great
disappointment it was empty: she did not like to drop the jar for fear
of killing somebody underneath, so managed to put it into one of the
cupboards as she fell past it.
“Well!” thought Alice to herself, “after such a fall as this, I shall
think nothing of tumbling down stairs! How brave they’ll all think me
at home! Why, I wouldn’t say anything about it, even if I fell off the
top of the house!” (Which was very likely true.)"""
print(nlp(prompt)._.cats)
but I get this error
ValueError: Couldn't deep-copy config: maximum recursion depth exceeded while calling a Python object
This is the full error output
ValueError Traceback (most recent call last)
Input In [2], in <cell line: 7>()
2 import classy_classification
6 nlp = spacy.load("en_core_web_sm")
----> 7 nlp.add_pipe(
8 "text_categorizer",
9 config={
10 "data": data,
11 "model": "spacy"
12 }
13 )
15 prompt="""
16 Either the well was very deep, or she fell very slowly, for she had
17 plenty of time as she went down to look about her and to wonder what
(...)
30 at home! Why, I wouldn’t say anything about it, even if I fell off the
31 top of the house!” (Which was very likely true.)"""
33 print(nlp(prompt)._.cats)
File ~/miniforge3/envs/sklearn38/lib/python3.8/site-packages/spacy/language.py:795, in Language.add_pipe(self, factory_name, name, before, after, first, last, source, config, raw_config, validate)
787 if not self.has_factory(factory_name):
788 err = Errors.E002.format(
789 name=factory_name,
790 opts=", ".join(self.factory_names),
(...)
793 lang_code=self.lang,
794 )
--> 795 pipe_component = self.create_pipe(
796 factory_name,
797 name=name,
798 config=config,
799 raw_config=raw_config,
800 validate=validate,
801 )
802 pipe_index = self._get_pipe_index(before, after, first, last)
803 self._pipe_meta[name] = self.get_factory_meta(factory_name)
File ~/miniforge3/envs/sklearn38/lib/python3.8/site-packages/spacy/language.py:660, in Language.create_pipe(self, factory_name, name, config, raw_config, validate)
657 # This is unideal, but the alternative would mean you always need to
658 # specify the full config settings, which is not really viable.
659 if pipe_meta.default_config:
--> 660 config = Config(pipe_meta.default_config).merge(config)
661 internal_name = self.get_factory_name(factory_name)
662 # If the language-specific factory doesn't exist, try again with the
663 # not-specific name
File ~/miniforge3/envs/sklearn38/lib/python3.8/site-packages/thinc/config.py:327, in Config.merge(self, updates, remove_extra)
325 """Deep merge the config with updates, using current as defaults."""
326 defaults = self.copy()
--> 327 updates = Config(updates).copy()
328 merged = deep_merge_configs(updates, defaults, remove_extra=remove_extra)
329 return Config(
330 merged,
331 is_interpolated=defaults.is_interpolated and updates.is_interpolated,
332 section_order=defaults.section_order,
333 )
File ~/miniforge3/envs/sklearn38/lib/python3.8/site-packages/thinc/config.py:315, in Config.copy(self)
313 config = copy.deepcopy(self)
314 except Exception as e:
--> 315 raise ValueError(f"Couldn't deep-copy config: {e}") from e
316 return Config(
317 config,
318 is_interpolated=self.is_interpolated,
319 section_order=self.section_order,
320 )
ValueError: Couldn't deep-copy config: maximum recursion depth exceeded while calling a Python object
Can you please help me solve this problem?
Thanks
David
Hi,
I am trying to reproduce your example on my data and using
python 3.8.13
andspacy 3.4.1
This is my code:but I get this error
This is the full error output
Can you please help me solve this problem? Thanks David