-
Notifications
You must be signed in to change notification settings - Fork 725
Closed
Labels
Description
🐛 Bug Report
The inferTrainedModel method is not recognized.
I am trying to create a semantic search functionality using Elastic and a Next.js frontend. As part of this process, I need to convert a string into an embedding vector.
I am able to do this in the dev console without any issues:
POST /_ml/trained_models/<model_id>/_infer
{
"docs": {
"text_field": "test string"
}
}However, when I try to call the same method using this library, I get an error saying that the method is not recognized:
TypeError: client.ml.inferTrainedModel is not a function
The relevant code from the API route is here:
try {
const test = await client.ml.inferTrainedModel({
index: 'embeddings-test',
model_id: <model_id>,
docs: { text_field: req.body },
});As a sanity check, I was able to successfully access other methods in the ml class, like the getTrainedModelStats method.
To Reproduce
Steps to reproduce the behavior:
- upload transformer model to Elastic (in this case, a custom fine-tuned BERT model)
- create dense vector field in mapping
- create API route to the inferTrainedModel endpoint in Next.js
- send string to this route
Expected behavior
An embedding vector in response to the inferTrainedModel request.
Your Environment
- node version: 18.2.0
@elastic/elasticsearchversion: 8.2.1- os: Mac
- framework: Next.js