-
Notifications
You must be signed in to change notification settings - Fork 128
Ported the reranking models: Bert-based, Roberta-based and Qwen3-based. #1001
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
885740e
Ported three types of reranking models: Bert-based, Roberta-based and…
gyou2021 3d5b006
Fixed imported but unused problem.
gyou2021 36d23ae
Fixed the code format.
gyou2021 07aea44
Added conditions in case of no kv_cache.
gyou2021 e8f9363
Added conditions in case of no kv_cache.
gyou2021 de1cd02
Fixed the bug in initialize_kv_cache.
gyou2021 3175fa7
Removed unused codes.
gyou2021 889c312
Removed logically duplicated codes.
gyou2021 c7d068f
Merge remote-tracking branch 'origin/main' into reranking
gyou2021 8db4419
Merge branch 'main' into reranking
iboiko-habana 9efb0cb
Merge branch 'main' into reranking
iboiko-habana e5a3874
Merge branch 'main' into reranking
iboiko-habana 83c5ab7
Merge branch 'main' into reranking
michalkuligowski ac072a8
Removed duplicated bucketing_manager init and fixed a bug in the warm…
gyou2021 6509fae
Merge remote-tracking branch 'origin/main' into reranking
gyou2021 c5c550a
Merge branch 'reranking' of https://github.com/gyou2021/vllm-gaudi in…
gyou2021 fd73dbc
Reused the method _encode_token_type_ids of bert.
gyou2021 d5bc6b6
Merge branch 'main' into reranking
iboiko-habana File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import torch | ||
| from vllm.sequence import IntermediateTensors | ||
| from vllm.model_executor.models.bert import TOKEN_TYPE_SHIFT, BertForSequenceClassification | ||
|
|
||
|
|
||
| def patched_BertForSequenceClassification_forward( | ||
| self, | ||
| input_ids: torch.Tensor | None, | ||
| positions: torch.Tensor, | ||
| intermediate_tensors: IntermediateTensors | None = None, | ||
| inputs_embeds: torch.Tensor | None = None, | ||
| token_type_ids: torch.Tensor | None = None, | ||
| ) -> torch.Tensor: | ||
| if token_type_ids is not None: | ||
| assert self.bert.config.vocab_size < (1 << TOKEN_TYPE_SHIFT) | ||
| assert input_ids is not None | ||
|
|
||
| return self.bert( | ||
| input_ids=input_ids, | ||
| positions=positions, | ||
| inputs_embeds=inputs_embeds, | ||
| intermediate_tensors=intermediate_tensors, | ||
| ) | ||
|
|
||
|
|
||
| BertForSequenceClassification.forward = patched_BertForSequenceClassification_forward | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import torch | ||
| from vllm.sequence import IntermediateTensors | ||
| from vllm.model_executor.models.bert import TOKEN_TYPE_SHIFT | ||
| from vllm.model_executor.models.roberta import RobertaForSequenceClassification, replace_roberta_positions | ||
|
|
||
|
|
||
| def patched_RobertaForSequenceClassification_forward( | ||
| self, | ||
| input_ids: torch.Tensor | None, | ||
| positions: torch.Tensor, | ||
| intermediate_tensors: IntermediateTensors | None = None, | ||
| inputs_embeds: torch.Tensor | None = None, | ||
| token_type_ids: torch.Tensor | None = None, | ||
| ) -> torch.Tensor: | ||
| replace_roberta_positions(input_ids=input_ids, position_ids=positions, padding_idx=self.padding_idx) | ||
| if token_type_ids is not None: | ||
| assert self.roberta.config.vocab_size < (1 << TOKEN_TYPE_SHIFT) | ||
| assert input_ids is not None | ||
|
|
||
| return self.roberta( | ||
| input_ids=input_ids, | ||
| positions=positions, | ||
| inputs_embeds=inputs_embeds, | ||
| intermediate_tensors=intermediate_tensors, | ||
|
gyou2021 marked this conversation as resolved.
|
||
| ) | ||
|
|
||
|
|
||
| RobertaForSequenceClassification.forward = patched_RobertaForSequenceClassification_forward | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.