[Bugfix] Preserve padding token types for cross encoders (#58143)
Signed-off-by: zhaoye <772971548@qq.com> Co-authored-by: Taneem Ibrahim <taneem.ibrahim@gmail.com>
This commit is contained in:
@@ -105,12 +105,15 @@ class EncoderOnlyModelState(DefaultModelState):
|
||||
if pooling_params is None or pooling_params.extra_kwargs is None:
|
||||
return
|
||||
|
||||
token_type_start = pooling_params.extra_kwargs.get("compressed_token_type_ids")
|
||||
if token_type_start is not None:
|
||||
token_type_range = pooling_params.extra_kwargs.get("compressed_token_type_ids")
|
||||
if token_type_range is not None:
|
||||
assert new_req_data.prompt_token_ids is not None
|
||||
token_type_start, token_type_end = token_type_range
|
||||
positions = torch.arange(
|
||||
len(new_req_data.prompt_token_ids), dtype=torch.int32
|
||||
)
|
||||
self.token_type_ids[new_req_data.req_id] = (
|
||||
torch.arange(len(new_req_data.prompt_token_ids), dtype=torch.int32)
|
||||
>= token_type_start
|
||||
(positions >= token_type_start) & (positions < token_type_end)
|
||||
).to(torch.int32)
|
||||
|
||||
def remove_request(self, req_id: str) -> None:
|
||||
|
||||
Reference in New Issue
Block a user