Skip to content

Commit

Permalink
Merge branch 'guardrails' of github.com:jngz-es/documentation-website…
Browse files Browse the repository at this point in the history
… into guardrails
  • Loading branch information
kolchfa-aws committed Mar 28, 2024
2 parents 2b13532 + 5475f8e commit 6c71e53
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions _ml-commons-plugin/api/model-apis/register-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ OpenSearch responds with the `task_id` and task `status`.

### The `guardrails` parameter

Guardrails act like safety measures for large language models (LLMs). They provide a set of rules and boundaries that control how an LLM behaves and what kind of outputs it generates.
Guardrails are safety measures for large language models (LLMs). They provide a set of rules and boundaries that control how an LLM behaves and what kind of output it generates.

To register an externally hosted model with guardrails, provide the `guardrails` parameter, which supports the following fields. All fields are optional.

Expand Down Expand Up @@ -300,11 +300,11 @@ POST /_plugins/_ml/models/_register
```
{% include copy-curl.html %}

For an end-to-end example, see [Guardrails]({{site.url}}{{site.baseurl}}/ml-commons-plugin/remote-models/guardrails/).
For a complete example, see [Guardrails]({{site.url}}{{site.baseurl}}/ml-commons-plugin/remote-models/guardrails/).

#### Example response

OpenSearch responds with the `task_id` and task `status`.
OpenSearch responds with the `task_id` and task `status`:

```json
{
Expand Down
10 changes: 5 additions & 5 deletions _ml-commons-plugin/remote-models/guardrails.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ grand_parent: Integrating ML models
**Introduced 2.13**
{: .label .label-purple }

Guardrails can guide a large language model (LLM) toward desired behavior. They act as a filter, preventing the LLM from generating outputs that are harmful or violate ethical principles and facilitating a safer use of AI. Guardrails also steer the LLM to produce a more focused and relevant output.
Guardrails can guide a large language model (LLM) toward desired behavior. They act as a filter, preventing the LLM from generating output that is harmful or violates ethical principles and facilitating safer use of AI. Guardrails also cause the LLM to produce more focused and relevant output.

To configure guardrails for your LLM, you can provide a list of words that are prohibited in the input or output of the model. Alternatively, you can provide a regular expression against which the model input or output will be matched.
To configure guardrails for your LLM, you can provide a list of words to be prohibited in the input or output of the model. Alternatively, you can provide a regular expression against which the model input or output will be matched.

## Prerequisites

Before you start, make sure you have fulfilled the [prerequisites]({{site.url}}{{site.baseurl}}/ml-commons-plugin/remote-models/index/#prerequisites) for connecting to an externally hosted model.

## Step 1: Create a guardrail index

To start, create an index that will hold the excluded words (_stopwords_). In the index settings, specify for the index to contain a `title` field, which will contain excluded words, and a `query` field, which is of the [percolator]({{site.url}}{{site.baseurl}}/field-types/supported-field-types/percolator/) type. The percolator query will be used to match the LLM input or output:
To start, create an index that will store the excluded words (_stopwords_). In the index settings, specify a `title` field, which will contain excluded words, and a `query` field of the [percolator]({{site.url}}{{site.baseurl}}/field-types/supported-field-types/percolator/) type. The percolator query will be used to match the LLM input or output:

```json
PUT /words0
Expand Down Expand Up @@ -97,7 +97,7 @@ To learn more about model groups, see [Model access control]({{site.url}}{{site.

## Step 4: Create a connector

Create a connector to the model. In this example, you'll create a connector to the Anthropic Claude model hosted on Amazon Bedrock:
Now you can create a connector for the model. In this example, you'll create a connector to the Anthropic Claude model hosted on Amazon Bedrock:

```json
POST /_plugins/_ml/connectors/_create
Expand Down Expand Up @@ -291,7 +291,7 @@ The response contains an error message because guardrails were triggered:
}
```

The guardrails are also triggered when a prompt matches the supplied regular expression.
Guardrails are also triggered when a prompt matches the supplied regular expression.

## Next steps

Expand Down
2 changes: 1 addition & 1 deletion _ml-commons-plugin/remote-models/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,4 @@ To learn how to use the model for vector search, see [Using an ML model for neur
- For more information about connector parameters, see [Connector blueprints]({{site.url}}{{site.baseurl}}/ml-commons-plugin/remote-models/blueprints/).
- For more information about managing ML models in OpenSearch, see [Using ML models within OpenSearch]({{site.url}}{{site.baseurl}}/ml-commons-plugin/model-serving-framework/).
- For more information about interacting with ML models in OpenSearch, see [Managing ML models in OpenSearch Dashboards]({{site.url}}{{site.baseurl}}/ml-commons-plugin/ml-dashboard/)
For steps to configure model guardrails, see [Guardrails]({{site.url}}{{site.baseurl}}/ml-commons-plugin/remote-models/guardrails/)
For instructions on how to configure model guardrails, see [Guardrails]({{site.url}}{{site.baseurl}}/ml-commons-plugin/remote-models/guardrails/).

0 comments on commit 6c71e53

Please sign in to comment.