The model output associated with a sequence. Args: parent_seq_id: The ID of the parent sequence (for forking in beam search). output_token: The output token ID. logprobs: The logprobs of the output token. (Token id -> logP(x_i+1 | x_0, ..., x_i))
| 363 | |
| 364 | |
| 365 | class SequenceOutput: |
| 366 | """The model output associated with a sequence. |
| 367 | |
| 368 | Args: |
| 369 | parent_seq_id: The ID of the parent sequence (for forking in beam |
| 370 | search). |
| 371 | output_token: The output token ID. |
| 372 | logprobs: The logprobs of the output token. |
| 373 | (Token id -> logP(x_i+1 | x_0, ..., x_i)) |
| 374 | """ |
| 375 | |
| 376 | def __init__( |
| 377 | self, |
| 378 | parent_seq_id: int, |
| 379 | output_token: int, |
| 380 | logprobs: Dict[int, float], |
| 381 | ) -> None: |
| 382 | self.parent_seq_id = parent_seq_id |
| 383 | self.output_token = output_token |
| 384 | self.logprobs = logprobs |
| 385 | |
| 386 | def __repr__(self) -> str: |
| 387 | return (f"SequenceOutput(parent_seq_id={self.parent_seq_id}, " |
| 388 | f"output_token={self.output_token}, " |
| 389 | f"logprobs={self.logprobs})") |
| 390 | |
| 391 | def __eq__(self, other: object) -> bool: |
| 392 | if not isinstance(other, SequenceOutput): |
| 393 | raise NotImplementedError() |
| 394 | return (self.parent_seq_id == other.parent_seq_id |
| 395 | and self.output_token == other.output_token |
| 396 | and self.logprobs == other.logprobs) |
| 397 | |
| 398 | |
| 399 | class SequenceGroupOutput: |
no outgoing calls
no test coverage detected