From a804b83a4bb8cbe1c49ba529ad1d54d6f32de3a5 Mon Sep 17 00:00:00 2001 From: Sofie Van Landeghem Date: Tue, 31 Oct 2023 22:07:07 +0100 Subject: [PATCH] Update llm docs to clarify task-specific factories (#13082) * fix typo * add examples to specify custom model for task-specific factory --- website/docs/api/large-language-models.mdx | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/website/docs/api/large-language-models.mdx b/website/docs/api/large-language-models.mdx index 55d137e21..5739a6c2f 100644 --- a/website/docs/api/large-language-models.mdx +++ b/website/docs/api/large-language-models.mdx @@ -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 @@ -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).