Open mingshl opened 3 months ago
maybe one way to fix this bug is to move the reconstructing payload within local model only @rbhavna please share your thoughts in this fix?
This issue is blocking using custom prompt in the ml inference response processor,
I have another idea to make this genAI use case to work,
when the model_config contains the the field from input_map and output_map, we should try to cast the datatype into escape string.
for example, ${input_map.context} in going to be in the substring of ${model_config.prompt}, we can try cast the ${input_map.context} into escape string or it won't be a valid payload later.
@rbhavna can you try this case using the latest main branch and reproduce this issue?
PUT /_search/pipeline/my_pipeline_request_review_llm
{
"response_processors": [
{
"ml_inference": {
"tag": "ml_inference",
"description": "This processor is going to run llm",
"model_id": "cf46K5EBoVpekzRp8x_3",
"model_input": "{ \"prompt\": \"${model_config.prompt}\"}",
"function_name": "REMOTE",
"input_map": [
{
"context": "review"
}
],
"output_map": [
{
"llm_response": "response"
}
],
"model_config": {
"prompt":"\n\nHuman: You are a professional data analysist. You will always answer question based on the given context first. If the answer is not directly shown in the context, you will analyze the data and find the answer. If you don't know the answer, just say I don't know. Context: ${input_map.context}. \n\n Human: please summarize the documents \n\n Assistant:"
},
"ignore_missing": false,
"ignore_failure": false
}
}
]
}
What is the bug?
since this change in https://github.com/opensearch-project/ml-commons/commit/7cd52915d04d8ac7ddb6e37a74a256603587ce69 in ModelExecutor, the fields in model_config prefix is changed in payload.
before this commit, when using the
model_config
parameters, the parameter are usually prefix withparameters
, for exampleparameters.prompt
.after this commit, when using the
model_config
parameters, the parameter will be prefix with 'model_config', for example,model_config.prompt
.now that using ml inference processor with model_config, on both search request, response and ingest, for remote model, we need to set
model_input
to rewrite the prefix, or the model_config won't be recognized by the connector response bodyThe pros about the parameters prefix is that it can identify the same parameters name within
input_map
andmodel_config
when compilingmodel_input
. However, for remote models, the inference processor passed over config such asmodel_config.prompt
, it won't be recognized in the response body, because in the connector, all parameters are prefix withparameter
, for exampleparameters.prompt
.How can one reproduce the bug? Steps to reproduce the behavior:
example 1, this is failing:
example 2, this is success when we rewrite the
model_config.prompt
intoparameters.prompt
What is the expected behavior? example 1 should be succeed.
What is your host/environment?
Do you have any screenshots? If applicable, add screenshots to help explain your problem.
Do you have any additional context? Add any other context about the problem.