diff --git a/website/docs/api/large-language-models.mdx b/website/docs/api/large-language-models.mdx index 4cf8c3c99..e914353cc 100644 --- a/website/docs/api/large-language-models.mdx +++ b/website/docs/api/large-language-models.mdx @@ -1477,20 +1477,21 @@ These models all take the same parameters: > > ```ini > [components.llm.model] -> @llm_models = "spacy.Llama2.v1" +> @llm_models = "spacy.HF.v1" > name = "Llama-2-7b-hf" > ``` -Currently, these models are provided as part of the core library: +Currently, these models are provided as part of the core library (more models +can be accessed through the `langchain` integration): -| Model | Provider | Supported names | HF directory | -| -------------------- | --------------- | ------------------------------------------------------------------------------------------------------------ | -------------------------------------- | -| `spacy.Dolly.v1` | Databricks | `["dolly-v2-3b", "dolly-v2-7b", "dolly-v2-12b"]` | https://huggingface.co/databricks | -| `spacy.Falcon.v1` | TII | `["falcon-rw-1b", "falcon-7b", "falcon-7b-instruct", "falcon-40b-instruct"]` | https://huggingface.co/tiiuae | -| `spacy.Llama2.v1` | Meta AI | `["Llama-2-7b-hf", "Llama-2-13b-hf", "Llama-2-70b-hf"]` | https://huggingface.co/meta-llama | -| `spacy.Mistral.v1` | Mistral AI | `["Mistral-7B-v0.1", "Mistral-7B-Instruct-v0.1"]` | https://huggingface.co/mistralai | -| `spacy.StableLM.v1` | Stability AI | `["stablelm-base-alpha-3b", "stablelm-base-alpha-7b", "stablelm-tuned-alpha-3b", "stablelm-tuned-alpha-7b"]` | https://huggingface.co/stabilityai | -| `spacy.OpenLLaMA.v1` | OpenLM Research | `["open_llama_3b", "open_llama_7b", "open_llama_7b_v2", "open_llama_13b"]` | https://huggingface.co/openlm-research | +| Model family | Author | Names of available model | HF directory | +| ------------ | --------------- | ------------------------------------------------------------------------------------------------------------ | -------------------------------------- | +| Dolly | Databricks | `["dolly-v2-3b", "dolly-v2-7b", "dolly-v2-12b"]` | https://huggingface.co/databricks | +| Falcon | TII | `["falcon-rw-1b", "falcon-7b", "falcon-7b-instruct", "falcon-40b-instruct"]` | https://huggingface.co/tiiuae | +| Llama 2 | Meta AI | `["Llama-2-7b-hf", "Llama-2-13b-hf", "Llama-2-70b-hf"]` | https://huggingface.co/meta-llama | +| Mistral | Mistral AI | `["Mistral-7B-v0.1", "Mistral-7B-Instruct-v0.1"]` | https://huggingface.co/mistralai | +| Stable LM | Stability AI | `["stablelm-base-alpha-3b", "stablelm-base-alpha-7b", "stablelm-tuned-alpha-3b", "stablelm-tuned-alpha-7b"]` | https://huggingface.co/stabilityai | +| OpenLLaMa | OpenLM Research | `["open_llama_3b", "open_llama_7b", "open_llama_7b_v2", "open_llama_13b"]` | https://huggingface.co/openlm-research | @@ -1540,7 +1541,7 @@ To use [LangChain](https://github.com/hwchase17/langchain) for the API retrieval part, make sure you have installed it first: ```shell -python -m pip install "langchain==0.0.191" +python -m pip install "langchain>=0.1,<0.2" # Or install with spacy-llm directly python -m pip install "spacy-llm[extras]" ``` @@ -1550,9 +1551,12 @@ Note that LangChain currently only supports Python 3.9 and beyond. LangChain models in `spacy-llm` work slightly differently. `langchain`'s models are parsed automatically, each LLM class in `langchain` has one entry in `spacy-llm`'s registry. As `langchain`'s design has one class per API and not -per model, this results in registry entries like `langchain.OpenAI.v1` - i. e. -there is one registry entry per API and not per model (family), as for the REST- -and HuggingFace-based entries. +per model, this results in registry entries like `langchain.OpenAIChat.v1` - i. +e. there is one registry entry per API and not per model (family), as for the +REST- and HuggingFace-based entries. LangChain provides access to many more +model that `spacy-llm` does natively, so if your model or provider of choice +isn't available directly, just leverage the `langchain` integration by +specifying your model with `langchain.YourModel.v1`! The name of the model to be used has to be passed in via the `name` attribute. @@ -1560,7 +1564,7 @@ The name of the model to be used has to be passed in via the `name` attribute. > > ```ini > [components.llm.model] -> @llm_models = "langchain.OpenAI.v1" +> @llm_models = "langchain.OpenAIChat.v1" > name = "gpt-3.5-turbo" > query = {"@llm_queries": "spacy.CallLangChain.v1"} > config = {"temperature": 0.0} diff --git a/website/docs/usage/large-language-models.mdx b/website/docs/usage/large-language-models.mdx index c799e91f3..d8e075858 100644 --- a/website/docs/usage/large-language-models.mdx +++ b/website/docs/usage/large-language-models.mdx @@ -107,7 +107,8 @@ factory = "llm" labels = ["COMPLIMENT", "INSULT"] [components.llm.model] -@llm_models = "spacy.GPT-3-5.v1" +@llm_models = "spacy.OpenAI.v1" +name = "gpt-3.5-turbo" config = {"temperature": 0.0} ``` @@ -146,7 +147,7 @@ factory = "llm" labels = ["PERSON", "ORGANISATION", "LOCATION"] [components.llm.model] -@llm_models = "spacy.Dolly.v1" +@llm_models = "spacy.HuggingFace.v1" # For better performance, use dolly-v2-12b instead name = "dolly-v2-3b" ``` @@ -457,12 +458,13 @@ models by specifying one of the models registered with the `langchain.` prefix. _Why LangChain if there are also are native REST and HuggingFace interfaces? When should I use what?_ Third-party libraries like `langchain` focus on prompt management, integration -of many different LLM APIs, and other related features such as conversational -memory or agents. `spacy-llm` on the other hand emphasizes features we consider -useful in the context of NLP pipelines utilizing LLMs to process documents -(mostly) independent from each other. It makes sense that the feature sets of -such third-party libraries and `spacy-llm` aren't identical - and users might -want to take advantage of features not available in `spacy-llm`. +of many different LLM APIs and models, and other related features such as +conversational memory or agents. `spacy-llm` on the other hand emphasizes +features we consider useful in the context of NLP pipelines utilizing LLMs for +(1) extractive NLP and (2) to process documents independent from each other. It +makes sense that the feature sets of such third-party libraries and `spacy-llm` +aren't identical - and users might want to take advantage of features not +available in `spacy-llm`. The advantage of implementing our own REST and HuggingFace integrations is that we can ensure a larger degree of stability and robustness, as we can guarantee @@ -481,36 +483,15 @@ provider's documentation. -| Model | Description | -| ----------------------------------------------------------------------- | ---------------------------------------------- | -| [`spacy.GPT-4.v2`](/api/large-language-models#models-rest) | OpenAI’s `gpt-4` model family. | -| [`spacy.GPT-3-5.v2`](/api/large-language-models#models-rest) | OpenAI’s `gpt-3-5` model family. | -| [`spacy.Text-Davinci.v2`](/api/large-language-models#models-rest) | OpenAI’s `text-davinci` model family. | -| [`spacy.Code-Davinci.v2`](/api/large-language-models#models-rest) | OpenAI’s `code-davinci` model family. | -| [`spacy.Text-Curie.v2`](/api/large-language-models#models-rest) | OpenAI’s `text-curie` model family. | -| [`spacy.Text-Babbage.v2`](/api/large-language-models#models-rest) | OpenAI’s `text-babbage` model family. | -| [`spacy.Text-Ada.v2`](/api/large-language-models#models-rest) | OpenAI’s `text-ada` model family. | -| [`spacy.Davinci.v2`](/api/large-language-models#models-rest) | OpenAI’s `davinci` model family. | -| [`spacy.Curie.v2`](/api/large-language-models#models-rest) | OpenAI’s `curie` model family. | -| [`spacy.Babbage.v2`](/api/large-language-models#models-rest) | OpenAI’s `babbage` model family. | -| [`spacy.Ada.v2`](/api/large-language-models#models-rest) | OpenAI’s `ada` model family. | -| [`spacy.Azure.v1`](/api/large-language-models#models-rest) | Azure's OpenAI models. | -| [`spacy.Command.v1`](/api/large-language-models#models-rest) | Cohere’s `command` model family. | -| [`spacy.Claude-2.v1`](/api/large-language-models#models-rest) | Anthropic’s `claude-2` model family. | -| [`spacy.Claude-1.v1`](/api/large-language-models#models-rest) | Anthropic’s `claude-1` model family. | -| [`spacy.Claude-instant-1.v1`](/api/large-language-models#models-rest) | Anthropic’s `claude-instant-1` model family. | -| [`spacy.Claude-instant-1-1.v1`](/api/large-language-models#models-rest) | Anthropic’s `claude-instant-1.1` model family. | -| [`spacy.Claude-1-0.v1`](/api/large-language-models#models-rest) | Anthropic’s `claude-1.0` model family. | -| [`spacy.Claude-1-2.v1`](/api/large-language-models#models-rest) | Anthropic’s `claude-1.2` model family. | -| [`spacy.Claude-1-3.v1`](/api/large-language-models#models-rest) | Anthropic’s `claude-1.3` model family. | -| [`spacy.PaLM.v1`](/api/large-language-models#models-rest) | Google’s `PaLM` model family. | -| [`spacy.Dolly.v1`](/api/large-language-models#models-hf) | Dolly models through HuggingFace. | -| [`spacy.Falcon.v1`](/api/large-language-models#models-hf) | Falcon models through HuggingFace. | -| [`spacy.Mistral.v1`](/api/large-language-models#models-hf) | Mistral models through HuggingFace. | -| [`spacy.Llama2.v1`](/api/large-language-models#models-hf) | Llama2 models through HuggingFace. | -| [`spacy.StableLM.v1`](/api/large-language-models#models-hf) | StableLM models through HuggingFace. | -| [`spacy.OpenLLaMA.v1`](/api/large-language-models#models-hf) | OpenLLaMA models through HuggingFace. | -| [LangChain models](/api/large-language-models#langchain-models) | LangChain models for API retrieval. | +| Model | Description | +| --------------------------------------------------------------- | -------------------------------------------------- | +| [`spacy.OpenAI.v1`](/api/large-language-models#models-rest) | OpenAI's chat and completion models. | +| [`spacy.Azure.v1`](/api/large-language-models#models-rest) | Azure's OpenAI models. | +| [`spacy.Cohere.v1`](/api/large-language-models#models-rest) | Cohere’s text models. | +| [`spacy.Anthropic.v1`](/api/large-language-models#models-rest) | Anthropic’s text models. | +| [`spacy.Google.v1`](/api/large-language-models#models-rest) | Google’s text models (e. g. PaLM). | +| [`spacy.HuggingFace.v1`](/api/large-language-models#models-hf) | A selection of LLMs available through HuggingFace. | +| [LangChain models](/api/large-language-models#langchain-models) | All models available through `langchain`. | Note that the chat models variants of Llama 2 are currently not supported. This is because they need a particular prompting setup and don't add any discernible