Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,11 @@ def prepare_inputs_for_generation(
if attention_mask is not None and attention_mask.shape[1] > (
input_ids.shape[1] // self.config.input_token_len
):
input_ids = input_ids[:, -(attention_mask.shape[1] - past_length) :]
input_ids = input_ids[
:,
-(attention_mask.shape[1] - past_length)
* self.config.input_token_len :,
]
# 2 - If the past_length is smaller than input_ids', then input_ids holds all input tokens. We can discard
# input_ids based on the past_length.
elif past_length < (input_ids.shape[1] // self.config.input_token_len):
Expand All @@ -629,9 +633,10 @@ def prepare_inputs_for_generation(
position_ids = attention_mask.long().cumsum(-1) - 1
position_ids.masked_fill_(attention_mask == 0, 1)
if past_key_values:
position_ids = position_ids[
:, -(input_ids.shape[1] // self.config.input_token_len) :
]
token_num = (
input_ids.shape[1] + self.config.input_token_len - 1
) // self.config.input_token_len
position_ids = position_ids[:, -token_num:]

# if `inputs_embeds` are passed, we only want to use them in the 1st generation step
if inputs_embeds is not None and past_key_values is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,11 @@ def prepare_inputs_for_generation(
if attention_mask is not None and attention_mask.shape[1] > (
input_ids.shape[1] // self.config.input_token_len
):
input_ids = input_ids[:, -(attention_mask.shape[1] - past_length) :]
input_ids = input_ids[
:,
-(attention_mask.shape[1] - past_length)
* self.config.input_token_len :,
]
# 2 - If the past_length is smaller than input_ids', then input_ids holds all input tokens. We can discard
# input_ids based on the past_length.
elif past_length < (input_ids.shape[1] // self.config.input_token_len):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ public void beforeStart(UDFParameters parameters, UDTFConfigurations configurati
}
ModelInferenceDescriptor descriptor = modelFetcher.fetchModel(this.model_id);
this.targetAINode = descriptor.getTargetAINode();
this.maxInputLength = descriptor.getModelInformation().getInputShape()[0];

this.outputInterval = parameters.getLongOrDefault(OUTPUT_INTERVAL, DEFAULT_OUTPUT_INTERVAL);
this.outputLength =
Expand Down
Loading