generated from amazon-archives/__template_Custom
-
Notifications
You must be signed in to change notification settings - Fork 186
add Yandex Cloud embeddings connector blueprint #4469
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
mkhludnev
wants to merge
3
commits into
opensearch-project:main
Choose a base branch
from
mkhludnev:yc-conn-blueprint
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
149 changes: 149 additions & 0 deletions
149
...rints/standard_blueprints/yandexcloud_connector_embedding_standard_blueprint.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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| # Yandex Cloud AI Studio connector standard blueprint example for embedding models | ||
|
|
||
| This blueprint demonstrates how to deploy a Yandex Cloud AI Studio embedding models. | ||
|
|
||
| ## 1. Allow connection to Yandex Cloud | ||
|
|
||
| ```json | ||
| PUT /_cluster/settings | ||
| { | ||
| "persistent": { | ||
| "plugins.ml_commons.trusted_connector_endpoints_regex": [ | ||
| "^https://llm\\.api\\.cloud\\.yandex\\.net/.*$" | ||
| ] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## 2. Create connector for Yandex Cloud Embeddings: | ||
|
|
||
|
|
||
| ```json | ||
| POST /_plugins/_ml/connectors/_create | ||
| { | ||
| "name": "YC Connector: embedding", | ||
| "description": "Yandex Cloud AI Studio Embeddings", | ||
| "version": "1", | ||
| "protocol": "http", | ||
| "parameters": { | ||
| "modelUri": "emb://<folder_ID>/text-search-<doc|query>/latest", | ||
| "folder_id":"<folder_ID>" | ||
| }, | ||
| "credential": { | ||
| "api_key": "<API-KEY>" | ||
| }, | ||
| "actions": [ | ||
| { | ||
| "action_type": "predict", | ||
| "method": "POST", | ||
| "url": "https://llm.api.cloud.yandex.net/foundationModels/v1/textEmbedding", | ||
| "headers": { | ||
| "Authorization": "Api-Key ${credential.api_key}", | ||
| "x-folder-id": "${parameters.folder_id}" | ||
| }, | ||
| "request_body": "{ \"text\": \"${parameters.inputText}\", \"modelUri\": \"${parameters.modelUri}\" }", | ||
| "pre_process_function": "connector.pre_process.bedrock.embedding", | ||
| "post_process_function": "connector.post_process.bedrock.embedding" | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
|
|
||
| Note: Replace all `<placeholders>` in the preceding code snippet with appropriate values, while preserving `${curly braces}` syntax exactly as shown. Short-lived [bearer tokens](https://yandex.cloud/en/docs/iam/concepts/authorization/iam-token) (valid ~12 hours) may be used as an alternative to [API keys](https://yandex.cloud/en/docs/iam/concepts/authorization/api-key). API keys must be granted either `yc.ai.languageModels.execute` or `yc.ai.foundationModels.execute` roles. Also refer to [the guide](https://yandex.cloud/en/docs/ai-studio/security/). Additionally, due to distinct [models](https://yandex.cloud/en/docs/ai-studio/concepts/embeddings) being employed for query processing versus document processing, two dedicated connectors are required. Using these particular pre/post processing functions is crucial. | ||
|
|
||
| Sample response: | ||
| ```json | ||
| { | ||
| "connector_id": "CTEou5oBdUNOOrVArUAU" | ||
| } | ||
| ``` | ||
|
|
||
| ## 3. Register model & deploy model: | ||
|
|
||
| ```json | ||
| POST /_plugins/_ml/model_groups/_register | ||
| { | ||
| "name": "yc_remote_model_group", | ||
| "description": "A model group for external YC AI Studio models" | ||
| } | ||
| ``` | ||
|
|
||
| Sample response: | ||
| ```json | ||
| { | ||
| "model_group_id": "4THNtZoBdUNOOrVAzj_V" | ||
| } | ||
| ``` | ||
|
|
||
| ```json | ||
| POST /_plugins/_ml/models/_register | ||
| { | ||
| "name": "yc-embedding", | ||
| "function_name": "remote", | ||
| "model_group_id": "4THNtZoBdUNOOrVAzj_V", | ||
| "description": "YC embedding model", | ||
| "connector_id": "CTEou5oBdUNOOrVArUAU" | ||
| } | ||
| ``` | ||
|
|
||
|
|
||
| ```json | ||
| POST /_plugins/_ml/models/_register | ||
| { | ||
| "name": "Bedrock text embedding model", | ||
| "function_name": "remote", | ||
| "description": "test model", | ||
| "connector_id": "nzh9PIsBnGXNcxYpPEcv" | ||
| } | ||
| ``` | ||
|
|
||
| Sample response: | ||
| ```json | ||
| { | ||
| "task_id": "5THZtZoBdUNOOrVAEj_I", | ||
| "status": "CREATED", | ||
| "model_id": "CzEou5oBdUNOOrVA10Db" | ||
| } | ||
| ``` | ||
|
|
||
| ## 4. Test model inference | ||
|
|
||
| ```json | ||
| POST /_plugins/_ml/models/CzEou5oBdUNOOrVA10Db/_predict | ||
| { | ||
| "parameters": { | ||
| "inputText": "What is the meaning of life?" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Sample response of Yadex Cloud AI Studio Embedding: | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```json | ||
| { | ||
| "inference_results": [ | ||
| { | ||
| "output": [ | ||
| { | ||
| "name": "sentence_embedding", | ||
| "data_type": "FLOAT32", | ||
| "shape": [ | ||
| 256 | ||
| ], | ||
| "data": [ | ||
| 0.06268310546875, | ||
| -0.04071044921875, | ||
| 0.047119140625, | ||
| -0.007476806640625, | ||
| -0.038543701171875, | ||
| -0.003681182861328125, | ||
| ... | ||
| 0.040679931640625 | ||
| ] | ||
| } | ||
| ], | ||
| "status_code": 200 | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
Oops, something went wrong.
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.