-
Notifications
You must be signed in to change notification settings - Fork 198
docs: adds model name virtualization page #856
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| --- | ||
| id: model-name-virtualization | ||
| title: Model Name Virtualization | ||
| sidebar_position: 7 | ||
| --- | ||
|
|
||
| import Tabs from '@theme/Tabs'; | ||
| import TabItem from '@theme/TabItem'; | ||
|
|
||
| Envoy AI Gateway provides an advanced model name virtualization capability that allows you to manage and route requests to different AI models seamlessly. | ||
| This guide covers the key feature and configuration for model virtualization. | ||
|
|
||
| ## Motivation | ||
|
|
||
| It is not uncommon for multiple AI providers to offer a similar or identical model, such as Llama-3-70b, etc. | ||
| However, each provider tends to have its own unique naming convention for the same model. | ||
| For example, `Claude 3.5 Sonnet` is hosted both on GCP and AWS Bedrock, but they have different model names: | ||
| * GCP: `claude-3-5-sonnet-v2@20241022`, etc. | ||
| * AWS Bedrock: `arn:aws:bedrock:us-west-2:123456789012:provisioned-model/abc123xyz` | ||
|
|
||
| From downstream GenAI applications' perspective, it is beneficial to have a unified model name that abstracts away these differences. | ||
|
|
||
| ## Virtualization with modelNameOverride API | ||
|
|
||
| In our top level AIGatewayRoute configuration, you can specify a `modelNameOverride` inside [AIGatewayRouteBackendRef](/api/api.mdx#aigatewayrouterulebackendref) on each route rule to override the model name that is sent to the upstream AI provider. | ||
| This feature is primarily designed for scenarios where you want to dynamically change the model name based on the actual AI provider the request is being sent to. | ||
|
|
||
| The example configuration looks like this: | ||
|
|
||
| ```yaml | ||
| apiVersion: aigateway.envoyproxy.io/v1alpha1 | ||
| kind: AIGatewayRoute | ||
| metadata: | ||
| name: test-route | ||
| spec: | ||
| targetRefs: [...] | ||
| rules: | ||
| - matches: | ||
| - headers: | ||
| - type: Exact | ||
| name: x-ai-eg-model | ||
| value: claude-3-5-sonnet-v2 | ||
| backendRefs: | ||
| - name: aws-backend | ||
| modelNameOverride: arn:aws:bedrock:us-west-2:123456789012:provisioned-model/abc123xyz | ||
| weight: 50 | ||
| - name: gcp-backend | ||
| modelNameOverride: claude-3-5-sonnet-v2@20241022 | ||
| weight: 50 | ||
| ``` | ||
|
|
||
| This configuration allows downstream applications to use a unified model name `claude-3-5-sonnet-v2` while splitting traffic between the AWS Bedrock and GCP AI providers based on the specified `modelNameOverride`. | ||
| This is what the word "Virtualization" means in this context: abstracting away the differences in model names across different AI providers and providing a unified interface for downstream applications. | ||
| It also can be thought of as "one-to-many" aliasing of model names, where one unified model name can map to multiple different model names on different providers depending on the routing path. | ||
|
|
||
| ## Virtualization for fallback scenarios | ||
|
|
||
| As we see in the [Provider Fallback](./provider-fallback) page, Envoy AI Gateway allows you to fallback to a different AI provider if the primary one fails. | ||
| However, sometimes we want to fallback to a different model on the same provider. | ||
| For example, it is natural to set up the Envoy AI Gateway in a way that if the primary expensive model fails (rate limit, etc), Envoy retries the request to a less expensive model on the same provider. | ||
| More concretely, if the request to `gpt-4` fails, we want to retry it with `gpt-3.5-turbo` on the same OpenAI provider. | ||
|
|
||
| `modelNameOverride` can also be used in this scenario to achieve the desired behavior. The configuration would look like this: | ||
|
|
||
| ```yaml | ||
| apiVersion: aigateway.envoyproxy.io/v1alpha1 | ||
| kind: AIGatewayRoute | ||
| metadata: | ||
| name: test-route | ||
| spec: | ||
| targetRefs: [...] | ||
| rules: | ||
| - matches: | ||
| - headers: | ||
| - type: Exact | ||
| name: x-ai-eg-model | ||
| value: gpt-4 | ||
| backendRefs: | ||
| - name: openai-backend | ||
| # This doesn't specify modelNameOverride, so it will use the default model name `gpt-4` in the request. | ||
| priority: 0 | ||
| - name: openai-backend | ||
| modelNameOverride: gpt-3.5-turbo | ||
| priority: 1 | ||
| ``` | ||
|
|
||
| With this configuration, assuming the retry is properly configured as per the [Provider Fallback](./provider-fallback) page, if the request to `gpt-4` fails, Envoy AI Gateway will automatically retry the request to `gpt-3.5-turbo` on the same OpenAI provider without requiring any changes to the downstream application. | ||
missBerg marked this conversation as resolved.
Show resolved
Hide resolved
|
||
6 changes: 6 additions & 0 deletions
6
site/docs/capabilities/traffic/fallback.md → ...capabilities/traffic/provider-fallback.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.