Skip to content
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

Extract embeddings values using PredictionServiceClient #3601

Open
returnvoid opened this issue Jan 8, 2024 · 0 comments
Open

Extract embeddings values using PredictionServiceClient #3601

returnvoid opened this issue Jan 8, 2024 · 0 comments
Labels
samples Issues that are directly related to samples.

Comments

@returnvoid
Copy link

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

@product-auto-label product-auto-label bot added the samples Issues that are directly related to samples. label Jan 8, 2024
@returnvoid returnvoid changed the title Extract embeddings values Extract embeddings values using PredictionServiceClient Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
samples Issues that are directly related to samples.
Projects
None yet
Development

No branches or pull requests

1 participant