-
Notifications
You must be signed in to change notification settings - Fork 3k
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
.Net: Fix hugging face embedding #6673
base: main
Are you sure you want to change the base?
Conversation
Added class `TextEmbeddingResponseType1` & `TextEmbeddingResponseType2` to parse two distinct possible JsonRequest
…Async` - Added try-catch block to better handle parsing in `GenerateEmbeddingsAsync` method.
dotnet/src/Connectors/Connectors.HuggingFace/Core/Models/TextEmbeddingResponse.cs
Outdated
Show resolved
Hide resolved
Hello @dmytrostruk |
@N-E-W-T-O-N That's awesome, thanks for validating this idea and creating an example for this! I think you can put it here: |
I want to add two more parameters in the api's payload body namely 'use_cache' & 'wait_for_model' I want to send this values as addition parameters in the HuggingFaceClient https://huggingface.co/docs/api-inference/en/detailed_parameters |
@dmytrostruk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@N-E-W-T-O-N Thanks for your contribution! There are some warnings about possible null references and formatting issues. In order to proceed with merging, we need to make sure that all warnings are resolved. Thanks again!
dotnet/samples/Concepts/Memory/MemoryHuggingFaceEmbedding_CustomHttpResponse.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Connectors/Connectors.HuggingFace/Core/HuggingFaceClient.cs
Outdated
Show resolved
Hide resolved
dotnet/samples/Concepts/Memory/MemoryHuggingFaceEmbedding_CustomHttpResponse.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Connectors/Connectors.HuggingFace/Core/HuggingFaceClient.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Connectors/Connectors.HuggingFace/Core/Models/TextEmbeddingResponse.cs
Show resolved
Hide resolved
… HuggingFace_TextEmbeddingCustomHttpHandle.cs Removed trailed whitespaces & rename the file
Removed try-catch method
@RogerBarreto It might be possible that changes in TextEmbeddingResponse class will lead to test case failure |
Remove the whitespace error. |
@N-E-W-T-O-N there are still formatting errors to be addressed. Suggest you run |
@dmytrostruk please check it now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@N-E-W-T-O-N PR looks good to me, but there are several unit tests that started to fail because of new change in deserialization logic.
dotnet/samples/Concepts/Memory/HuggingFace_TextEmbeddingCustomHttpHandle.cs
Outdated
Show resolved
Hide resolved
@dmytrostruk may I ask how to test unit test cases locally |
cd dotnet/src/Connectors/Connectors.HuggingFace.UnitTests
dotnet test |
@dmytrostruk The issue is unit tests are still based on the previous version of embedding dimensions as noted by@RogerBarreto .Would you like me to update the unit test accordingly? |
@N-E-W-T-O-N Yes, if we are changing the behavior, then unit tests should be updated as well. Thanks! |
chin assert as per dotnet format
@dmytrostruk moved the class inside with access modifier 'private sealed' Resolve the unit test issue |
@dmytrostruk anything to add from my side |
@N-E-W-T-O-N I think we are ready to merge this to |
dotnet/samples/Concepts/Memory/HuggingFace_TextEmbeddingCustomHttpHandler.cs
Outdated
Show resolved
Hide resolved
dotnet/samples/Concepts/Memory/HuggingFace_TextEmbeddingCustomHttpHandler.cs
Outdated
Show resolved
Hide resolved
@dmytrostruk updated the code based on the suggestion of @westey-m |
@dmytrostruk |
Motivation and Context
Fix the Bug #6635 HuggingFace Embedding: Unable to Deserialization for certain models
Description
As mentioned in the issue, the HuggingFace Embedding API interface returns responses typically in the form of
List<ReadOnlyMemory<float>>
and occasionally asList<List<List<ReadOnlyMemory<float>>>>
. Currently, only the latter format is handled correctly, leading to deserialization issues.To address this, I propose the following solution:
Contribution Checklist