Skip to content

Commit 13ec465

Browse files
authored
Documentation updates for latest AI changes. (#371)
* ML docs housekeeping for LLMs, add OpenAI to spiceaidocs/docs/components/models * add configurable LLMS, dataset[*].embeddings reference docs * lint * Apply suggestions from code review Co-authored-by: peasee <98815791+peasee@users.noreply.github.com> Co-authored-by: Evgenii Khramkov <evgenii@spice.ai> * Update models.md * Update datasets.md * Update runtime_tools.md
1 parent 22f2532 commit 13ec465

8 files changed

Lines changed: 171 additions & 22 deletions

File tree

spiceaidocs/docs/components/models/huggingface.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ models:
1313
- from: huggingface:huggingface.co/spiceai/darts:latest
1414
name: hf_model
1515
files:
16-
- model.onnx
16+
- path: model.onnx
1717
datasets:
1818
- taxi_trips
1919
```
@@ -44,4 +44,4 @@ The `from` key follows the following regex format:
4444
- ML models currently only support ONNX file format.
4545
- Only ONNX and GGUF file formats are currently supported.
4646

47-
:::
47+
:::

spiceaidocs/docs/components/models/index.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,22 @@ sidebar_label: 'AI/ML Models'
44
description: ''
55
---
66

7-
Machine Learning (ML) models can be deployed and loaded from the following sources.
7+
Spice supports traditional machine learning (ML) models and language models (LLMs).
88

99
- **Filesystem**: [ONNX](https://onnx.ai) models.
1010
- **HuggingFace**: ONNX models hosted on [HuggingFace](https://huggingface.co).
1111
- **Spice Cloud Platform**: Models hosted on the [Spice Cloud Platform](https://docs.spice.ai/building-blocks/spice-models).
12+
- **OpenAI**: OpenAI (or compatible) LLM endpoints.
1213

13-
Defined in the `spicepod.yml`, a `model` component has the following format.
14+
### Model Sources
1415

15-
| field | Description |
16-
| ---------- | ----------------------------------------------------------------------- |
17-
| `name` | Unique, readable name for the model within the Spicepod. |
18-
| `from` | Source-specific address to uniquely identify a model |
19-
| `datasets` | Datasets that the model depends on for inference |
20-
| `files` | Specify additional files, or override default files needed by the model |
16+
| Name | Description | ML Format(s) | LLM Format(s)* |
17+
| ---------------------------- | ---------------- | ------------ | ----------------------- |
18+
| `file` | Local filesystem | ONNX | GGUF, GGML, SafeTensor |
19+
| `huggingface:huggingface.co` | Models hosted on [HuggingFace](https://huggingface.co) | ONNX | GGUF, GGML, SafeTensor |
20+
| `spice.ai` | Models hosted on the [Spice Cloud Platform](https://docs.spice.ai/building-blocks/spice-models) | ONNX | - |
21+
| `openai` | OpenAI (or compatible) LLM endpoint | - | Remote HTTP endpoint |
2122

22-
For more detail, refer to the `model` [reference specification](/reference/spicepod/models.md).
23+
* LLM Format(s) may require additional files (e.g. `tokenizer_config.json`).
2324

24-
## Model Sources
25-
26-
import DocCardList from '@theme/DocCardList';
27-
28-
<DocCardList />
25+
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).
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: 'OpenAI (or Compatible) Language Models'
3+
sidebar_label: 'OpenAI'
4+
sidebar_position: 4
5+
---
6+
7+
To use a language model hosted on OpenAI (or compatible), specify the `openai` path in `from`.
8+
9+
For a specific model, include it as the model ID in `from` (see example below). Defaults to `"gpt-3.5-turbo"`.
10+
These parameters are specific to OpenAI models:
11+
12+
| Param | Description | Default |
13+
| ----- | ----------- | ------- |
14+
| `openai_api_key` | The OpenAI API key. | - |
15+
| `openai_org_id` | The OpenAI organization id. | - |
16+
| `openai_project_id` | The OpenAI project id. | - |
17+
| `endpoint` | The OpenAI API base endpoint. | `https://api.openai.com/v1` |
18+
19+
20+
Example:
21+
22+
```yaml
23+
models:
24+
- from: openai:gpt-4o
25+
name: local_fs_model
26+
params:
27+
openai_api_key: ${ secrets:SPICE_OPENAI_API_KEY }
28+
29+
- from: openai:llama3-groq-70b-8192-tool-use-preview
30+
name: groq-llama
31+
params:
32+
endpoint: https://api.groq.com/openai/v1
33+
openai_api_key: ${ secrets:SPICE_GROQ_API_KEY }
34+
```
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
title: 'Language Model Overrides'
3+
sidebar_label: 'Default overrides'
4+
description: 'Learn how to override default LLM hyperparameters in Spice.'
5+
sidebar_position: 1
6+
pagination_prev: null
7+
pagination_next: null
8+
---
9+
10+
### Chat Completion Parameter Overrides
11+
[`v1/chat/completion`](/api/http/chat-completions) is an OpenAI compatible endpoint.
12+
13+
It supports all request body parameters defined in the [OpenAI reference documentation](https://platform.openai.com/docs/api-reference/chat/create). Spice can configure different defaults for these request parameters.
14+
```yaml
15+
models:
16+
- name: pirate-haikus
17+
from: openai:gpt-4o
18+
params:
19+
openai_temperature: 0.1
20+
openai_response_format: { "type": "json_object" }
21+
```
22+
To specify a default override for a parameter, use the `openai_` prefix followed by the parameter name. For example, to set the `temperature` parameter to `0.1`, use `openai_temperature: 0.1`.
23+
24+
### System Prompt
25+
In addition to any system prompts provided in message dialogue, or added by model providers, Spice can configure an additional system prompt.
26+
```yaml
27+
models:
28+
- name: pirate-haikus
29+
from: openai:gpt-4o
30+
params:
31+
system_prompt: |
32+
Write everything in Haiku like a pirate
33+
```
34+
35+
Any request to [HTTP `v1/chat/completion`](/api/http/chat-completions) will include the configured system prompt.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
title: 'Configuring Language Models'
3+
sidebar_label: 'Configuring LLMs'
4+
description: 'Learn how to configure language models in Spice.'
5+
sidebar_position: 7
6+
pagination_prev: null
7+
pagination_next: null
8+
---
9+
10+
Spice supports language models (LLMs) from several sources (see [model components](/components/models/index.md)) and provides configuration for how inference will be performed in the Spice runtime. This includes:
11+
- Providing tools to the language model, enabling it to interact with the Spice runtime.
12+
- Specifying system prompts and overriding defaults for [`v1/chat/completion`](/api/http/chat-completions.md).
13+
14+
15+
import DocCardList from '@theme/DocCardList';
16+
17+
<DocCardList />
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
title: 'Giving Language Models Runtime Tools'
3+
sidebar_label: 'Runtime tools'
4+
description: 'Learn how LLMs can interact with the spice runtime.'
5+
sidebar_position: 2
6+
pagination_prev: null
7+
pagination_next: null
8+
---
9+
10+
Spice provides a set of tools that let LLMs interact with the runtime. To provide these tools to a Spice model, specify them in its `params.spice_tools`.
11+
```yaml
12+
models:
13+
- name: sql-model
14+
from: openai:gpt-4o
15+
params:
16+
spice_tools: list_datasets, sql, table_schema
17+
18+
- name: full-runtime
19+
from: openai:gpt-4o
20+
params:
21+
spice_tools: auto # Use all available tools
22+
```
23+
24+
## Available tools
25+
- `list_datasets`: List all available datasets in the runtime.
26+
- `sql`: Execute SQL queries on the runtime.
27+
- `table_schema`: Get the schema of a specific SQL table.
28+
- `document_similarity`: For datasets with an embedding column, retrieve documents based on an input query. It is equivalent to [/v1/search](/api/http/search).

spiceaidocs/docs/reference/spicepod/datasets.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,3 +325,28 @@ datasets:
325325
# alternatively "drop" can be used instead of "upsert" to drop the data update.
326326
hash: upsert
327327
```
328+
329+
## `embeddings`
330+
331+
Optional. Create vector embeddings for specific columns of the dataset.
332+
333+
```yaml
334+
datasets:
335+
- from: spice.ai/eth.recent_blocks
336+
name: eth.recent_blocks
337+
embeddings:
338+
- column: extra_data
339+
use: hf_minilm
340+
```
341+
342+
## `embeddings[*].column`
343+
344+
The column name to create an embedding for.
345+
346+
## `embeddings[*].use`
347+
348+
The embedding model to use, specific the component name `embeddings[*].name`.
349+
350+
## `embeddings[*].column_pk`
351+
352+
Optional. For datasets without a primary key, explicitly specify column(s) that uniquely identify a row.

spiceaidocs/docs/reference/spicepod/models.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ The model specifications are in early preview and are subject to change.
1616
Spice supports both traditional machine learning (ML) models and language models (LLMs). The configuration allows you to specify either type from a variety of sources. The model type is automatically determined based on the model source and files.
1717

1818

19+
| field | Description |
20+
| ------------- | ----------------------------------------------------------------------- |
21+
| `name` | Unique, readable name for the model within the Spicepod. |
22+
| `from` | Source-specific address to uniquely identify a model |
23+
| `description` | Additional details about the model, useful for displaying to users |
24+
| `datasets` | Datasets that the model depends on for inference |
25+
| `files` | Specify additional files, or override default files needed by the model |
26+
| `params` | Additional parameters to be passed to the model |
27+
1928
## `models`
2029

2130
The `models` section in your configuration allows you to specify one or more models to be used with your datasets.
@@ -41,13 +50,13 @@ models:
4150
4251
### `from`
4352

44-
The `from` field specifies both the source of the model, and the unique identifier of the model (relative to the source). The `from` value expects the following format
53+
The `from` field specifies both the source of the model (e.g Huggingface, or a local file), and the unique identifier of the model (relative to the source). The `from` value expects the following format
4554

4655
```yaml
4756
- from: <model_source>/<model id>
4857
```
4958

50-
### Model Source
59+
#### Model Source
5160

5261
The `<model_source>` prefix of the `from` field indicates where the model is sourced from:
5362

@@ -56,7 +65,7 @@ The `<model_source>` prefix of the `from` field indicates where the model is sou
5665
- `openai` - OpenAI (or compatible) models
5766
- `spiceai` - Spice AI models
5867

59-
### Model ID
68+
#### Model ID
6069

6170
The `<model_id>` suffix of the `from` field is a unique (per source) identifier for the model:
6271

@@ -65,13 +74,17 @@ The `<model_id>` suffix of the `from` field is a unique (per source) identifier
6574
- For Hugging Face: A repo_id and, optionally, revision hash or tag.
6675
- `Qwen/Qwen1.5-0.5B` (no revision)
6776
- `meta-llama/Meta-Llama-3-8B:cd892e8f4da1043d4b01d5ea182a2e8412bf658f` (with revision hash)
68-
- For local files: Represents the absolute or relative path to the model weights file on the local file system. See [below](#files) for the accepted model weight types and formats.
77+
- For local files: Represents the absolute or relative path to the model weights file on the local file system. See [below](#files) for the accepted model weight types and formats.
6978
- For OpenAI: Only supports LMs. For OpenAI models, valid IDs can be found in their model [documentation](https://platform.openai.com/docs/models/continuous-model-upgrades). For OpenAI compatible providers, specify the value required in their `v1/chat/completion` [payload](https://platform.openai.com/docs/api-reference/chat/create#chat-create-model).
7079

7180
### `name`
7281

7382
A unique identifier for this model component.
7483

84+
### `description`
85+
86+
Additional details about the model, useful for displaying to users
87+
7588
### `files`
7689

7790
Optional. A list of files associated with this model. Each file has:
@@ -106,8 +119,8 @@ Optional. A map of key-value pairs for additional parameters specific to the mod
106119

107120
### `datasets`
108121

109-
Optional. A list of [dataset names](./datasets.md#name) that this model should be applied to. For ML models, this preselects the dataset to use for inference.
122+
Optional. A list of [dataset names](./datasets.md#name) that this model should be applied to. For ML models, this preselects the dataset to use for inference.
110123

111124
### `dependsOn`
112125

113-
Optional. A list of dependencies that must be loaded and available before this model.
126+
Optional. A list of dependencies that must be loaded and available before this model.

0 commit comments

Comments
 (0)