Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running into problems while using spaCy LLM. #13614

Open
PrithaSarkar opened this issue Sep 2, 2024 · 1 comment
Open

Running into problems while using spaCy LLM. #13614

PrithaSarkar opened this issue Sep 2, 2024 · 1 comment

Comments

@PrithaSarkar
Copy link

Hi, community!

So, I have been trying to implement spaCy's LLM along with OpenAI's gpt-4.0-turbo model but running into some trouble. For more context, below is the config.cfg file

[paths]
train = null
dev = null

[system]
gpu_allocator = null

[nlp]
lang = "en"
pipeline = ["llm"]

[components]

[components.llm]
factory = "llm"
save_io = true

[components.llm.task]
@llm_tasks = 'spacy.NER.v3'
#labels = ["CHANGE_ME_1", "CHANGE_ME_2"]

[components.llm.task.template]
@llm_templates = "text-to-text"
template = "CHANGE_ME"

[components.llm.model]
@llm_models = "spacy.OpenAI.v1"
model = "gpt-4-turbo"
max_tokens = 500
config = {"temperature": 0.3}

[components.llm.backend]
api_key = "CHANGE_ME"

The python script I was using was importing SpacyLLM from spacy_llm. I was getting the following error at first:

from spacy_llm import SpacyLLM
ImportError: cannot import name 'SpacyLLM' from 'spacy_llm' (/Users/psarkar/opt/anaconda3/lib/python3.9/site-packages/spacy_llm/__init__.py)

I re-installed spacy_llm , thinking that there might have been some problem during installation but that did not resolve the problem. I commented out the import but has been running into the following error now:

Traceback (most recent call last):
  File "/Users/psarkar/model-training/scripts/test_spacy_llm.py", line 7, in <module>
    llm_component = nlp.add_pipe("llm")
  File "/Users/psarkar/opt/anaconda3/lib/python3.9/site-packages/spacy/language.py", line 821, in add_pipe
    pipe_component = self.create_pipe(
  File "/Users/psarkar/opt/anaconda3/lib/python3.9/site-packages/spacy/language.py", line 709, in create_pipe
    resolved = registry.resolve(cfg, validate=validate)
  File "/Users/psarkar/opt/anaconda3/lib/python3.9/site-packages/confection/__init__.py", line 759, in resolve
    resolved, _ = cls._make(
  File "/Users/psarkar/opt/anaconda3/lib/python3.9/site-packages/confection/__init__.py", line 808, in _make
    filled, _, resolved = cls._fill(
  File "/Users/psarkar/opt/anaconda3/lib/python3.9/site-packages/confection/__init__.py", line 880, in _fill
    getter_result = getter(*args, **kwargs)
  File "/Users/psarkar/opt/anaconda3/lib/python3.9/site-packages/spacy_llm/pipeline/llm.py", line 81, in make_llm
    raise ValueError(
ValueError: Argument `task` has not been specified, but is required (e. g. {'@llm_tasks': 'spacy.NER.v3'}).

Even though @llm_tasks is defined. I would like to initialise the task with spacy.LLM.v1 but have been running into problem. Could somebody please provide some clarity on the situation and what I might be doing wrong?

## Info about spaCy

- **spaCy version:** 3.7.2
- **Platform:** macOS-10.16-x86_64-i386-64bit
- **Python version:** 3.9.12
- **Pipelines:** en_core_web_sm (3.7.1), en_core_web_lg (3.7.1)
@WillDomvo
Copy link

Hi PrithatSarkar, thanks for sharing your issue.

  • Did you get it resolved?

From looking up the docs, I was unable to find any module called SpacyLLM. The docs recommend to simply call:
import spacy_llm

Cheers,
Will

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants