Skip to content
Merged
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
20 changes: 5 additions & 15 deletions axlearn/common/causal_lm.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,22 +475,12 @@ def predict(self, input_batch: dict[str, Tensor]) -> dict[str, Tensor]:
hidden_states: a float Tensor of shape [batch_size, seq_len, hidden_dim]
"""
self._constrain_input_batch(input_batch)
input_ids: Tensor = input_batch["input_ids"]
token_type_ids: Optional[Tensor] = input_batch.get("token_type_ids")
input_segment_ids: Optional[Tensor] = input_batch.get("input_segment_ids")
input_positions: Optional[Tensor] = input_batch.get("input_positions")
# TODO(markblee): Simplify by using consistent naming between `input_positions` and
# `positions`, `input_segment_ids` and `segment_ids`.
# Decoder hidden states: [batch_size, target_len, hidden_dim].
decoder_output = self.decoder(
# TODO(markblee): Simplify by using consistent naming between `input_positions` and
# `positions`, `input_segment_ids` and `segment_ids`.
input_batch=dict(
input_ids=input_ids,
token_type_ids=token_type_ids,
input_segment_ids=input_segment_ids,
positions=input_positions,
),
)
return decoder_output
decoder_batch = {**input_batch}
decoder_batch["positions"] = input_batch.get("input_positions")
return self.decoder(input_batch=decoder_batch)

def _metrics(
self, input_batch: Nested[Tensor], *, predict_outputs: Nested[Tensor]
Expand Down
Loading