Skip to content

Commit

Permalink
Improve user messaging and documentation for Cross-Region Inference o…
Browse files Browse the repository at this point in the history
…n Amazon Bedrock (jupyterlab#1134)

* Updated UI and documentation for Amazon Bedrock Cross Region Inference

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* screenshot for CRI usage

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Consolidated Bedrock chat documentation

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update bedrock.md

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update install.sh

* Update install.sh

* Fix install step in CI (jupyterlab#1139)

* fix install in CI

* pre-commit

* Update docs/source/users/index.md

Co-authored-by: david qiu <[email protected]>

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: david qiu <[email protected]>
  • Loading branch information
3 people authored Dec 6, 2024
1 parent f7dabb3 commit 5ffe481
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 28 deletions.
Binary file modified docs/source/_static/bedrock-chat-basemodel-arn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/_static/bedrock-chat-basemodel-modelid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/_static/bedrock-chat-custom-model-arn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/source/_static/bedrock-model-select.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 33 additions & 4 deletions docs/source/users/bedrock.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Using Amazon Bedrock with Jupyter AI

[(Return to Chat Interface page for Bedrock)](index.md#amazon-bedrock-usage)
[(Return to the Chat Interface page)](index.md#amazon-bedrock-usage)

Bedrock supports many language model providers such as AI21 Labs, Amazon, Anthropic, Cohere, Meta, and Mistral AI. To use the base models from any supported provider make sure to enable them in Amazon Bedrock by using the AWS console. Go to Amazon Bedrock and select `Model Access` as shown here:
Bedrock supports many language model providers such as AI21 Labs, Amazon, Anthropic, Cohere, Meta, and Mistral AI. To use the base models from any supported provider make sure to enable them in Amazon Bedrock by using the AWS console. You should also select embedding models in Bedrock in addition to language completion models if you intend to use retrieval augmented generation (RAG) on your documents.

Go to Amazon Bedrock and select `Model Access` as shown here:

<img src="../_static/bedrock-model-access.png"
width="75%"
Expand All @@ -25,7 +27,16 @@ You may now select a chosen Bedrock model from the drop-down menu box title `Com
alt='Screenshot of the Jupyter AI chat panel where the base language model and embedding model is selected.'
class="screenshot" />

Bedrock also allows custom models to be trained from scratch or fine-tuned from a base model. Jupyter AI enables a custom model to be called in the chat panel using its `arn` (Amazon Resource Name). As with custom models, you can also call a base model by its `model id` or its `arn`. An example of using a base model with its `model id` through the custom model interface is shown below:
If your provider requires an API key, please enter it in the box that will show for that provider. Make sure to click on `Save Changes` to ensure that the inputs have been saved.

Bedrock also allows custom models to be trained from scratch or fine-tuned from a base model. Jupyter AI enables a custom model to be called in the chat panel using its `arn` (Amazon Resource Name). A fine-tuned model will have your 12-digit customer number in the ARN:

<img src="../_static/bedrock-chat-custom-model-arn.png"
width="75%"
alt='Screenshot of the Jupyter AI chat panel where the custom model is selected using model arn.'
class="screenshot" />

As with custom models, you can also call a base model by its `model id` or its `arn`. An example of using a base model with its `model id` through the custom model interface is shown below:

<img src="../_static/bedrock-chat-basemodel-modelid.png"
width="75%"
Expand All @@ -39,6 +50,8 @@ An example of using a base model using its `arn` through the custom model interf
alt='Screenshot of the Jupyter AI chat panel where the base model is selected using its ARN.'
class="screenshot" />

## Fine-tuning in Bedrock

To train a custom model in Amazon Bedrock, select `Custom models` in the Bedrock console as shown below, and then you may customize a base model by fine-tuning it or continuing to pre-train it:

<img src="../_static/bedrock-custom-models.png"
Expand All @@ -57,4 +70,20 @@ Once the model is fine-tuned, it will have its own `arn`, as shown below:

As seen above, you may click on `Purchase provisioned throughput` to buy inference units with which to call the custom model's API. Enter the model's `arn` in Jupyter AI's Language model user interface to use the provisioned model.

[(Return to Chat Interface page for Bedrock)](index.md#amazon-bedrock-usage)
## Cross-Region Inference

Amazon Bedrock now permits cross-region inference, where a model hosted in a different region than that of the user may be specified, see the [inference profiles documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html). Such models have IDs prefixed by a region identifier such as `us.meta.llama3-2-1b-instruct-v1:0`, for example. To use this feature, simply enter the Inference profile ID for the cross-region model instead of the ARN.

<img src="../_static/bedrock-cross-region-inference.png"
width="75%"
alt='Screenshot of Bedrock cross-region inference usage.'
class="screenshot" />

## Summary

1. Bedrock Base models: All available models will already be available in the drop down model list. The above interface also allows use of base model IDs or ARNs, though this is unnecessary as they are in the dropdown list.
2. Bedrock Custom models: If you have fine-tuned a Bedrock base model you may use the ARN for this custom model. Make sure to enter the correct provider information, such as `amazon`, `anthropic`, `cohere`, `meta`, `mistral` (always in lower case).
3. Provisioned Models: These are models that run on dedicated endpoints. Users can purchase Provisioned Throughput Model Units to get faster throughput. These may be base or custom models. Enter the ARN for these models in the Model ID field.
4. Cross-region Inference: Use the Inference profile ID for the cross-region model instead of the ARN.

[(Return to the Chat Interface page)](index.md#amazon-bedrock-usage)
24 changes: 2 additions & 22 deletions docs/source/users/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,29 +334,9 @@ The chat backend remembers the last two exchanges in your conversation and passe

### Amazon Bedrock Usage

Jupyter AI enables use of language models hosted on [Amazon Bedrock](https://aws.amazon.com/bedrock/) on AWS. First, ensure that you have authentication to use AWS using the `boto3` SDK with credentials stored in the `default` profile. Guidance on how to do this can be found in the [`boto3` documentation](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html).
Jupyter AI enables use of language models hosted on [Amazon Bedrock](https://aws.amazon.com/bedrock/) on AWS. Ensure that you have authentication to use AWS using the `boto3` SDK with credentials stored in the `default` profile. Guidance on how to do this can be found in the [`boto3` documentation](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html).

For more detailed workflows, see [Using Amazon Bedrock with Jupter AI](bedrock.md).

Bedrock supports many language model providers such as AI21 Labs, Amazon, Anthropic, Cohere, Meta, and Mistral AI. To use the base models from any supported provider make sure to enable them in Amazon Bedrock by using the AWS console. You should also select embedding models in Bedrock in addition to language completion models if you intend to use retrieval augmented generation (RAG) on your documents.

You may now select a chosen Bedrock model from the drop-down menu box title `Completion model` in the chat interface. If RAG is going to be used then pick an embedding model that you chose from the Bedrock models as well. An example of these selections is shown below:

<img src="../_static/bedrock-chat-basemodel.png"
width="50%"
alt='Screenshot of the Jupyter AI chat panel where the base language model and embedding model is selected.'
class="screenshot" />

If your provider requires an API key, please enter it in the box that will show for that provider. Make sure to click on `Save Changes` to ensure that the inputs have been saved.

Bedrock also allows custom models to be trained from scratch or fine-tuned from a base model. Jupyter AI enables a custom model to be called in the chat panel using its `arn` (Amazon Resource Name). The interface is shown below:

<img src="../_static/bedrock-chat-custom-model-arn.png"
width="75%"
alt='Screenshot of the Jupyter AI chat panel where the custom model is selected using model arn.'
class="screenshot" />

For detailed workflows, see [Using Amazon Bedrock with Jupter AI](bedrock.md).
For details on enabling model access in your AWS account, using cross-region inference, or invoking custom/provisioned models, please see our dedicated documentation page on [using Amazon Bedrock in Jupyter AI](bedrock.md).


### SageMaker endpoints usage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ class BedrockCustomProvider(BaseProvider, ChatBedrock):
),
]
help = (
"Specify the ARN (Amazon Resource Name) of the custom/provisioned model as the model ID. For more information, see the [Amazon Bedrock model IDs documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/model-ids.html).\n\n"
"The model provider must also be specified below. This is the provider of your foundation model *in lowercase*, e.g. `amazon`, `anthropic`, `meta`, or `mistral`."
"- For Cross-Region Inference use the appropriate `Inference profile ID` (Model ID with a region prefix, e.g., `us.meta.llama3-2-11b-instruct-v1:0`). See the [inference profiles documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html). \n"
"- For custom/provisioned models, specify the model ARN (Amazon Resource Name) as the model ID. For more information, see the [Amazon Bedrock model IDs documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/model-ids.html).\n\n"
"The model provider must also be specified below. This is the provider of your foundation model *in lowercase*, e.g., `amazon`, `anthropic`, `cohere`, `meta`, or `mistral`."
)
registry = True

Expand Down

0 comments on commit 5ffe481

Please sign in to comment.