GoogleCloudPlatform / GoogleCloudPlatform/nodejs-docs-samples
Extract embeddings values using PredictionServiceClient
- 主要语言
- JavaScript
- 星标
- 3k
- 派生
- 2k
- 平均合并
- 2 天 19 小时
- 30 天内合并 PR
- 44
描述
Hi! I'm trying to find how to extract the embeddings values to add them to a json files following this format following the example https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/62253bb75d6068e1b44047eac5572246dfaa217b/ai-platform/snippets/predict-text-embeddings.js#L76C69-L76C69:
{"id":"0","embedding":[0.005268869,-0.019839672,0.0035084013,0.0536439,-0.028307509,0.0037563213, ...]}
But not sure how to access or put them into an array. The type is google.protobuf.IValue so in the example it iterates over an array google.protobuf.IValue[]. I'm doing:
```
const predictions = response.predictions;
for (const prediction of predictions) {
const value: google.protobuf.IValue = prediction;
console.log(`\t\tPrediction`, value.structValue); // structValue is the only one not returning undefined
// this returns: **fields: { embeddings: { structValue: [Object], kind: 'structValue' } }**
}
```
Thanks
贡献指南
调研方向
从引用行中的 ai-platform/snippets/predict-text-embeddings.js 开始,检查 PredictionServiceClient 响应的表示方式。确定应如何访问 embeddings 值,以及示例或其文档是否需要澄清,以使输出与 issue 中显示的 JSON 格式一致。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- google-cloud, javascript, node.js
- 领域
- api, machine-learning
- Issue 类型
- 文档
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100