Open N-E-W-T-O-N opened 1 month ago
I suggest adding a condition check for the type coming from the API response to handle the deserialization process more gracefully.
@N-E-W-T-O-N Thanks for creating the issue. Would you be interested in creating a PR with the fix for this?
Happy to do that.
Hello @markwallace-microsoft . I have created a Pull Request #6673 as Asked Please review my PR
Describe the bug HuggingFace Embedding Interface API: Issue related to Deserialization So I was using BAAI/bge-large-en embedding model from huggingface Interface API .The code execution produces the following error:
The JSON value could not be converted to System.Collections.Generic.List`1[System.ReadOnlyMemory`1[System.Single]]. Path: $[0][0] | LineNumber: 0 | BytePositionInLine: 23.
To Reproduce Steps to reproduce the behavior:
Based on the output, it was clear that this issue was related to Json Deserilaztion .First, I check what the expected datatype.
internal sealed class TextEmbeddingResponse : List<List<List<ReadOnlyMemory<float>>>>;
The the HuggingFace Embedinng Expectedist<List<List<ReadOnlyMemory<float>>>>
& then return [0][0].ToList() Then I check in Postman what is the response coming from the embeddingSo it was clear that APi is sending List<ReadOnlyMemory> while services expects a list<list<list<ReadOnlyMemory>> .
I tested for other models and got the same response .
Screenshots
MxBai
All-MiniLM-L6-v2
Jina
Finally I tested with the following embedding LaBSE .Able to get the expected response .
Platform