EventStream.transformer.generation.generation_utils module¶
-
class EventStream.transformer.generation.generation_utils.SampleDecoderOnlyOutput(scores: tuple[GenerativeSequenceModelPredictions] | None =
None, batch: PytorchBatch | None =None, attentions: tuple[tuple[FloatTensor]] | None =None, hidden_states: tuple[tuple[FloatTensor]] | None =None)[source]¶ Bases:
ModelOutputBase class for outputs of decoder-only generation models using sampling.
- Parameters:¶
- batch: PytorchBatch | None =
None¶ The generated sequences.
- ( : hidden_states
tuple(GenerativeSequenceModelPredictions)optional, returned whenoutput_scores=Trueis passed or whenconfig.output_scores=True- )
Processed predictions of the generative sequence modeling head, as torch distributions at each generation step.
- (
tuple(tuple(torch.FloatTensor)), optional, returned whenoutput_attentions=Trueis passed orconfig.output_attentions=True- )
Tuple (one element for each generated token) of tuples (one element for each layer of the decoder) of
torch.FloatTensorof shape(batch_size, num_heads, generated_length, sequence_length).- (
tuple(tuple(torch.FloatTensor)), optional, returned whenoutput_hidden_states=Trueis passed or whenconfig.output_hidden_states=True- )
Tuple (one element for each generated token) of tuples (one element for each layer of the decoder) of
torch.FloatTensorof shape(batch_size, generated_length, dependency_graph_len, hidden_size).
- batch: PytorchBatch | None =
-
batch : PytorchBatch | None =
None¶
-
scores : tuple[GenerativeSequenceModelPredictions] | None =
None¶
- class EventStream.transformer.generation.generation_utils.StructuredGenerationMixin[source]¶
Bases:
objectA class containing all functions for auto-regressive structured event stream generation, to be used as a mixin in [
PreTrainedModel].- The class exposes [
generate], which can be used for: sampling by calling [
sample] ifdo_sample=True.
-
generate(batch: PytorchBatch, max_length: int | None =
None, do_sample: bool | None =True, num_return_sequences: int | None =None, max_new_events: int | None =None, use_cache: bool | None =None, stopping_criteria: StoppingCriteriaList | None =[], output_attentions: bool | None =None, output_hidden_states: bool | None =None, output_scores: bool | None =None, return_dict_in_generate: bool | None =None, synced_gpus: bool | None =False, **model_kwargs) SampleDecoderOnlyOutput | PytorchBatch[source]¶
- The class exposes [