Skip to content

Commit e4d98ac

Browse files
committed
Initial changes for text-embedding-3
1 parent cb5149d commit e4d98ac

File tree

9 files changed

+64
-27
lines changed

9 files changed

+64
-27
lines changed

app/backend/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,8 @@ async def setup_clients():
421421
# Shared by all OpenAI deployments
422422
OPENAI_HOST = os.getenv("OPENAI_HOST", "azure")
423423
OPENAI_CHATGPT_MODEL = os.environ["AZURE_OPENAI_CHATGPT_MODEL"]
424-
OPENAI_EMB_MODEL = os.getenv("AZURE_OPENAI_EMB_MODEL_NAME", "text-embedding-ada-002")
425-
OPENAI_EMB_DIMENSIONS = int(os.getenv("AZURE_OPENAI_EMB_DIMENSIONS") or 1536)
424+
OPENAI_EMB_MODEL = os.environ["AZURE_OPENAI_EMB_MODEL_NAME"]
425+
OPENAI_EMB_DIMENSIONS = int(os.environ["AZURE_OPENAI_EMB_DIMENSIONS"])
426426
# Used with Azure OpenAI deployments
427427
AZURE_OPENAI_SERVICE = os.getenv("AZURE_OPENAI_SERVICE")
428428
AZURE_OPENAI_GPT4V_DEPLOYMENT = os.environ.get("AZURE_OPENAI_GPT4V_DEPLOYMENT")

docs/deploy_existing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ You should set these values before running `azd up`. Once you've set them, retur
3131
1. Run `azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT_VERSION {Version string for existing chat deployment}`. Only needed if your chat deployment model version is not the default '0125'. You definitely need to change this if you changed the model.
3232
1. Run `azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT_SKU {Name of SKU for existing chat deployment}`. Only needed if your chat deployment SKU is not the default 'Standard', like if it is 'GlobalStandard' instead.
3333
1. Run `azd env set AZURE_OPENAI_EMB_DEPLOYMENT {Name of existing embedding deployment}`. Only needed if your embeddings deployment is not the default 'embedding'.
34-
1. Run `azd env set AZURE_OPENAI_EMB_MODEL_NAME {Model name of existing embedding deployment}`. Only needed if your embeddings model is not the default 'text-embedding-ada-002'.
35-
1. Run `azd env set AZURE_OPENAI_EMB_DIMENSIONS {Dimensions for existing embedding deployment}`. Only needed if your embeddings model is not the default 'text-embedding-ada-002'.
34+
1. Run `azd env set AZURE_OPENAI_EMB_MODEL_NAME {Model name of existing embedding deployment}`. Only needed if your embeddings model is not the default 'text-embedding-3-large'.
35+
1. Run `azd env set AZURE_OPENAI_EMB_DIMENSIONS {Dimensions for existing embedding deployment}`. Only needed if your embeddings model is not the default 'text-embedding-3-large'.
3636
1. Run `azd env set AZURE_OPENAI_EMB_DEPLOYMENT_VERSION {Version string for existing embedding deployment}`. If your embeddings deployment is one of the 'text-embedding-3' models, set this to the number 1.
3737
1. This project does *not* use keys when authenticating to Azure OpenAI. However, if your Azure OpenAI service must have key access enabled for some reason (like for use by other projects), then run `azd env set AZURE_OPENAI_DISABLE_KEYS false`. The default value is `true` so you should only run the command if you need key access.
3838

docs/deploy_features.md

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ This document covers optional features that can be enabled in the deployed Azure
55
You should typically enable these features before running `azd up`. Once you've set them, return to the [deployment steps](../README.md#deploying).
66

77
* [Using different chat completion models](#using-different-chat-completion-models)
8-
* [Using text-embedding-3 models](#using-text-embedding-3-models)
9-
* [Enabling GPT-4 Turbo with Vision](#enabling-gpt-4-turbo-with-vision)
8+
* [Using different embedding models](#using-different-embedding-models)
9+
* [Enabling GPT vision feature](#enabling-gpt-vision-feature)
1010
* [Enabling media description with Azure Content Understanding](#enabling-media-description-with-azure-content-understanding)
1111
* [Enabling client-side chat history](#enabling-client-side-chat-history)
1212
* [Enabling persistent chat history with Azure Cosmos DB](#enabling-persistent-chat-history-with-azure-cosmos-db)
@@ -121,12 +121,16 @@ This process does *not* delete your previous model deployment. If you want to de
121121
> [!NOTE]
122122
> To revert back to a previous model, run the same commands with the previous model name and version.
123123

124-
## Using text-embedding-3 models
124+
## Using different embedding models
125125

126-
By default, the deployed Azure web app uses the `text-embedding-ada-002` embedding model. If you want to use one of the text-embedding-3 models, you can do so by following these steps:
126+
By default, the deployed Azure web app uses the `text-embedding-3-large` embedding model. If you want to use a different embeddig model, you can do so by following these steps:
127127

128128
1. Run one of the following commands to set the desired model:
129129

130+
```shell
131+
azd env set AZURE_OPENAI_EMB_MODEL_NAME text-embedding-ada-002
132+
```
133+
130134
```shell
131135
azd env set AZURE_OPENAI_EMB_MODEL_NAME text-embedding-3-small
132136
```
@@ -137,32 +141,65 @@ By default, the deployed Azure web app uses the `text-embedding-ada-002` embeddi
137141

138142
2. Specify the desired dimensions of the model: (from 256-3072, model dependent)
139143

144+
Default dimensions for text-embedding-ada-002
145+
146+
```shell
147+
azd env set AZURE_OPENAI_EMB_DIMENSIONS 1536
148+
```
149+
150+
Default dimensions for text-embedding-3-small
151+
140152
```shell
141-
azd env set AZURE_OPENAI_EMB_DIMENSIONS 256
153+
azd env set AZURE_OPENAI_EMB_DIMENSIONS 1536
142154
```
143155

144-
3. Set the model version to "1" (the only version as of March 2024):
156+
Default dimensions for text-embedding-3-large
157+
158+
```shell
159+
azd env set AZURE_OPENAI_EMB_DIMENSIONS 3072
160+
```
161+
162+
3. Set the model version, depending on the model you are using:
163+
164+
For text-embedding-ada-002:
165+
166+
```shell
167+
azd env set AZURE_OPENAI_EMB_DEPLOYMENT_VERSION 2
168+
```
169+
170+
For text-embedding-3-small and text-embedding-3-large:
145171

146172
```shell
147173
azd env set AZURE_OPENAI_EMB_DEPLOYMENT_VERSION 1
148174
```
149175

150-
4. When prompted during `azd up`, make sure to select a region for the OpenAI resource group location that supports the text-embedding-3 models. There are [limited regions available](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#embeddings-models).
176+
4. To set the embedding model deployment SKU name, run this command with [the desired SKU name](https://learn.microsoft.com/azure/ai-services/openai/how-to/deployment-types#deployment-types).
177+
178+
For GlobalStandard:
179+
180+
```bash
181+
azd env set AZURE_OPENAI_EMB_DEPLOYMENT_SKU GlobalStandard
182+
```
183+
184+
For Standard:
185+
186+
```bash
187+
azd env set AZURE_OPENAI_EMB_DEPLOYMENT_SKU Standard
188+
```
189+
190+
5. When prompted during `azd up`, make sure to select a region for the OpenAI resource group location that supports the desired embedding model and deployment SKU. There are [limited regions available](https://learn.microsoft.com/azure/ai-services/openai/concepts/models?tabs=global-standard%2Cstandard-chat-completions#models-by-deployment-type).
151191

152192
If you have already deployed:
153193

154194
* You'll need to change the deployment name by running `azd env set AZURE_OPENAI_EMB_DEPLOYMENT <new-deployment-name>`
155195
* You'll need to create a new index, and re-index all of the data using the new model. You can either delete the current index in the Azure Portal, or create an index with a different name by running `azd env set AZURE_SEARCH_INDEX new-index-name`. When you next run `azd up`, the new index will be created and the data will be re-indexed.
156196
* If your OpenAI resource is not in one of the supported regions, you should delete `openAiResourceGroupLocation` from `.azure/YOUR-ENV-NAME/config.json`. When running `azd up`, you will be prompted to select a new region.
157197

158-
> ![NOTE]
159-
> The text-embedding-3 models are not currently supported by the integrated vectorization feature.
160-
161-
## Enabling GPT-4 Turbo with Vision
198+
## Enabling GPT vision feature
162199

163200
⚠️ This feature is not currently compatible with [integrated vectorization](#enabling-integrated-vectorization).
164201

165-
This section covers the integration of GPT-4 Vision with Azure AI Search. Learn how to enhance your search capabilities with the power of image and text indexing, enabling advanced search functionalities over diverse document types. For a detailed guide on setup and usage, visit our [Enabling GPT-4 Turbo with Vision](gpt4v.md) page.
202+
This section covers the integration of GPT vision models with Azure AI Search. Learn how to enhance your search capabilities with the power of image and text indexing, enabling advanced search functionalities over diverse document types. For a detailed guide on setup and usage, visit our page on [Using GPT vision model with RAG approach](gpt4v.md).
166203

167204
## Enabling media description with Azure Content Understanding
168205

docs/gpt4v.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ For more details on how this feature works, read [this blog post](https://techco
2121

2222
* Create a [AI Vision account in Azure Portal first](https://ms.portal.azure.com/#create/Microsoft.CognitiveServicesComputerVision), so that you can agree to the Responsible AI terms for that resource. You can delete that account after agreeing.
2323
* The ability to deploy a gpt-4o model in the [supported regions](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#standard-deployment-model-availability). If you're not sure, try to create a gpt-4o deployment from your Azure OpenAI deployments page.
24-
* Ensure that you can deploy the Azure OpenAI resource group in [a region where all required components are available](https://learn.microsoft.com/azure/cognitive-services/openai/concepts/models#model-summary-table-and-region-availability):
24+
* Ensure that you can deploy the Azure OpenAI resource group in [a region and deployment SKU where all required components are available](https://learn.microsoft.com/azure/cognitive-services/openai/concepts/models#model-summary-table-and-region-availability):
2525
* Azure OpenAI models
2626
* gpt-4o-mini
27-
* text-embedding-ada-002
27+
* text-embedding-3-large
2828
* gpt-4o (for vision/evaluation features)
2929
* [Azure AI Vision](https://learn.microsoft.com/azure/ai-services/computer-vision/)
3030

infra/main.bicep

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ param embeddingDeploymentSkuName string = ''
146146
param embeddingDeploymentCapacity int = 0
147147
param embeddingDimensions int = 0
148148
var embedding = {
149-
modelName: !empty(embeddingModelName) ? embeddingModelName : 'text-embedding-ada-002'
150-
deploymentName: !empty(embeddingDeploymentName) ? embeddingDeploymentName : 'embedding'
151-
deploymentVersion: !empty(embeddingDeploymentVersion) ? embeddingDeploymentVersion : '2'
152-
deploymentSkuName: !empty(embeddingDeploymentSkuName) ? embeddingDeploymentSkuName : 'Standard'
149+
modelName: !empty(embeddingModelName) ? embeddingModelName : 'text-embedding-3-large'
150+
deploymentName: !empty(embeddingDeploymentName) ? embeddingDeploymentName : 'text-embedding-3-large'
151+
deploymentVersion: !empty(embeddingDeploymentVersion) ? embeddingDeploymentVersion : '1'
152+
deploymentSkuName: !empty(embeddingDeploymentSkuName) ? embeddingDeploymentSkuName : 'GlobalStandard'
153153
deploymentCapacity: embeddingDeploymentCapacity != 0 ? embeddingDeploymentCapacity : 30
154-
dimensions: embeddingDimensions != 0 ? embeddingDimensions : 1536
154+
dimensions: embeddingDimensions != 0 ? embeddingDimensions : 3072
155155
}
156156

157157
param gpt4vModelName string = ''

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ async def mock_acreate(*args, **kwargs):
9595
object="embedding",
9696
)
9797
],
98-
model="text-embedding-ada-002",
98+
model="text-embedding-3-large",
9999
usage=Usage(prompt_tokens=8, total_tokens=8),
100100
)
101101

tests/test_prepdocs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ async def mock_create_client(*args, **kwargs):
5151
object="embedding",
5252
)
5353
],
54-
model="text-embedding-ada-002",
54+
model="text-embedding-3-large",
5555
usage=Usage(prompt_tokens=8, total_tokens=8),
5656
)
5757
)

tests/test_searchmanager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ async def mock_create_client(*args, **kwargs):
258258
object="embedding",
259259
)
260260
],
261-
model="text-embedding-ada-002",
261+
model="text-embedding-3-large",
262262
usage=Usage(prompt_tokens=8, total_tokens=8),
263263
)
264264
)

tests/test_upload.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ async def mock_create_client(self, *args, **kwargs):
7575
object="embedding",
7676
)
7777
],
78-
model="text-embedding-ada-002",
78+
model="text-embedding-3-large",
7979
usage=Usage(prompt_tokens=8, total_tokens=8),
8080
)
8181
)

0 commit comments

Comments
 (0)