few more small fixes

This commit is contained in:
svlandeg 2023-09-01 13:59:38 +02:00
parent 4d7c677b2c
commit f852c586f8
2 changed files with 19 additions and 13 deletions

View File

@ -160,9 +160,9 @@ The NER task identifies non-overlapping entities in text.
#### spacy.NER.v3 {id="ner-v3"} #### spacy.NER.v3 {id="ner-v3"}
Version 3 is fundamentally different to v1 and v2, as it implements Version 3 is fundamentally different to v1 and v2, as it implements
Chain-of-Thought prompting, based on Chain-of-Thought prompting, based on the
[the PromptNER paper by Ashok and Lipton (2023)](https://arxiv.org/pdf/2305.15444.pdf). [PromptNER paper](https://arxiv.org/pdf/2305.15444.pdf) by Ashok and Lipton
From preliminary experiments, we've found this implementation to obtain (2023). From preliminary experiments, we've found this implementation to obtain
significant better accuracy. significant better accuracy.
> #### Example config > #### Example config
@ -191,8 +191,9 @@ means that the task will always perform few-shot prompting under the hood.
Note that the `single_match` parameter, used in v1 and v2, is not supported Note that the `single_match` parameter, used in v1 and v2, is not supported
anymore, as the CoT parsing algorithm takes care of this automatically. anymore, as the CoT parsing algorithm takes care of this automatically.
New to v3 is the fact that you can provide an explicit description of what entities should look like. New to v3 is the fact that you can provide an explicit description of what
You can use this feature in addition to `label_definitions`. entities should look like. You can use this feature in addition to
`label_definitions`.
```ini ```ini
[components.llm.task] [components.llm.task]
@ -214,9 +215,10 @@ you can write down a few examples in a separate file, and provide these to be
injected into the prompt to the LLM. The default reader `spacy.FewShotReader.v1` injected into the prompt to the LLM. The default reader `spacy.FewShotReader.v1`
supports `.yml`, `.yaml`, `.json` and `.jsonl`. supports `.yml`, `.yaml`, `.json` and `.jsonl`.
While not required, this task works best when both positive and negative examples are provided. While not required, this task works best when both positive and negative
The format is different than the files required for v1 and v2, as additional fields such as examples are provided. The format is different than the files required for v1
`is_entity` and `reason` should now be provided. and v2, as additional fields such as `is_entity` and `reason` should now be
provided.
```json ```json
[ [
@ -247,7 +249,8 @@ The format is different than the files required for v1 and v2, as additional fie
path = "${paths.examples}" path = "${paths.examples}"
``` ```
For a fully working example, see this [usage example](https://github.com/explosion/spacy-llm/tree/main/usage_examples/ner_v3_openai). For a fully working example, see this
[usage example](https://github.com/explosion/spacy-llm/tree/main/usage_examples/ner_v3_openai).
#### spacy.NER.v2 {id="ner-v2"} #### spacy.NER.v2 {id="ner-v2"}
@ -293,12 +296,14 @@ counter examples seems to work quite well.
[components.llm.task] [components.llm.task]
@llm_tasks = "spacy.NER.v2" @llm_tasks = "spacy.NER.v2"
labels = PERSON,SPORTS_TEAM labels = PERSON,SPORTS_TEAM
[components.llm.task.label_definitions] [components.llm.task.label_definitions]
PERSON = "Extract any named individual in the text." PERSON = "Extract any named individual in the text."
SPORTS_TEAM = "Extract the names of any professional sports team. e.g. Golden State Warriors, LA Lakers, Man City, Real Madrid" SPORTS_TEAM = "Extract the names of any professional sports team. e.g. Golden State Warriors, LA Lakers, Man City, Real Madrid"
``` ```
For a fully working example, see this [usage example](https://github.com/explosion/spacy-llm/tree/main/usage_examples/ner_dolly). For a fully working example, see this
[usage example](https://github.com/explosion/spacy-llm/tree/main/usage_examples/ner_dolly).
#### spacy.NER.v1 {id="ner-v1"} #### spacy.NER.v1 {id="ner-v1"}
@ -619,7 +624,8 @@ Note: the REL task relies on pre-extracted entities to make its prediction.
Hence, you'll need to add a component that populates `doc.ents` with recognized Hence, you'll need to add a component that populates `doc.ents` with recognized
spans to your spaCy pipeline and put it _before_ the REL component. spans to your spaCy pipeline and put it _before_ the REL component.
For a fully working example, see this [usage example](https://github.com/explosion/spacy-llm/tree/main/usage_examples/rel_openai). For a fully working example, see this
[usage example](https://github.com/explosion/spacy-llm/tree/main/usage_examples/rel_openai).
### Lemma {id="lemma"} ### Lemma {id="lemma"}

View File

@ -142,7 +142,7 @@ pipeline = ["llm"]
factory = "llm" factory = "llm"
[components.llm.task] [components.llm.task]
@llm_tasks = "spacy.NER.v2" @llm_tasks = "spacy.NER.v3"
labels = ["PERSON", "ORGANISATION", "LOCATION"] labels = ["PERSON", "ORGANISATION", "LOCATION"]
[components.llm.model] [components.llm.model]
@ -366,7 +366,7 @@ evaluate the component.
| Component | Description | | Component | Description |
| ----------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | | ----------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| [`spacy.Summarization.v1`](/api/large-language-models#summarization-v1) | The summarization task prompts the model for a concise summary of the provided text. | | [`spacy.Summarization.v1`](/api/large-language-models#summarization-v1) | The summarization task prompts the model for a concise summary of the provided text. |
| [`spacy.NER.v3`](/api/large-language-models#ner-v3 | Implements Chain-of-Thought reasoning for NER extraction - obtains higher accuracy than v1 or v2. | | [`spacy.NER.v3`](/api/large-language-models#ner-v3) | Implements Chain-of-Thought reasoning for NER extraction - obtains higher accuracy than v1 or v2. |
| [`spacy.NER.v2`](/api/large-language-models#ner-v2) | Builds on v1 and additionally supports defining the provided labels with explicit descriptions. | | [`spacy.NER.v2`](/api/large-language-models#ner-v2) | Builds on v1 and additionally supports defining the provided labels with explicit descriptions. |
| [`spacy.NER.v1`](/api/large-language-models#ner-v1) | The original version of the built-in NER task supports both zero-shot and few-shot prompting. | | [`spacy.NER.v1`](/api/large-language-models#ner-v1) | The original version of the built-in NER task supports both zero-shot and few-shot prompting. |
| [`spacy.SpanCat.v3`](/api/large-language-models#spancat-v3) | Adaptation of the v3 NER task to support overlapping entities and store its annotations in `doc.spans`. | | [`spacy.SpanCat.v3`](/api/large-language-models#spancat-v3) | Adaptation of the v3 NER task to support overlapping entities and store its annotations in `doc.spans`. |