Skip to content

Upgrade to text-embedding-3-large model as default, with vector storage optimizations #2470

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

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

pamelafox
Copy link
Collaborator

@pamelafox pamelafox commented Apr 1, 2025

Purpose

This pull request changes the default embedding model to text-embedding-3-large, with 3072 dimensions, along with these AI Search vector storage optimizations:

  • Truncate dimensions to 1024
  • Binary quantization
  • Preserve originals in the search index for rescoring
  • Don't store the vectors in the search index itself

See this notebook for a demonstration of the effects of those optimizations. Due to the rescoring, the search quality remains high.

This PR introduces a new environment variable AZURE_SEARCH_FIELD_NAME_EMBEDDING so that developers can theoretically have multiple fields in their index, for different embedding sizes/models.

This PR also changes the SKU for all models to GlobalStandard. It's becoming really tricky to find a region for the Standard SKU that works for all the models. Some developers may not be comfortable with GlobalStandard, depending on their regulations, so they can still change the SKU manually as desired.

Fixes #2383

Does this introduce a breaking change?

When developers merge from main and run the server, azd up, or azd deploy, will this produce an error?
If you're not sure, try it out on an old environment.

[X] Yes - I am trying to make it backwards compatible, but it's hard! I suspect that developers that recently deployed gpt-4o-mini with Standard sku will get an error, and need to run `azd env set` to change the deployment name or sku name.
[ ] No

Does this require changes to learn.microsoft.com docs?

This repository is referenced by this tutorial
which includes deployment, settings and usage instructions. If text or screenshot need to change in the tutorial,
check the box below and notify the tutorial author. A Microsoft employee can do this for you if you're an external contributor.

[ ] Yes
[X] No

Type of change

[ ] Bugfix
[X] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:

Code quality checklist

See CONTRIBUTING.md for more details.

  • The current tests all pass (python -m pytest).
  • I added tests that prove my fix is effective or that my feature works
  • I ran python -m pytest --cov to verify 100% coverage of added lines
  • I ran python -m mypy to check for type errors
  • I either used the pre-commit hooks or ran ruff and black manually on my code.

Copy link

github-actions bot commented Apr 2, 2025

Check Country Locale in URLs

We have automatically detected added country locale to URLs in your files.
Review and remove country-specific locale from URLs to resolve this issue.

Check the file paths and associated URLs inside them.
For more details, check our Contributing Guide.

File Full Path Issues
docs/deploy_features.md
#LinkLine Number
1https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models?tabs=global-standard%2Cstandard-chat-completions#models-by-deployment-type197

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR upgrades the default embedding model to "text-embedding-3-large" (3072 dimensions) and implements several vector storage optimizations including truncation, binary quantization, and preserving original values for rescoring. It also introduces new environment variables for embedding field names and updates documentation and related code to support the new configuration.

  • Updated tests and environment variables for the new embedding model and dimensions.
  • Revised documentation to reflect model and deployment changes.
  • Refactored search management and approach modules to use dynamic embedding field names.

Reviewed Changes

Copilot reviewed 24 out of 27 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/conftest.py Updated mocked model and dimensions for the new embedding model.
docs/gpt4v.md Changed embedding model reference from ada to text-embedding-3-large.
docs/deploy_features.md Updated deployment instructions and embedding model references.
docs/deploy_existing.md Adjusted instructions for existing deployments to use the new model.
azure.yaml Added new environment variables for embedding field names.
app/backend/prepdocslib/searchmanager.py Refactored index creation to use dynamic embedding field names and profiles.
app/backend/integratedvectorizerstrategy.py Passed new search field names into indexer skill configuration.
app/backend/prepdocs.py Updated embedding field configuration from environment variables.
app/backend/approaches/* Modified constructors and vector field usages to accept new embedding field.
app/backend/app.py Integrated new environment variables for embedding field names in client setup.
.github/workflows/azure-dev.yml & .azdo/pipelines/azure-dev.yml Included new environment variable exports for embedding field names.
Files not reviewed (3)
  • app/backend/requirements.txt: Language not supported
  • infra/main.bicep: Language not supported
  • infra/main.parameters.json: Language not supported

@pamelafox pamelafox marked this pull request as ready for review April 3, 2025 00:09
@@ -60,6 +60,8 @@ steps:
AZURE_SEARCH_QUERY_SPELLER: $(AZURE_SEARCH_QUERY_SPELLER)
AZURE_SEARCH_SEMANTIC_RANKER: $(AZURE_SEARCH_SEMANTIC_RANKER)
AZURE_SEARCH_QUERY_REWRITING: $(AZURE_SEARCH_QUERY_REWRITING)
AZURE_SEARCH_FIELD_NAME_EMBEDDING: $(AZURE_SEARCH_FIELD_NAME_EMBEDDING)
AZURE_SEARCH_FIELD_NAME_IMAGE_EMBEDDING: $(AZURE_SEARCH_FIELD_NAME_IMAGE_EMBEDDING)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deal with image embedding in a future pr

InputFieldMappingEntry(name="sourcepage", source="/document/metadata_storage_name"),
InputFieldMappingEntry(name="sourcefile", source="/document/metadata_storage_name"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

help e2e test

Copy link

github-actions bot commented May 3, 2025

Check Broken URLs

We have automatically detected the following broken URLs in your files. Review and fix the paths to resolve this issue.

Check the file paths and associated broken URLs inside them.
For more details, check our Contributing Guide.

File Full Path Issues
docs/deploy_troubleshooting.md
#LinkLine Number
1https://stackoverflow.com/questions/35569042/ssl-certificate-verify-failed-with-python3/43855394#4385539411
docs/customization.md
#LinkLine Number
1https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/chat_query_rewrite.prompty41
2https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/chat_answer_question.prompty43
3https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/chat_query_rewrite.prompty45
4https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/chat_answer_question.prompty45
5https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/chat_answer_question_vision.prompty55
6https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/retrievethenread.py59
7https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/ask_answer_question.prompty62
8https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/ask_answer_question.prompty64
9https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/ask_answer_question_vision.prompty73
10https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/prepdocslib/searchmanager.py173
11https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/prepdocslib/searchmanager.py174
12https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/prepdocslib/textsplitter.py176

Copy link

github-actions bot commented May 5, 2025

Check Broken URLs

We have automatically detected the following broken URLs in your files. Review and fix the paths to resolve this issue.

Check the file paths and associated broken URLs inside them.
For more details, check our Contributing Guide.

File Full Path Issues
docs/deploy_troubleshooting.md
#LinkLine Number
1https://stackoverflow.com/questions/35569042/ssl-certificate-verify-failed-with-python3/43855394#4385539411
docs/customization.md
#LinkLine Number
1https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/chat_query_rewrite.prompty41
2https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/chat_answer_question.prompty43
3https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/chat_query_rewrite.prompty45
4https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/chat_answer_question.prompty45
5https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/chat_answer_question_vision.prompty55
6https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/retrievethenread.py59
7https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/ask_answer_question.prompty62
8https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/ask_answer_question.prompty64
9https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/ask_answer_question_vision.prompty73
10https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/prepdocslib/searchmanager.py173
11https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/prepdocslib/searchmanager.py174
12https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/prepdocslib/textsplitter.py176

Copy link

github-actions bot commented May 5, 2025

Check Broken URLs

We have automatically detected the following broken URLs in your files. Review and fix the paths to resolve this issue.

Check the file paths and associated broken URLs inside them.
For more details, check our Contributing Guide.

File Full Path Issues
data/Contoso_Electronics_Company_Overview.md
#LinkLine Number
1http://www.contoso.com48
docs/deploy_troubleshooting.md
#LinkLine Number
1https://stackoverflow.com/questions/35569042/ssl-certificate-verify-failed-with-python3/43855394#4385539411
docs/customization.md
#LinkLine Number
1https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/chatreadretrieveread.py39
2https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/chat_query_rewrite.prompty41
3https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/chat_answer_question.prompty43
4https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/chat_query_rewrite.prompty45
5https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/chat_answer_question.prompty45
6https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/chat_answer_question_vision.prompty55
7https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/retrievethenread.py59
8https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/ask_answer_question.prompty62
9https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/ask_answer_question.prompty64
10https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/ask_answer_question_vision.prompty73
11https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/prepdocslib/searchmanager.py173
12https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/prepdocslib/searchmanager.py174
13https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/prepdocslib/textsplitter.py176

Copy link

github-actions bot commented May 5, 2025

Check Broken URLs

We have automatically detected the following broken URLs in your files. Review and fix the paths to resolve this issue.

Check the file paths and associated broken URLs inside them.
For more details, check our Contributing Guide.

File Full Path Issues
README.md
#LinkLine Number
1https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#role-based-access-control-administrator-preview79
2https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#user-access-administrator79
3https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#owner79
4https://learn.microsoft.com/azure/role-based-access-control/built-in-roles#role-based-access-control-administrator-preview79
5https://learn.microsoft.com/azure/cognitive-services/openai/concepts/models#model-summary-table-and-region-availability178
6https://learn.microsoft.com/azure/developer/python/get-started-app-chat-template?toc=%2Fazure%2Fdeveloper%2Fai%2Ftoc.json&bc=%2Fazure%2Fdeveloper%2Fai%2Fbreadcrumb%2Ftoc.json&tabs=github-codespaces273
7https://learn.microsoft.com/azure/search/search-what-is-azure-search275
8https://learn.microsoft.com/azure/cognitive-services/openai/overview276
docs/customization.md
#LinkLine Number
1https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/chat_answer_question.prompty43
2https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/chat_answer_question.prompty45
3https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/chat_answer_question_vision.prompty55
4https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/retrievethenread.py59
5https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/ask_answer_question.prompty62
6https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/ask_answer_question.prompty64
7https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/approaches/prompts/ask_answer_question_vision.prompty73
8https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/prepdocslib/searchmanager.py173
9https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/prepdocslib/searchmanager.py174
10https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/app/backend/prepdocslib/textsplitter.py176

@pamelafox pamelafox requested review from mattgotteiner and Copilot May 6, 2025 06:08
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request upgrades the default embedding model to text-embedding-3-large with 3072 dimensions and applies vector storage optimizations. Key changes include:

  • Adding a new environment variable AZURE_SEARCH_FIELD_NAME_EMBEDDING in configuration files.
  • Renaming and updating vector field type usage on both frontend and backend to use the new VectorFields enum.
  • Propagating changes in embedding-related logic (e.g. API version updates, search index field naming) in backend modules.

Reviewed Changes

Copilot reviewed 104 out of 105 changed files in this pull request and generated no comments.

Show a summary per file
File Description
azure.yaml Added AZURE_SEARCH_FIELD_NAME_EMBEDDING to the pipeline environment variables.
app/frontend/src/pages/chat/Chat.tsx Renamed vector field state from VectorFieldOptions to VectorFields and updated related references.
app/frontend/src/pages/ask/Ask.tsx Updated import and state management of vector fields.
app/frontend/src/components/VectorSettings/VectorSettings.tsx Refactored vector field dropdown logic and state handling with the new VectorFields enum.
app/frontend/src/components/Settings/Settings.tsx Adjusted prop names to match updated vector fields terminology.
app/frontend/src/api/models.ts Replaced the VectorFieldOptions enum with the new VectorFields enum and updated its key names.
app/backend/* (various files) Updated backend logic to require and propagate the new embedding field name, updated API versions, etc.
.github/workflows/azure-dev.yml & .azdo/pipelines/azure-dev.yml Included AZURE_SEARCH_FIELD_NAME_EMBEDDING in the environment variable configuration.
Files not reviewed (1)
  • app/backend/requirements.txt: Language not supported
Comments suppressed due to low confidence (2)

app/frontend/src/pages/chat/Chat.tsx:59

  • The new variable name 'vectorFields' is more descriptive than the previous name. Please ensure that all component references and related handlers have been updated consistently.
const [vectorFields, setVectorFields] = useState<VectorFields>(VectorFields.TextAndImageEmbeddings);

app/frontend/src/api/models.ts:13

  • The updated enum 'VectorFields' with keys 'textEmbeddingOnly', 'imageEmbeddingOnly', and 'textAndImageEmbeddings' should be reviewed for consistent usage across the codebase.
export const enum VectorFields {

@pamelafox
Copy link
Collaborator Author

@mattgotteiner I made changes to how vector fields are handed for gpt-vision as it was previously using the vector field names in the settings, and also, I think it was actually buggy the way it was implemented. Now it's done very similar to retrieval mode, with either text, image, or both, as the options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue with Integrated vectorization enabled
2 participants