Running into problems while using spaCy LLM.
- Dominant language
- Python
- Stars
- 33.9k
- Forks
- 4.7k
- Avg merge
- 3m
- Merged PRs (30d)
- 1
Description
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
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)
```
Contributor guide
Assessment
This issue has not been assessed yet.