GoogleCloudPlatform / GoogleCloudPlatform/nodejs-docs-samples
Extract embeddings values using PredictionServiceClient
- Langage dominant
- JavaScript
- Étoiles
- 3k
- Forks
- 2k
- Merge moyen
- 2 j 19 h
- PR mergées (30 j)
- 44
Description
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
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par ai-platform/snippets/predict-text-embeddings.js à la ligne référencée et examinez comment les réponses de PredictionServiceClient sont représentées. Déterminez comment accéder aux valeurs de embeddings et si l’exemple ou sa documentation nécessite une clarification afin que la sortie corresponde au format JSON présenté dans l’issue.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- google-cloud, javascript, node.js
- Domaine
- api, machine-learning
- Type d'issue
- Documentation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 25/100