Skip to content

Commit

Permalink
Update llm docs to clarify task-specific factories (#13082)
Browse files Browse the repository at this point in the history
* fix typo

* add examples to specify custom model for task-specific factory
  • Loading branch information
svlandeg authored Oct 31, 2023
1 parent 48248c6 commit a804b83
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions website/docs/api/large-language-models.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ prototyping** and **prompting**, and turning unstructured responses into

## Config and implementation {id="config"}

An LLM component is implemented through the `LLMWrapper` class. It is accessible
through a generic `llm`
[component factory](https://spacy.io/usage/processing-pipelines#custom-components-factories)
as well as through task-specific component factories: `llm_ner`, `llm_spancat`,
`llm_rel`, `llm_textcat`, `llm_sentiment` and `llm_summarization`.

### LLMWrapper.\_\_init\_\_ {id="init",tag="method"}

> #### Example
>
> ```python
Expand All @@ -32,13 +24,26 @@ as well as through task-specific component factories: `llm_ner`, `llm_spancat`,
> llm = nlp.add_pipe("llm", config=config)
>
> # Construction via add_pipe with a task-specific factory and default GPT3.5 model
> llm = nlp.add_pipe("llm-ner")
> llm = nlp.add_pipe("llm_ner")
>
> # Construction via add_pipe with a task-specific factory and custom model
> llm = nlp.add_pipe("llm_ner", config={"model": {"@llm_models": "spacy.Dolly.v1", "name": "dolly-v2-12b"}})
>
> # Construction from class
> from spacy_llm.pipeline import LLMWrapper
> llm = LLMWrapper(vocab=nlp.vocab, task=task, model=model, cache=cache, save_io=True)
> ```
An LLM component is implemented through the `LLMWrapper` class. It is accessible
through a generic `llm`
[component factory](https://spacy.io/usage/processing-pipelines#custom-components-factories)
as well as through task-specific component factories: `llm_ner`, `llm_spancat`,
`llm_rel`, `llm_textcat`, `llm_sentiment` and `llm_summarization`. For these
factories, the GPT-3-5 model from OpenAI is used by default, but this can be
customized.
### LLMWrapper.\_\_init\_\_ {id="init",tag="method"}
Create a new pipeline instance. In your application, you would normally use a
shortcut for this and instantiate the component using its string name and
[`nlp.add_pipe`](/api/language#add_pipe).
Expand Down

0 comments on commit a804b83

Please sign in to comment.