Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to Models section #625

Merged
merged 7 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 14 additions & 20 deletions spiceaidocs/docs/components/models/anthropic.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,30 @@
---
title: 'Anthropic Language Models'
title: 'Anthropic Models'
description: 'Instructions for using language models hosted on Anthropic with Spice.'
sidebar_label: 'Anthropic'
sidebar_position: 5
---

To use a language model hosted on Anthropic, specify `anthropic` in `from`.
To use a language model hosted on Anthropic, specify `anthropic` in the `from` field.

For a specific model, include it as the model ID in `from` (see example below). Defaults to `"claude-3-5-sonnet-20240620"`.
These parameters are specific to Anthropic models:
To use a specific model, include its model ID in the `from` field (see example below). If not specified, the default model is `"claude-3-5-sonnet-latest"`.

| Param | Description | Default |
| ----- | ----------- | ------- |
| `anthropic_api_key` | The Anthropic API key. | - |
| `anthropic_auth_token` | The Anthropic auth token. | - |
| `endpoint` | The Anthropic API base endpoint. | `https://api.anthropic.com/v1` |
The following parameters are specific to Anthropic models:

Example:
| Parameter | Description | Default |
| ---------------------- | -------------------------------- | ------------------------------ |
| `anthropic_api_key` | The Anthropic API key. | - |
| `anthropic_auth_token` | The Anthropic auth token. | - |
| `endpoint` | The Anthropic API base endpoint. | `https://api.anthropic.com/v1` |

Example `spicepod.yml` configuration:

```yaml
models:
- from: anthropic:claude-3-5-sonnet-20240620
- from: anthropic:claude-3-5-sonnet-latest
name: claude_3_5_sonnet
params:
anthropic_api_key: ${ secrets:SPICE_ANTHROPIC_API_KEY }
```

## Supported Models

- `claude-3-5-sonnet-20240620`
- `claude-3-opus-20240229`
- `claude-3-sonnet-20240229`
- `claude-3-haiku-20240307`
- `claude-2.1`
- `claude-2.0`
- `claude-instant-1.2`
See [Anthropic Model Names](https://docs.anthropic.com/en/docs/about-claude/models#model-names) for a list of supported model names.
43 changes: 39 additions & 4 deletions spiceaidocs/docs/components/models/filesystem.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,52 @@
---
title: 'Filesystem'
description: 'Instructions for using models hosted on a filesystem with Spice.'
sidebar_label: 'Filesystem'
sidebar_position: 3
---

To use a ML model hosted on a filesystem, specify the file path in `from`.
To use a model hosted on a filesystem, specify the path to the model file in `from`.

Example:
Supported formats include ONNX for traditional machine learning models and GGUF, GGML, and SafeTensor for large language models (LLMs).

### Example: Loading an ONNX Model

```yaml
models:
- from: file://absolute/path/to/my/model.onnx
name: local_fs_model
datasets:
- taxi_trips
```

### Example: Loading a GGUF Model

```yaml
models:
- from: file://absolute/path/to/my/model.gguf
name: local_ggml_model
```

### Example: Loading a GGML Model

```yaml
models:
- from: file://absolute/path/to/my/model.ggml
name: local_ggml_model
files:
- path: models/llms/ggml/tokenizer.json
- path: models/llms/ggml/tokenizer_config.json
- path: models/llms/ggml/config.json
```

### Example: Loading a SafeTensor Model

```yaml
models:
lukekim marked this conversation as resolved.
Show resolved Hide resolved
- name: safety
from: file:models/llms/llama3.2-1b-instruct/model.safetensors
params:
model_type: llama3
files:
- path: models/llms/llama3.2-1b-instruct/tokenizer.json
- path: models/llms/llama3.2-1b-instruct/tokenizer_config.json
- path: models/llms/llama3.2-1b-instruct/config.json
```
11 changes: 7 additions & 4 deletions spiceaidocs/docs/components/models/huggingface.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
---
title: 'HuggingFace'
description: 'Instructions for using machine learning models hosted on HuggingFace with Spice.'
sidebar_label: 'HuggingFace'
sidebar_position: 1
---

To use a ML model hosted on HuggingFace, specify the `huggingface.co` path in `from` along with the files to include.
To use a model hosted on HuggingFace, specify the `huggingface.co` path in the `from` field along with the files to include.

Example:
Example configuration:

```yaml
models:
Expand Down Expand Up @@ -40,9 +41,11 @@ The `from` key follows the following regex format:
5. **Revision (Optional):** A colon (`:`) followed by the git-like revision identifier (`revision`).

### Access Tokens

Access tokens can be provided for Huggingface models in two ways:
1. In the Huggingface token cache (i.e. `~/.cache/huggingface/token`). Default.
1. Via model params (see below).

1. In the Huggingface token cache (i.e. `~/.cache/huggingface/token`). Default.
1. Via model params (see below).

```yaml
models:
Expand Down
31 changes: 13 additions & 18 deletions spiceaidocs/docs/components/models/index.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
---
title: 'AI/ML Models'
sidebar_label: 'AI/ML Models'
description: ''
title: 'Model Providers'
sidebar_label: 'Model Providers'
description: 'Overview of supported model providers for ML and LLMs in Spice.'
sidebar_position: 5
---

Spice supports traditional machine learning (ML) models and language models (LLMs).
Spice supports various model providers for traditional machine learning (ML) models and large language models (LLMs).

- **Filesystem**: [ONNX](https://onnx.ai) models.
- **HuggingFace**: ONNX models hosted on [HuggingFace](https://huggingface.co).
- **Spice Cloud Platform**: Models hosted on the [Spice Cloud Platform](https://docs.spice.ai/building-blocks/spice-models).
- **OpenAI**: OpenAI (or compatible) LLM endpoints.
| Source | Description | ML Format(s) | LLM Format(s)\* |
| ------------- | ----------------------------------------------------------------------------------------------- | ------------ | ---------------------- |
| `file` | Local filesystem | ONNX | GGUF, GGML, SafeTensor |
| `huggingface` | Models hosted on [HuggingFace](https://huggingface.co) | ONNX | GGUF, GGML, SafeTensor |
| `spice.ai` | Models hosted on the [Spice Cloud Platform](https://docs.spice.ai/building-blocks/spice-models) | ONNX | - |
| `openai` | OpenAI (or compatible) LLM endpoint | - | Remote HTTP endpoint |
| `anthropic` | Models hosted on [Anthropic](https://www.anthropic.com) | - | Remote HTTP endpoint |
| `grok` | Coming soon | - | Remote HTTP endpoint |

### Model Sources

| Name | Description | ML Format(s) | LLM Format(s)* |
| ---------------------------- | ---------------- | ------------ | ----------------------- |
| `file` | Local filesystem | ONNX | GGUF, GGML, SafeTensor |
| `huggingface:huggingface.co` | Models hosted on [HuggingFace](https://huggingface.co) | ONNX | GGUF, GGML, SafeTensor |
| `spice.ai` | Models hosted on the [Spice Cloud Platform](https://docs.spice.ai/building-blocks/spice-models) | ONNX | - |
| `openai` | OpenAI (or compatible) LLM endpoint | - | Remote HTTP endpoint |

* LLM Format(s) may require additional files (e.g. `tokenizer_config.json`).
- LLM Format(s) may require additional files (e.g. `tokenizer_config.json`).

The model type is inferred based on the model source and files. For more detail, refer to the `model` [reference specification](/reference/spicepod/models.md).
42 changes: 34 additions & 8 deletions spiceaidocs/docs/components/models/openai.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
---
title: 'OpenAI (or Compatible) Language Models'
description: 'Instructions for using language models hosted on OpenAI or compatible services with Spice.'
sidebar_label: 'OpenAI'
sidebar_position: 4
---

To use a language model hosted on OpenAI (or compatible), specify the `openai` path in `from`.
To use a language model hosted on OpenAI (or compatible), specify the `openai` path in `from`.

For a specific model, include it as the model ID in `from` (see example below). Defaults to `"gpt-3.5-turbo"`.
These parameters are specific to OpenAI models:

| Param | Description | Default |
| ----- | ----------- | ------- |
| `openai_api_key` | The OpenAI API key. | - |
| `openai_org_id` | The OpenAI organization id. | - |
| `openai_project_id` | The OpenAI project id. | - |
| `endpoint` | The OpenAI API base endpoint. | `https://api.openai.com/v1` |

| Param | Description | Default |
| ------------------- | ----------------------------- | --------------------------- |
| `openai_api_key` | The OpenAI API key. | - |
| `openai_org_id` | The OpenAI organization id. | - |
| `openai_project_id` | The OpenAI project id. | - |
| `endpoint` | The OpenAI API base endpoint. | `https://api.openai.com/v1` |

Example:

Expand All @@ -25,10 +25,36 @@ models:
name: local_fs_model
params:
openai_api_key: ${ secrets:SPICE_OPENAI_API_KEY }
```

## Supported OpenAI Compatible Providers

Spice supports several OpenAI compatible providers. Specify the appropriate endpoint in the params section.

### Groq

Groq provides OpenAI compatible endpoints. Use the following configuration:

```yaml
models:
- from: openai:llama3-groq-70b-8192-tool-use-preview
name: groq-llama
params:
endpoint: https://api.groq.com/openai/v1
openai_api_key: ${ secrets:SPICE_GROQ_API_KEY }
```

### Parasail

Parasail also offers OpenAI compatible endpoints. Use the following configuration:

```yaml
models:
- from: openai:parasail-model-id
name: parasail_model
params:
endpoint: https://api.parasail.com/v1
openai_api_key: ${ secrets:SPICE_PARASAIL_API_KEY }
```

Refer to the respective provider documentation for more details on available models and configurations.
1 change: 1 addition & 0 deletions spiceaidocs/docs/components/models/spiceai.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: 'Spice Cloud Platform'
description: 'Instructions for using models hosted on the Spice Cloud Platform with Spice.'
sidebar_label: 'Spice Cloud Platform'
sidebar_position: 2
---
Expand Down