Open Adeel-UNSW opened 7 months ago
Hey @Adeel-UNSW, nice to see you back around these parts! Hope you've been well since our last chat.
Thank you for providing detailed information about the issue you're facing. Based on the error message you're encountering, it seems like there's a problem with the data type of the embeddings returned by the SageMaker endpoint. The error message indicates that the value is not a valid float, which suggests that the EmbeddingEndEvent
is expecting a float value but is receiving a different data type.
The EmbeddingEndEvent
is a Pydantic model, which is used for data validation. Pydantic models enforce type checking, so if the data type of the input does not match the expected data type, a ValidationError
is raised. In this case, the EmbeddingEndEvent
is expecting a list of lists of floats for the embeddings
field, but it seems to be receiving a different data type.
The SageMakerEmbedding
class uses the deserialize_output
method of the content_handler
object to process the response from the SageMaker endpoint. The deserialize_output
method is responsible for converting the response into the expected format. If the deserialize_output
method is not correctly processing the response, it could be causing the ValidationError
.
Without the specific implementation details of the deserialize_output
method, it's difficult to determine the exact cause of the issue. However, you could try printing the response from the SageMaker endpoint before it's processed by the deserialize_output
method to see if it's in the expected format. You could add the following lines of code before the deserialize_output
method is called:
response = self.sagemaker_runtime_client.invoke_endpoint(
EndpointName=self.endpoint_name,
ContentType='application/json',
Body=json.dumps(payload),
Accept='application/json'
)
print(response['Body'].read().decode())
This will print the raw response from the SageMaker endpoint, which might help identify if the issue is with the response format.
If the response format is correct, the issue might be with the deserialize_output
method. You could try printing the output of the deserialize_output
method to see if it's correctly processing the response:
output = self.content_handler.deserialize_output(response=response)
print(output)
This will print the output of the deserialize_output
method, which might help identify if the issue is with the deserialization logic.
If you're still encountering the issue after trying these solutions, it might be helpful to provide more information about your environment, such as the exact version of the botocore
and boto3
packages you're using, and any other relevant details about your setup. This could help identify if there's a specific compatibility issue or other underlying problem causing the connection error.
I hope this helps! If you have any other questions or need further clarification, please don't hesitate to ask.
Seems like pagemaker isn't returning proper types, it should be a List[float]
-- would have to update the integration class
@logan-markewich were you able to replicate this issue ? Who needs to update the integration class ?
I don't have access to test sagemaker. I could make a guess at a fix.
It's an open source library, so anyone can make a change :)
Bug Description
I am using Llama-index version 0.10.20 and llama-index-embeddings-sagemaker-endpoint version 0.1.3. My code was working on AWS sagemaker notebook since yesterday using the 0.10.18 version of llama-index. Please see the code below
I am getting below error
**--> 235 dispatcher.event(EmbeddingEndEvent(chunks=[text], embeddings=[text_embedding])) 236 return text_embedding
File /opt/conda/lib/python3.10/site-packages/pydantic/v1/main.py:341, in BaseModel.init(pydantic_self__, **data) 339 values, fields_set, validation_error = validate_model(pydantic_self.class, data) 340 if validation_error: --> 341 raise validation_error 342 try: 343 object_setattr(__pydantic_self, 'dict', values)
ValidationError: 1 validation error for EmbeddingEndEvent embeddings -> 0 -> 0 value is not a valid float (type=type_error.float)**
Please have a look at the relevant logs when I just execute the following lines of code
Please let me know if you have any questions
Version
0.10.20
Steps to Reproduce
Relevant Logs/Tracbacks