์์ ๊ธฐ๋ฐ ์ค๋ช
์ ์ฌ์ฉํ๋ ค๋ฉด Model
๋ฆฌ์์ค๋ฅผ Model Registry์ ๊ฐ์ ธ์ฌ ๋ explanationSpec
์ ์ง์ ํ์ฌ ์ค๋ช
์ ๊ตฌ์ฑํด์ผ ํฉ๋๋ค.
๊ทธ๋ฌ๋ฉด ์จ๋ผ์ธ ์ค๋ช
์ ์์ฒญํ ๋ ์์ฒญ์ ExplanationSpecOverride
๋ฅผ ์ง์ ํ์ฌ ๊ตฌ์ฑ๊ฐ์ ์ผ๋ถ๋ฅผ ์ฌ์ ์ํ ์ ์์ต๋๋ค. ์ผ๊ด ์ค๋ช
์ ์ง์๋์ง ์์ผ๋ฏ๋ก ์์ฒญํ ์ ์์ต๋๋ค.
์ด ํ์ด์ง์์๋ ์ด๋ฌํ ์ต์ ์ ๊ตฌ์ฑํ๊ณ ์ ๋ฐ์ดํธํ๋ ๋ฐฉ๋ฒ์ ์ค๋ช ํฉ๋๋ค.
๋ชจ๋ธ์ ๊ฐ์ ธ์ค๊ฑฐ๋ ์ ๋ก๋ํ ๋ ์ค๋ช ๊ตฌ์ฑ
์์ํ๊ธฐ ์ ์ ๋ค์ ์ฌํญ์ ํ์ธํ์ธ์.
๋ชจ๋ธ ์ํฐํฉํธ๊ฐ ํฌํจ๋ Cloud Storage ์์น๊ฐ ์์ด์ผ ํฉ๋๋ค. ๋ชจ๋ธ์ ๋ ์ด์ด ์ด๋ฆ์ ์ ๊ณตํ๊ฑฐ๋ ์ถ๋ ฅ์ ์ ์ฌ ๊ณต๊ฐ์ผ๋ก ์ฌ์ฉํ ์ ์๋ ์๋ช ์ ์ ๊ณตํ๋ ์ฌ์ธต์ ๊ฒฝ๋ง(DNN)์ด์ด์ผ ํฉ๋๋ค. ๋๋ ์๋ฒ ๋ฉ(์ ์ฌ ๊ณต๊ฐ ํํ)์ ์ง์ ์ถ๋ ฅํ๋ ๋ชจ๋ธ์ ์ ๊ณตํด๋ ๋ฉ๋๋ค. ์ด ์ ์ฌ ๊ณต๊ฐ์ ์ค๋ช ์ ์์ฑํ๋ ๋ฐ ์ฌ์ฉ๋๋ ์์ ํํ์ ์บก์ฒํฉ๋๋ค.
์ต๊ทผ์ ์ด์ ๊ฒ์์ ์ํด ์์ธ์ ์์ฑํ ์ธ์คํด์ค๊ฐ ํฌํจ๋ Cloud Storage ์์น๊ฐ ์์ด์ผ ํฉ๋๋ค. ์์ธํ ๋ด์ฉ์ ์ ๋ ฅ ๋ฐ์ดํฐ ์๊ตฌ์ฌํญ์ ์ฐธ์กฐํ์ธ์.
์ฝ์
Google Cloud ์ฝ์์ ์ฌ์ฉํ์ฌ ๋ชจ๋ธ ๊ฐ์ ธ์ค๊ธฐ ๊ฐ์ด๋๋ฅผ ๋ฐ๋ฅด์ธ์.
์ค๋ช ๊ธฐ๋ฅ ํญ์์ ์์ ๊ธฐ๋ฐ ์ค๋ช ์ ์ ํํ๊ณ ๋ด์ฉ์ ์ ๋ ฅํฉ๋๋ค.
๊ฐ ํ๋์ ๋ํ ์์ธํ ๋ด์ฉ์ Google Cloud ์ฝ์(์๋ ์ฐธ์กฐ)์ ํ๊ณผ Example
๋ฐ ExplanationMetadata
์ ์ฐธ๊ณ ๋ฌธ์๋ฅผ ํ์ธํ์ธ์.
gcloud CLI
- ๋ค์
ExplanationMetadata
๋ฅผ ๋ก์ปฌ ํ๊ฒฝ์ JSON ํ์ผ์ ์์ฑํฉ๋๋ค. ํ์ผ ์ด๋ฆ์ ์ค์ํ์ง ์์ง๋ง ์ด ์์์์๋ ํ์ผ ์ด๋ฆ์explanation-metadata.json
์ผ๋ก ์ง์ ํฉ๋๋ค.
{
"inputs": {
"my_input": {
"inputTensorName": "INPUT_TENSOR_NAME",
"encoding": "IDENTITY",
},
"id": {
"inputTensorName": "id",
"encoding": "IDENTITY"
}
},
"outputs": {
"embedding": {
"outputTensorName": "OUTPUT_TENSOR_NAME"
}
}
}
- (์ ํ์ฌํญ) ์ ์ฒด
NearestNeighborSearchConfig
๋ฅผ ์ง์ ํ๋ ๊ฒฝ์ฐ, ๋ก์ปฌ ํ๊ฒฝ์ JSON ํ์ผ์ ๋ค์์ ์๋๋ค. ํ์ผ ์ด๋ฆ์ ์ค์ํ์ง ์์ง๋ง ์ด ์์์์๋ ํ์ผ ์ด๋ฆ์search_config.json
์ผ๋ก ์ง์ ํฉ๋๋ค.
{
"contentsDeltaUri": "",
"config": {
"dimensions": 50,
"approximateNeighborsCount": 10,
"distanceMeasureType": "SQUARED_L2_DISTANCE",
"featureNormType": "NONE",
"algorithmConfig": {
"treeAhConfig": {
"leafNodeEmbeddingCount": 1000,
"fractionLeafNodesToSearch": 1.0
}
}
}
}
- ๋ค์ ๋ช
๋ น์ด๋ฅผ ์คํํ์ฌ
Model
์ ์ ๋ก๋ํฉ๋๋ค.
Preset
๊ฒ์ ๊ตฌ์ฑ์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ --explanation-nearest-neighbor-search-config-file
ํ๋๊ทธ๋ฅผ ์ญ์ ํ์ธ์. NearestNeighborSearchConfig
๋ฅผ ์ง์ ํ๋ ๊ฒฝ์ฐ --explanation-modality
๋ฐ --explanation-query
ํ๋๊ทธ๋ฅผ ์ญ์ ํฉ๋๋ค.
์์ ๊ธฐ๋ฐ ์ค๋ช ๊ณผ ๊ฐ์ฅ ๊ด๋ จ์ฑ์ด ๋์ ํ๋๊ทธ๋ ๊ตต๊ฒ ํ์๋ฉ๋๋ค.
gcloud ai models upload \
--region=LOCATION \
--display-name=MODEL_NAME \
--container-image-uri=IMAGE_URI \
--artifact-uri=MODEL_ARTIFACT_URI \
--explanation-method=examples \
--uris=[URI, ...] \
--explanation-neighbor-count=NEIGHBOR_COUNT \
--explanation-metadata-file=explanation-metadata.json \
--explanation-modality=IMAGE|TEXT|TABULAR \
--explanation-query=PRECISE|FAST \
--explanation-nearest-neighbor-search-config-file=search_config.json
์์ธํ ๋ด์ฉ์ gcloud ai ๋ชจ๋ธ ์ ๋ก๋๋ฅผ ์ฐธ์กฐํ์ธ์.
-
์
๋ก๋ ์์
์์ ์์
์ด ์๋ฃ๋์๋์ง ํ์ธํ๋ ๋ฐ ์ฌ์ฉํ ์ ์๋
OPERATION_ID
๋ฅผ ๋ฐํํฉ๋๋ค. ์๋ต์"done": true
๊ฐ ํฌํจ๋ ๋๊น์ง ์์ ์ํ๋ฅผ ํด๋งํ ์ ์์ต๋๋ค. gcloud ai operations describe ๋ช ๋ น์ด๋ฅผ ์ฌ์ฉํ์ฌ ์ํ๋ฅผ ํด๋งํฉ๋๋ค. ์๋ฅผ ๋ค๋ฉด ๋ค์๊ณผ ๊ฐ์ต๋๋ค.gcloud ai operations describe <operation-id>
์์ ์ด ์๋ฃ๋ ๋๊น์ง ์ค๋ช ์ ์์ฒญํ ์ ์์ต๋๋ค. ๋ฐ์ดํฐ ์ธํธ ๋ฐ ๋ชจ๋ธ ์ํคํ ์ฒ์ ํฌ๊ธฐ์ ๋ฐ๋ผ ์ด ๋จ๊ณ๋ ์์์ ์ฟผ๋ฆฌ์ ์ฌ์ฉ๋๋ ์์ธ์ ๋น๋ํ๋ ๋ฐ ๋ช ์๊ฐ์ด ๊ฑธ๋ฆด ์ ์์ต๋๋ค.
REST
์์ฒญ ๋ฐ์ดํฐ๋ฅผ ์ฌ์ฉํ๊ธฐ ์ ์ ๋ค์์ ๋ฐ๊ฟ๋๋ค.
- PROJECT
- LOCATION
๋ค๋ฅธ ์๋ฆฌํ์์์ ๋ํด ์์๋ณด๋ ค๋ฉด Model
, explanationSpec
, Examples
์ ์ฐธ์กฐํ์ธ์ใ
.
๋ชจ๋ธ ์
๋ก๋์ ๋ํ ์์ธ ์ค๋ช
์ upload
๋ฉ์๋์ ๋ชจ๋ธ ๊ฐ์ ธ์ค๊ธฐ๋ฅผ ์ฐธ์กฐํ์ธ์.
์๋ JSON ์์ฒญ ๋ณธ๋ฌธ์ Preset
๊ฒ์ ๊ตฌ์ฑ์ ์ง์ ํฉ๋๋ค. ๋๋ ์ ์ฒด NearestNeighborSearchConfig
๋ฅผ ์ง์ ํด๋ ๋ฉ๋๋ค.
HTTP ๋ฉ์๋ ๋ฐ URL:
POST https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT/locations/LOCATION/models:upload
JSON ์์ฒญ ๋ณธ๋ฌธ:
{ "model": { "displayName": "my-model", "artifactUri": "gs://your-model-artifact-folder", "containerSpec": { "imageUri": "us-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-11:latest", }, "explanationSpec": { "parameters": { "examples": { "gcsSource": { "uris": ["gs://your-examples-folder"] }, "neighborCount": 10, "presets": { "modality": "image" } } }, "metadata": { "outputs": { "embedding": { "output_tensor_name": "embedding" } }, "inputs": { "my_fancy_input": { "input_tensor_name": "input_tensor_name", "encoding": "identity", "modality": "image" }, "id": { "input_tensor_name": "id", "encoding": "identity" } } } } } }
์์ฒญ์ ๋ณด๋ด๋ ค๋ฉด ๋ค์ ์ต์ ์ค ํ๋๋ฅผ ํผ์นฉ๋๋ค.
๋ค์๊ณผ ๋น์ทํ JSON ์๋ต์ด ํ์๋ฉ๋๋ค.
{ "name": "projects/PROJECT_NUMBER/locations/LOCATION/models/MODEL_ID/operations/OPERATION_ID", "metadata": { "@type": "type.googleapis.com/google.cloud.aiplatform.v1.UploadModelOperationMetadata", "genericMetadata": { "createTime": "2022-01-08T01:21:10.147035Z", "updateTime": "2022-01-08T01:21:10.147035Z" } } }
์
๋ก๋ ์์
์์ ์์
์ด ์๋ฃ๋์๋์ง ํ์ธํ๋ ๋ฐ ์ฌ์ฉํ ์ ์๋ OPERATION_ID
๋ฅผ ๋ฐํํฉ๋๋ค. ์๋ต์ "done": true
๊ฐ ํฌํจ๋ ๋๊น์ง ์์
์ํ๋ฅผ ํด๋งํ ์ ์์ต๋๋ค. gcloud ai operations describe ๋ช
๋ น์ด๋ฅผ ์ฌ์ฉํ์ฌ ์ํ๋ฅผ ํด๋งํฉ๋๋ค. ์๋ฅผ ๋ค๋ฉด ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
gcloud ai operations describe <operation-id>
์์ ์ด ์๋ฃ๋ ๋๊น์ง ์ค๋ช ์ ์์ฒญํ ์ ์์ต๋๋ค. ๋ฐ์ดํฐ ์ธํธ ๋ฐ ๋ชจ๋ธ ์ํคํ ์ฒ์ ํฌ๊ธฐ์ ๋ฐ๋ผ ์ด ๋จ๊ณ๋ ์์์ ์ฟผ๋ฆฌ์ ์ฌ์ฉ๋๋ ์์ธ์ ๋น๋ํ๋ ๋ฐ ๋ช ์๊ฐ์ด ๊ฑธ๋ฆด ์ ์์ต๋๋ค.
Python
์ด๋ฏธ์ง ๋ถ๋ฅ ์์ ๊ธฐ๋ฐ ์ค๋ช ๋ ธํธ๋ถ์์ ๋ชจ๋ธ ์ ๋ก๋ ์น์ ์ ์ฐธ๊ณ ํ์ธ์.
NearestNeighborSearchConfig
๋ค์ JSON ์์ฒญ ๋ณธ๋ฌธ์์๋ upload
์์ฒญ์์ ์ฌ์ ์ค์ ๋์ ์ ์ฒด NearestNeighborSearchConfig
๋ฅผ ์ง์ ํ๋ ๋ฐฉ๋ฒ์ ๋ณด์ฌ์ค๋๋ค.
{
"model": {
"displayName": displayname,
"artifactUri": model_path_to_deploy,
"containerSpec": {
"imageUri": DEPLOY_IMAGE,
},
"explanationSpec": {
"parameters": {
"examples": {
"gcsSource": {
"uris": [DATASET_PATH]
},
"neighborCount": 5,
"nearest_neighbor_search_config": {
"contentsDeltaUri": "",
"config": {
"dimensions": dimensions,
"approximateNeighborsCount": 10,
"distanceMeasureType": "SQUARED_L2_DISTANCE",
"featureNormType": "NONE",
"algorithmConfig": {
"treeAhConfig": {
"leafNodeEmbeddingCount": 1000,
"fractionLeafNodesToSearch": 1.0
}
}
}
}
}
},
"metadata": { ... }
}
}
}
์๋ ํ์๋ NearestNeighborSearchConfig
์ ํ๋๊ฐ ๋์ด๋์ด ์์ต๋๋ค.
ํ๋ | |
---|---|
dimensions |
ํ์ ํญ๋ชฉ์ ๋๋ค. ์ ๋ ฅ ๋ฒกํฐ์ ์ฐจ์ ์์ ๋๋ค. ๋ฐ์ง ์๋ฒ ๋ฉ์๋ง ์ฌ์ฉ๋ฉ๋๋ค. |
approximateNeighborsCount |
tree-AH ์๊ณ ๋ฆฌ์ฆ์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ํ์์ ๋๋ค. ์ ํํ ์์ ๋ณ๊ฒฝ์ด ์ํ๋๊ธฐ ์ ์ ์ ์ฌ ๊ฒ์์ ํตํด ์ฐพ์ ์ด์์ ๊ธฐ๋ณธ ๊ฐ์์ ๋๋ค. ์ ํํ ์์ ๋ณ๊ฒฝ์ ์ ์ฌ ๊ฒ์ ์๊ณ ๋ฆฌ์ฆ์์ ๋ฐํํ๋ ๊ฒฐ๊ณผ๊ฐ ๋น์ฉ์ด ๋ ๋ง์ด ๋๋ ๊ฑฐ๋ฆฌ ๊ณ์ฐ์ ์ด์ฉํด ์ฌ์ ๋ ฌ๋๋ ์ ์ฐจ์ ๋๋ค. |
ShardSize |
ShardSize
๊ฐ ์ค๋์ ํฌ๊ธฐ. ์์ธ์ด ํฌ๋ฉด ์ง์ ๋ ์ค๋ ํฌ๊ธฐ๋ฅผ ๊ธฐ์ค์ผ๋ก ์ค๋ฉ๋ฉ๋๋ค. ์๋น ์ค์ ๊ฐ ์ค๋๋ ๋ณ๋์ ๋ ธ๋์์ ์ ๊ณต๋๋ฉฐ ๋ ๋ฆฝ์ ์ผ๋ก ํ์ฅ๋ฉ๋๋ค. |
distanceMeasureType |
์ต๊ทผ์ ์ด์ ๊ฒ์์ ์ฌ์ฉ๋๋ ๊ฑฐ๋ฆฌ ์ธก์ ์ ๋๋ค. |
featureNormType |
๊ฐ ๋ฒกํฐ์์ ์ํ๋ ์ ๊ทํ ์ ํ์ ๋๋ค. |
algorithmConfig |
oneOf:
๋ฒกํฐ ๊ฒ์์์ ํจ์จ์ ์ธ ๊ฒ์์ ์ฌ์ฉํ๋ ์๊ณ ๋ฆฌ์ฆ์ ๊ตฌ์ฑ์ ๋๋ค. ๋ฐ์ง ์๋ฒ ๋ฉ์๋ง ์ฌ์ฉ๋ฉ๋๋ค.
|
DistanceMeasureType
์ด๊ฑฐํ | |
---|---|
SQUARED_L2_DISTANCE |
์ ํด๋ฆฌ๋(L2) ๊ฑฐ๋ฆฌ |
L1_DISTANCE |
๋งจํดํผ(L1) ๊ฑฐ๋ฆฌ |
DOT_PRODUCT_DISTANCE |
๊ธฐ๋ณธ๊ฐ ์ค์นผ๋ผ๊ณฑ์ ์์๋ก ์ ์๋ฉ๋๋ค. |
COSINE_DISTANCE |
์ฝ์ฌ์ธ ๊ฑฐ๋ฆฌ์ ๋๋ค. ์ฝ์ฌ์ธ ๊ฑฐ๋ฆฌ ๋์ DOT_PRODUCT_Distance + UNIT_L2_NORM์ ์ฌ์ฉํ๋ ๊ฒ์ด ์ข์ต๋๋ค. Google์ ์๊ณ ๋ฆฌ์ฆ์ DOT_PRODUCT ๊ฑฐ๋ฆฌ๋ฅผ ๊ธฐ์ค์ผ๋ก ์ต์ ํ๋์์ผ๋ฉฐ, UNIT_L2_NORM๊ณผ ๊ฒฐํฉํ๋ฉด ์ฝ์ฌ์ธ ๊ฑฐ๋ฆฌ์ ๋์ผํ ์์ ๋ฐ ์ํ์ ๋ฑ๊ฐ๋ฅผ ์ ๊ณตํฉ๋๋ค. |
FeatureNormType
์ด๊ฑฐํ | |
---|---|
UNIT_L2_NORM |
๋จ์ L2 ์ ๊ทํ ์ ํ์ ๋๋ค. |
NONE |
๊ธฐ๋ณธ๊ฐ ์ง์ ๋ ์ ๊ทํ ์ ํ์ด ์์ต๋๋ค. |
TreeAhConfig
tree-AH ์๊ณ ๋ฆฌ์ฆ(Shallow tree + Asymmetric Hashing)์ ์ ํํ ์ ์๋ ํ๋์ ๋๋ค.
ํ๋ | |
---|---|
fractionLeafNodesToSearch |
double |
์ฟผ๋ฆฌ๋ฅผ ๊ฒ์ํ ์ ์๋ ๋ฆฌํ ๋ ธ๋์ ๊ธฐ๋ณธ ๋น์จ์ ๋๋ค. ๋ฒ์๋ 0.0~1.0 ๋ฏธ๋ง์ด์ด์ผ ํฉ๋๋ค. ์ค์ ํ์ง ์์ผ๋ฉด ๊ธฐ๋ณธ๊ฐ์ 0.05์ ๋๋ค. | |
leafNodeEmbeddingCount |
int32 |
๊ฐ ๋ฆฌํ ๋ ธ๋์ ์๋ฒ ๋ฉ ์์ ๋๋ค. ์ค์ ํ์ง ์์ผ๋ฉด ๊ธฐ๋ณธ๊ฐ์ 1000์ ๋๋ค. | |
leafNodesToSearchPercent |
int32 |
์ง์ ์ค๋จ๋จ, fractionLeafNodesToSearch ๋ฅผ ์ฌ์ฉํ์ธ์.์ฟผ๋ฆฌ๋ฅผ ๊ฒ์ํ ์ ์๋ ๋ฆฌํ ๋ ธ๋์ ๊ธฐ๋ณธ ๋น์จ์ ๋๋ค. 1~100 ๋ฒ์ ๋ด์ ์์ด์ผ ํฉ๋๋ค. ์ค์ ๋์ง ์์ผ๋ฉด ๊ธฐ๋ณธ๊ฐ์ 10(์ฆ, 10%)์ ๋๋ค. |
BruteForceConfig
์ด ์ต์
์ ๋ฐ์ดํฐ๋ฒ ์ด์ค์์ ๊ฐ ์ฟผ๋ฆฌ์ ํ์ค ์ ํ ๊ฒ์์ ๊ตฌํํฉ๋๋ค. ๋ฌด์ฐจ๋ณ ๊ฒ์์ ์ํด ๊ตฌ์ฑํ ํ๋๊ฐ ์์ต๋๋ค. ์ด ์๊ณ ๋ฆฌ์ฆ์ ์ ํํ๋ ค๋ฉด BruteForceConfig
์ ๋น ๊ฐ์ฒด๋ฅผ algorithmConfig
์ ์ ๋ฌํฉ๋๋ค.
์ ๋ ฅ ๋ฐ์ดํฐ ์๊ตฌ์ฌํญ
๋ฐ์ดํฐ ์ธํธ๋ฅผ Cloud Storage ์์น์ ์ ๋ก๋ํ์ธ์. ํ์ผ์ด JSON ์ค ํ์์ธ์ง ํ์ธํ์ธ์.
ํ์ผ์ JSON Lines ํ์์ด์ด์ผ ํฉ๋๋ค. ๋ค์ ์ํ์ ์ด๋ฏธ์ง ๋ถ๋ฅ ์์ ๊ธฐ๋ฐ ์ค๋ช ๋ ธํธ๋ถ์์ ๊ฐ์ ธ์จ ๊ฒ์ ๋๋ค.
{"id": "0", "bytes_inputs": {"b64": "..."}}
{"id": "1", "bytes_inputs": {"b64": "..."}}
{"id": "2", "bytes_inputs": {"b64": "..."}}
์์ธ ๋๋ ๊ตฌ์ฑ ์ ๋ฐ์ดํธ
Vertex AI๋ฅผ ์ฌ์ฉํ๋ฉด ๋ชจ๋ธ์ ์ต๊ทผ์ ์ด์ ์์ธ์ด๋ Example
๊ตฌ์ฑ์ ์
๋ฐ์ดํธํ ์ ์์ต๋๋ค. ์ด๋ ๋ฐ์ดํฐ ์ธํธ์ ์์ธ์ ์ฌ์์ฑํ์ง ์๊ณ ๋ชจ๋ธ์ ์
๋ฐ์ดํธํ๋ ค๋ ๊ฒฝ์ฐ์ ์ ์ฉํฉ๋๋ค. ์๋ฅผ ๋ค์ด ๋ชจ๋ธ์ ์์ธ์ 1,000๊ฐ์ ์ธ์คํด์ค๊ฐ ํฌํจ๋์ด ์๊ณ ์ธ์คํด์ค 500๊ฐ๋ฅผ ๋ ์ถ๊ฐํ๋ ค๋ ๊ฒฝ์ฐ UpdateExplanationDataset
๋ฅผ ํธ์ถํ๋ฉด ์๋์ ์ธ์คํด์ค 1,000๊ฐ๋ฅผ ๋ค์ ์ฒ๋ฆฌํ์ง ์๊ณ ์์ธ์ ์ถ๊ฐํ ์ ์์ต๋๋ค.
์ค๋ช ๋ฐ์ดํฐ ์ธํธ๋ฅผ ์ ๋ฐ์ดํธํ๋ ค๋ฉด ๋ค์ ์๋ด๋ฅผ ๋ฐ๋ฅด์ธ์.
Python
def update_explanation_dataset(model_id, new_examples):
response = clients["model"].update_explanation_dataset(model=model_id, examples=new_examples)
update_dataset_response = response.result()
return update_dataset_response
PRESET_CONFIG = {
"modality": "TEXT",
"query": "FAST"
}
NEW_DATASET_FILE_PATH = "new_dataset_path"
NUM_NEIGHBORS_TO_RETURN = 10
EXAMPLES = aiplatform.Examples(presets=PRESET_CONFIG,
gcs_source=aiplatform.types.io.GcsSource(uris=[NEW_DATASET_FILE_PATH]),
neighbor_count=NUM_NEIGHBORS_TO_RETURN)
MODEL_ID = 'model_id'
update_dataset_response = update_explanation_dataset(MODEL_ID, EXAMPLES)
์ฌ์ฉ ์ฐธ๊ณ ์ฌํญ:
model_id
๋UpdateExplanationDataset
์์ ํ์๋ ๊ทธ๋๋ก ์ ์ง๋ฉ๋๋ค.UpdateExplanationDataset
์์ ์Model
๋ฆฌ์์ค์๋ง ์ํฅ์ ์ฃผ๋ฉฐ, ์ฐ๊ฒฐ๋DeployedModel
๋ ์ ๋ฐ์ดํธ๋์ง ์์ต๋๋ค. ์ฆ,deployedModel
์ ์์ธ์ ๋ฐฐํฌ ๋น์์ ๋ฐ์ดํฐ ์ธํธ๊ฐ ํฌํจ๋ฉ๋๋ค.deployedModel
์ ์์ธ์ ์ ๋ฐ์ดํธํ๋ ค๋ฉด ์ ๋ฐ์ดํธํ ๋ชจ๋ธ์ ์๋ํฌ์ธํธ๋ก ์ฌ๋ฐฐํฌํด์ผ ํฉ๋๋ค.
์จ๋ผ์ธ ์ค๋ช ์ ๊ฐ์ ธ์ฌ ๋ ๊ตฌ์ฑ ์ฌ์ ์
์ค๋ช
์ ์์ฒญํ ๋ ExplanationSpecOverride
ํ๋๋ฅผ ์ง์ ํ์ฌ ์ฆ์์์ ์ผ๋ถ ๋งค๊ฐ๋ณ์๋ฅผ ์ฌ์ ์ํ ์ ์์ต๋๋ค.
์ ํ๋ฆฌ์ผ์ด์ ์ ๋ฐ๋ผ์๋ ๋ฐํ๋๋ ์ค๋ช ์ ํ์ ์ผ๋ถ ์ ์ฝ ์กฐ๊ฑด์ ์ ์ฉํ๋ ๊ฒ์ด ์ ํฉํ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด, ๋ค์ํ ์ค๋ช ์ ๋ณด์ฅํ๊ธฐ ์ํด ์ฌ์ฉ์๊ฐ ์ค๋ช ์ ๋จ์ผ ์ ํ์ ์์๊ฐ ์ค๋ช ์์ ๊ณผ๋ํ๊ฒ ํํ๋์ง ์์์ ๋ํ๋ด๋ ํฌ๋ผ์ฐ๋ฉ ๋งค๊ฐ๋ณ์๋ฅผ ์ง์ ํ ์ ์์ต๋๋ค. ๊ตฌ์ฒด์ ์ผ๋ก๋ ๋ชจ๋ธ์์ ์๊ฐ ๋นํ๊ธฐ๋ก ๋ผ๋ฒจ์ด ์ง์ ๋ ์ด์ ๋ฅผ ํ์ ํ๋ ค๊ณ ํ ๋ ๊ทผ๋ณธ ์์ธ์ ํจ๊ณผ์ ์ผ๋ก ์กฐ์ฌํ๊ธฐ ์ํด ๋๋ฌด ๋ง์ ์ ์์๋ฅผ ์ค๋ช ์ผ๋ก ํ์ํ๋ ๊ฒ์ ์ํ์ง ์์ ์ ์์ต๋๋ค.
๋ค์ ํ์๋ ์์ ๊ธฐ๋ฐ ์ค๋ช ์์ฒญ์ ๋ํด ์ฌ์ ์ํ ์ ์๋ ๋งค๊ฐ๋ณ์๊ฐ ์์ฝ๋์ด ์์ต๋๋ค.
์์ฑ ์ด๋ฆ | ์์ฑ ๊ฐ | ์ค๋ช |
---|---|---|
neighborCount | int32 |
์ค๋ช ์ผ๋ก ๋ฐํํ ์์ ์์ ๋๋ค. |
crowdingCount | int32 |
๋์ผํ ํฌ๋ผ์ฐ๋ฉ ํ๊ทธ๋ก ๋ฐํํ ์ต๋ ์์ ์์ ๋๋ค. |
allow | String Array |
์ค๋ช ์ ํ์ฉ๋๋ ํ๊ทธ์ ๋๋ค. |
deny | String Array |
์ค๋ช ์ ํ์ฉ๋์ง ์๋ ํ๊ทธ์ ๋๋ค. |
๋ฒกํฐ ๊ฒ์ ํํฐ๋ง์์๋ ์ด๋ฌํ ๋งค๊ฐ๋ณ์๋ฅผ ์์ธํ ์ค๋ช ํฉ๋๋ค.
๋ค์์ ์ฌ์ ์๊ฐ ํฌํจ๋ JSON ์์ฒญ ๋ณธ๋ฌธ์ ์์์ ๋๋ค.
{
"instances":[
{
"id": data[0]["id"],
"bytes_inputs": {"b64": bytes},
"restricts": "",
"crowding_tag": ""
}
],
"explanation_spec_override": {
"examples_override": {
"neighbor_count": 5,
"crowding_count": 2,
"restrictions": [
{
"namespace_name": "label",
"allow": ["Papilloma", "Rift_Valley", "TBE", "Influenza", "Ebol"]
}
]
}
}
}
๋ค์ ๋จ๊ณ
๋ค์์ ์์ ๊ธฐ๋ฐ explain
์์ฒญ์ ์๋ต ์์
๋๋ค.
[
{
"neighbors":[
{
"neighborId":"311",
"neighborDistance":383.8
},
{
"neighborId":"286",
"neighborDistance":431.4
}
],
"input":"0"
},
{
"neighbors":[
{
"neighborId":"223",
"neighborDistance":471.6
},
{
"neighborId":"55",
"neighborDistance":392.7
}
],
"input":"1"
}
]
๊ฐ๊ฒฉ ์ฑ ์
๊ฐ๊ฒฉ ์ฑ ์ ํ์ด์ง์์ ์์ ๊ธฐ๋ฐ ์ค๋ช ์ ๋ํ ์น์ ์ดํด๋ณด๊ธฐ