-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Extend huggingface with rerank #127297
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
base: main
Are you sure you want to change the base?
Extend huggingface with rerank #127297
Conversation
@@ -361,6 +362,7 @@ public void loadExtensions(ExtensionLoader loader) { | |||
public List<InferenceServiceExtension.Factory> getInferenceServiceFactories() { | |||
return List.of( | |||
context -> new HuggingFaceElserService(httpFactory.get(), serviceComponents.get()), | |||
context -> new HuggingFaceRerankService(httpFactory.get(), serviceComponents.get()), |
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.
Instead of creating a whole new service we'll want to add the functionality to the HuggingFaceService
.
For example the OpenAI service supports many task types: https://github.com/elastic/elasticsearch/blob/main/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/services/openai/OpenAiService.java#L175-L197
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.
Thank you, Jonathan. Now the HuggingFaceService is used
|
||
import static org.elasticsearch.xpack.inference.common.Truncator.truncate; | ||
|
||
public class HuggingFaceRequestRerankManager extends BaseRequestManager { |
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.
We're trying to move away from the request manager pattern because it adds duplicate code. Could you look into following the pattern we started here (we haven't refactored all the services yet but if it's possible to do for hugging face it'd be great if we could do it now)?
One option would be to leave the other hugging face request managers as they are (if possible, it may not be though) and then use one of the generic request managers like shown in the PR above for this new functionality.
We'll want to sync up with @Jan-Kazlouski-elastic to ensure that we're not duplicating that refactoring work though.
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.
We synced with Jan. I followed the changes he applied with GenericRequestManager
|
||
@Override | ||
public String modelId() { | ||
return null; |
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.
I would be adding comments for such implementations.
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.
Thanks. Added the comment
Pinging @elastic/ml-core (Team:ML) |
586ae7f
to
390b7e7
Compare
gradle check
?