text
stringlengths
31
243k
type
stringclasses
1 value
start
int64
36
275k
end
int64
286
280k
depth
int64
0
1
filepath
stringlengths
85
188
parent_class
stringclasses
3 values
class_index
int64
0
10.8k
class ConvertCommand(BaseTransformersCLICommand): @staticmethod def register_subcommand(parser: ArgumentParser): """ Register this command to argparse so it's available for the transformer-cli Args: parser: Root parser to register command-specific arguments """ ...
class_definition
1,305
7,067
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/commands/convert.py
null
10,600
class BaseTransformersCLICommand(ABC): @staticmethod @abstractmethod def register_subcommand(parser: ArgumentParser): raise NotImplementedError() @abstractmethod def run(self): raise NotImplementedError()
class_definition
681
922
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/commands/__init__.py
null
10,601
class LfsCommands(BaseTransformersCLICommand): """ Implementation of a custom transfer agent for the transfer type "multipart" for git-lfs. This lets users upload large files >5GB 🔥. Spec for LFS custom transfer agent is: https://github.com/git-lfs/git-lfs/blob/master/docs/custom-transfers.md This...
class_definition
941
2,550
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/commands/lfs.py
null
10,602
class LfsEnableCommand: def __init__(self, args): self.args = args def run(self): warnings.warn( "Managing repositories through transformers-cli is deprecated. Please use `huggingface-cli` instead." ) local_path = os.path.abspath(self.args.path) if not os.pat...
class_definition
2,553
3,358
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/commands/lfs.py
null
10,603
class FileSlice(AbstractContextManager): """ File-like object that only reads a slice of a file Inspired by stackoverflow.com/a/29838711/593036 """ def __init__(self, filepath: str, seek_from: int, read_limit: int): self.filepath = filepath self.seek_from = seek_from self.r...
class_definition
3,925
4,974
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/commands/lfs.py
null
10,604
class LfsUploadCommand: def __init__(self, args): self.args = args def run(self): # Immediately after invoking a custom transfer process, git-lfs # sends initiation data to the process over stdin. # This tells the process useful information about the configuration. init_...
class_definition
4,977
8,000
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/commands/lfs.py
null
10,605
class TrainCommand(BaseTransformersCLICommand): @staticmethod def register_subcommand(parser: ArgumentParser): """ Register this command to argparse so it's available for the transformer-cli Args: parser: Root parser to register command-specific arguments """ ...
class_definition
1,333
6,340
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/commands/train.py
null
10,606
class DataCollatorMixin: def __call__(self, features, return_tensors=None): if return_tensors is None: return_tensors = self.return_tensors if return_tensors == "tf": return self.tf_call(features) elif return_tensors == "pt": return self.torch_call(feature...
class_definition
1,307
1,803
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/data_collator.py
null
10,607
class DefaultDataCollator(DataCollatorMixin): """ Very simple data collator that simply collates batches of dict-like objects and performs special handling for potential keys named: - `label`: handles a single value (int or float) per object - `label_ids`: handles a list of values per objec...
class_definition
3,692
4,833
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/data_collator.py
null
10,608
class DataCollatorWithPadding: """ Data collator that will dynamically pad the inputs received. Args: tokenizer ([`PreTrainedTokenizer`] or [`PreTrainedTokenizerFast`]): The tokenizer used for encoding the data. padding (`bool`, `str` or [`~utils.PaddingStrategy`], *optional*, d...
class_definition
10,078
12,399
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/data_collator.py
null
10,609
class DataCollatorForTokenClassification(DataCollatorMixin): """ Data collator that will dynamically pad the inputs received, as well as the labels. Args: tokenizer ([`PreTrainedTokenizer`] or [`PreTrainedTokenizerFast`]): The tokenizer used for encoding the data. padding (`bool...
class_definition
12,413
18,426
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/data_collator.py
null
10,610
class DataCollatorForSeq2Seq: """ Data collator that will dynamically pad the inputs received, as well as the labels. Args: tokenizer ([`PreTrainedTokenizer`] or [`PreTrainedTokenizerFast`]): The tokenizer used for encoding the data. model ([`PreTrainedModel`], *optional*): ...
class_definition
23,531
30,100
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/data_collator.py
null
10,611
class DataCollatorForLanguageModeling(DataCollatorMixin): """ Data collator used for language modeling. Inputs are dynamically padded to the maximum length of a batch if they are not all of the same length. Args: tokenizer ([`PreTrainedTokenizer`] or [`PreTrainedTokenizerFast`]): Th...
class_definition
30,114
46,400
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/data_collator.py
null
10,612
class DataCollatorForWholeWordMask(DataCollatorForLanguageModeling): """ Data collator used for language modeling that masks entire words. - collates batches of tensors, honoring their tokenizer's pad_token - preprocesses batches for masked language modeling <Tip> This collator relies on deta...
class_definition
46,414
59,668
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/data_collator.py
null
10,613
class DataCollatorForSOP(DataCollatorForLanguageModeling): """ Data collator used for sentence order prediction task. - collates batches of tensors, honoring their tokenizer's pad_token - preprocesses batches for both masked language modeling and sentence order prediction """ def __init__(self...
class_definition
59,682
63,851
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/data_collator.py
null
10,614
class DataCollatorForPermutationLanguageModeling(DataCollatorMixin): """ Data collator used for permutation language modeling. - collates batches of tensors, honoring their tokenizer's pad_token - preprocesses batches for permutation language modeling with procedures specific to XLNet """ toke...
class_definition
63,865
84,573
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/data_collator.py
null
10,615
class DataCollatorWithFlattening(DefaultDataCollator): """ Data collator used for padding free approach. Does the following: - concatate the entire mini batch into single long sequence [1, total_tokens] - uses `separator_id` to separate sequences within the concatenated `labels`, default value is -100 ...
class_definition
84,587
86,355
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/data_collator.py
null
10,616
class TextDataset(Dataset): """ This will be superseded by a framework-agnostic approach soon. """ def __init__( self, tokenizer: PreTrainedTokenizer, file_path: str, block_size: int, overwrite_cache=False, cache_dir: Optional[str] = None, ): ...
class_definition
1,150
4,198
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/datasets/language_modeling.py
null
10,617
class LineByLineTextDataset(Dataset): """ This will be superseded by a framework-agnostic approach soon. """ def __init__(self, tokenizer: PreTrainedTokenizer, file_path: str, block_size: int): warnings.warn( DEPRECATION_WARNING.format( "https://github.com/huggingfac...
class_definition
4,201
5,590
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/datasets/language_modeling.py
null
10,618
class LineByLineWithRefDataset(Dataset): """ This will be superseded by a framework-agnostic approach soon. """ def __init__(self, tokenizer: PreTrainedTokenizer, file_path: str, block_size: int, ref_path: str): warnings.warn( DEPRECATION_WARNING.format( "https://git...
class_definition
5,593
7,853
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/datasets/language_modeling.py
null
10,619
class LineByLineWithSOPTextDataset(Dataset): """ Dataset for sentence order prediction task, prepare sentence pairs for SOP task """ def __init__(self, tokenizer: PreTrainedTokenizer, file_dir: str, block_size: int): warnings.warn( DEPRECATION_WARNING.format( "https:...
class_definition
7,856
15,399
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/datasets/language_modeling.py
null
10,620
class TextDatasetForNextSentencePrediction(Dataset): """ This will be superseded by a framework-agnostic approach soon. """ def __init__( self, tokenizer: PreTrainedTokenizer, file_path: str, block_size: int, overwrite_cache=False, short_seq_probability=0...
class_definition
15,402
23,720
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/datasets/language_modeling.py
null
10,621
class SquadDataTrainingArguments: """ Arguments pertaining to what data we are going to input our model for training and eval. """ model_type: str = field( default=None, metadata={"help": "Model type selected in the list: " + ", ".join(MODEL_TYPES)} ) data_dir: str = field( defa...
class_definition
1,296
3,767
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/datasets/squad.py
null
10,622
class Split(Enum): train = "train" dev = "dev"
class_definition
3,770
3,824
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/datasets/squad.py
null
10,623
class SquadDataset(Dataset): """ This will be superseded by a framework-agnostic approach soon. """ args: SquadDataTrainingArguments features: List[SquadFeatures] mode: Split is_language_sensitive: bool def __init__( self, args: SquadDataTrainingArguments, token...
class_definition
3,827
9,218
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/datasets/squad.py
null
10,624
class GlueDataTrainingArguments: """ Arguments pertaining to what data we are going to input our model for training and eval. Using `HfArgumentParser` we can turn this class into argparse arguments to be able to specify them on the command line. """ task_name: str = field(metadata={"help": "Th...
class_definition
1,121
2,176
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/datasets/glue.py
null
10,625
class Split(Enum): train = "train" dev = "dev" test = "test"
class_definition
2,179
2,251
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/datasets/glue.py
null
10,626
class GlueDataset(Dataset): """ This will be superseded by a framework-agnostic approach soon. """ args: GlueDataTrainingArguments output_mode: str features: List[InputFeatures] def __init__( self, args: GlueDataTrainingArguments, tokenizer: PreTrainedTokenizerBase,...
class_definition
2,254
6,162
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/datasets/glue.py
null
10,627
class XnliProcessor(DataProcessor): """ Processor for the XNLI dataset. Adapted from https://github.com/google-research/bert/blob/f39e881b169b9d53bea03d2d341b31707a6c052b/run_classifier.py#L207 """ def __init__(self, language, train_language=None): self.language = language self.trai...
class_definition
889
3,330
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/processors/xnli.py
null
10,628
class SquadProcessor(DataProcessor): """ Processor for the SQuAD data set. overridden by SquadV1Processor and SquadV2Processor, used by the version 1.1 and version 2.0 of SQuAD, respectively. """ train_file = None dev_file = None def _get_example_from_tensor_dict(self, tensor_dict, evaluat...
class_definition
21,537
27,206
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/processors/squad.py
null
10,629
class SquadV1Processor(SquadProcessor): train_file = "train-v1.1.json" dev_file = "dev-v1.1.json"
class_definition
27,209
27,314
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/processors/squad.py
null
10,630
class SquadV2Processor(SquadProcessor): train_file = "train-v2.0.json" dev_file = "dev-v2.0.json"
class_definition
27,317
27,422
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/processors/squad.py
null
10,631
class SquadExample: """ A single training/test example for the Squad dataset, as loaded from disk. Args: qas_id: The example's unique identifier question_text: The question string context_text: The context string answer_text: The answer string start_position_characte...
class_definition
27,425
29,629
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/processors/squad.py
null
10,632
class SquadFeatures: """ Single squad example features to be fed to a model. Those features are model-specific and can be crafted from [`~data.processors.squad.SquadExample`] using the :method:*~transformers.data.processors.squad.squad_convert_examples_to_features* method. Args: input_ids: ...
class_definition
29,632
32,388
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/processors/squad.py
null
10,633
class SquadResult: """ Constructs a SquadResult which can be used to evaluate a model's output on the SQuAD dataset. Args: unique_id: The unique identifier corresponding to that example. start_logits: The logits corresponding to the start of the answer end_logits: The logits corresp...
class_definition
32,391
33,152
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/processors/squad.py
null
10,634
class OutputMode(Enum): classification = "classification" regression = "regression"
class_definition
5,971
6,062
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/processors/glue.py
null
10,635
class MrpcProcessor(DataProcessor): """Processor for the MRPC data set (GLUE version).""" def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) warnings.warn(DEPRECATION_WARNING.format("processor"), FutureWarning) def get_example_from_tensor_dict(self, tensor_dict): ...
class_definition
6,065
7,831
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/processors/glue.py
null
10,636
class MnliProcessor(DataProcessor): """Processor for the MultiNLI data set (GLUE version).""" def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) warnings.warn(DEPRECATION_WARNING.format("processor"), FutureWarning) def get_example_from_tensor_dict(self, tensor_dict): ...
class_definition
7,834
9,610
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/processors/glue.py
null
10,637
class MnliMismatchedProcessor(MnliProcessor): """Processor for the MultiNLI Mismatched data set (GLUE version).""" def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) warnings.warn(DEPRECATION_WARNING.format("processor"), FutureWarning) def get_dev_examples(self, data_di...
class_definition
9,613
10,276
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/processors/glue.py
null
10,638
class ColaProcessor(DataProcessor): """Processor for the CoLA data set (GLUE version).""" def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) warnings.warn(DEPRECATION_WARNING.format("processor"), FutureWarning) def get_example_from_tensor_dict(self, tensor_dict): ...
class_definition
10,279
11,982
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/processors/glue.py
null
10,639
class Sst2Processor(DataProcessor): """Processor for the SST-2 data set (GLUE version).""" def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) warnings.warn(DEPRECATION_WARNING.format("processor"), FutureWarning) def get_example_from_tensor_dict(self, tensor_dict): ...
class_definition
11,985
13,664
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/processors/glue.py
null
10,640
class StsbProcessor(DataProcessor): """Processor for the STS-B data set (GLUE version).""" def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) warnings.warn(DEPRECATION_WARNING.format("processor"), FutureWarning) def get_example_from_tensor_dict(self, tensor_dict): ...
class_definition
13,667
15,364
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/processors/glue.py
null
10,641
class QqpProcessor(DataProcessor): """Processor for the QQP data set (GLUE version).""" def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) warnings.warn(DEPRECATION_WARNING.format("processor"), FutureWarning) def get_example_from_tensor_dict(self, tensor_dict): ...
class_definition
15,367
17,275
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/processors/glue.py
null
10,642
class QnliProcessor(DataProcessor): """Processor for the QNLI data set (GLUE version).""" def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) warnings.warn(DEPRECATION_WARNING.format("processor"), FutureWarning) def get_example_from_tensor_dict(self, tensor_dict): ...
class_definition
17,278
18,998
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/processors/glue.py
null
10,643
class RteProcessor(DataProcessor): """Processor for the RTE data set (GLUE version).""" def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) warnings.warn(DEPRECATION_WARNING.format("processor"), FutureWarning) def get_example_from_tensor_dict(self, tensor_dict): ...
class_definition
19,001
20,721
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/processors/glue.py
null
10,644
class WnliProcessor(DataProcessor): """Processor for the WNLI data set (GLUE version).""" def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) warnings.warn(DEPRECATION_WARNING.format("processor"), FutureWarning) def get_example_from_tensor_dict(self, tensor_dict): ...
class_definition
20,724
22,424
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/processors/glue.py
null
10,645
class InputExample: """ A single training/test example for simple sequence classification. Args: guid: Unique id for the example. text_a: string. The untokenized text of the first sequence. For single sequence tasks, only this sequence must be specified. text_b: (Optiona...
class_definition
947
1,795
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/processors/utils.py
null
10,646
class InputFeatures: """ A single set of features of data. Property names are the same names as the corresponding inputs to a model. Args: input_ids: Indices of input sequence tokens in the vocabulary. attention_mask: Mask to avoid performing attention on padding token indices. ...
class_definition
1,822
2,869
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/processors/utils.py
null
10,647
class DataProcessor: """Base class for data converters for sequence classification data sets.""" def get_example_from_tensor_dict(self, tensor_dict): """ Gets an example from a dict with tensorflow tensors. Args: tensor_dict: Keys and values should match the corresponding G...
class_definition
2,872
4,458
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/processors/utils.py
null
10,648
class SingleSentenceClassificationProcessor(DataProcessor): """Generic processor for a single sentence classification data set.""" def __init__(self, labels=None, examples=None, mode="classification", verbose=False): self.labels = [] if labels is None else labels self.examples = [] if examples ...
class_definition
4,461
13,828
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/data/processors/utils.py
null
10,649
class GenerationMode(ExplicitEnum): """ Possible generation modes, downstream of the [`~generation.GenerationMixin.generate`] method. """ # Non-beam methods CONTRASTIVE_SEARCH = "contrastive_search" GREEDY_SEARCH = "greedy_search" SAMPLE = "sample" ASSISTED_GENERATION = "assisted_genera...
class_definition
2,485
3,033
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/configuration_utils.py
null
10,650
class GenerationConfig(PushToHubMixin): # no-format """ Class that holds a configuration for a generation task. A `generate` call supports the following generation methods for text-decoder, text-to-text, speech-to-text, and vision-to-text models: - *greedy decoding* if `num_beams=1` and `do_sam...
class_definition
3,036
72,891
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/configuration_utils.py
null
10,651
class BaseWatermarkingConfig(ABC): """Generic watermarking config""" @classmethod def from_dict(cls, config_dict, **kwargs): """ Constructs a BaseWatermarkingConfig instance from a dictionary of parameters. Args: config_dict (Dict[str, Any]): Dictionary containing confi...
class_definition
72,905
75,561
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/configuration_utils.py
null
10,652
class WatermarkingConfig(BaseWatermarkingConfig): """ Class that holds arguments for watermark generation and should be passed into `GenerationConfig` during `generate`. See [this paper](https://arxiv.org/abs/2306.04634) for more details on the arguments. Accepts the following keys: - greenlist...
class_definition
75,575
78,980
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/configuration_utils.py
null
10,653
class SynthIDTextWatermarkingConfig(BaseWatermarkingConfig): """ Class that holds arguments for watermark generation and should be passed into `GenerationConfig` during `generate`. See [this paper](https://www.nature.com/articles/s41586-024-08025-4) for more details on the arguments. Args: ngra...
class_definition
78,994
82,722
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/configuration_utils.py
null
10,654
class CompileConfig(object): """ Class that holds arguments relative to `torch.compile` behavior, when using automatic compilation in `generate`. See [`torch.compile`](https://pytorch.org/docs/stable/generated/torch.compile.html) for more details on the arguments. Args: fullgraph (`bool`, *opti...
class_definition
82,736
84,724
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/configuration_utils.py
null
10,655
class FlaxGreedySearchOutput(ModelOutput): """ Flax Base class for outputs of decoder-only generation models using greedy search. Args: sequences (`jnp.ndarray` of shape `(batch_size, max_length)`): The generated sequences. """ sequences: jnp.ndarray = None
class_definition
1,651
1,951
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/flax_utils.py
null
10,656
class FlaxSampleOutput(ModelOutput): """ Flax Base class for outputs of decoder-only generation models using sampling. Args: sequences (`jnp.ndarray` of shape `(batch_size, max_length)`): The generated sequences. """ sequences: jnp.ndarray = None
class_definition
1,977
2,266
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/flax_utils.py
null
10,657
class FlaxBeamSearchOutput(ModelOutput): """ Flax Base class for outputs of decoder-only generation models using greedy search. Args: sequences (`jnp.ndarray` of shape `(batch_size, max_length)`): The generated sequences. scores (`jnp.ndarray` of shape `(batch_size,)`): ...
class_definition
2,292
2,749
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/flax_utils.py
null
10,658
class GreedyState: cur_len: jnp.ndarray sequences: jnp.ndarray running_token: jnp.ndarray is_sent_finished: jnp.ndarray model_kwargs: Dict[str, jnp.ndarray]
class_definition
2,775
2,951
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/flax_utils.py
null
10,659
class SampleState: cur_len: jnp.ndarray sequences: jnp.ndarray running_token: jnp.ndarray is_sent_finished: jnp.ndarray prng_key: jnp.ndarray model_kwargs: Dict[str, jnp.ndarray]
class_definition
2,977
3,179
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/flax_utils.py
null
10,660
class BeamSearchState: cur_len: jnp.ndarray running_sequences: jnp.ndarray running_scores: jnp.ndarray sequences: jnp.ndarray scores: jnp.ndarray is_sent_finished: jnp.ndarray model_kwargs: Dict[str, jnp.ndarray]
class_definition
3,205
3,445
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/flax_utils.py
null
10,661
class FlaxGenerationMixin: """ A class containing all functions for auto-regressive text generation, to be used as a mixin in [`FlaxPreTrainedModel`]. The class exposes [`~generation.FlaxGenerationMixin.generate`], which can be used for: - *greedy decoding* by calling [`~generation.FlaxGene...
class_definition
3,448
50,468
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/flax_utils.py
null
10,662
class LogitsProcessor: """Abstract base class for all logit processors that can be applied during generation.""" @add_start_docstrings(LOGITS_PROCESSOR_INPUTS_DOCSTRING) def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor) -> torch.FloatTensor: raise NotImplementedError( ...
class_definition
1,564
1,992
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,663
class LogitsProcessorList(list): """ This class can be used to create a list of [`LogitsProcessor`] to subsequently process a `scores` input tensor. This class inherits from list and adds a specific *__call__* method to apply each [`LogitsProcessor`] to the inputs. """ def __call__(self, input_...
class_definition
1,995
3,838
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,664
class MinLengthLogitsProcessor(LogitsProcessor): r""" [`LogitsProcessor`] enforcing a min-length by setting EOS probability to 0. Note that, for decoder-only models like most LLMs, the length includes the prompt. Args: min_length (`int`): The minimum length below which the score of ...
class_definition
3,841
6,577
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,665
class MinNewTokensLengthLogitsProcessor(LogitsProcessor): r""" [`LogitsProcessor`] enforcing a min-length of new tokens by setting EOS (End-Of-Sequence) token probability to 0. Contrarily to [`MinLengthLogitsProcessor`], this processor ignores the prompt. Args: prompt_length_to_skip (`int`): ...
class_definition
6,580
9,664
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,666
class TemperatureLogitsWarper(LogitsProcessor): r""" [`LogitsProcessor`] for temperature (exponential scaling output probability distribution), which effectively means that it can control the randomness of the predicted tokens. Often used together with [`TopPLogitsWarper`] and [`TopKLogitsWarper`]. ...
class_definition
9,667
12,690
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,667
class RepetitionPenaltyLogitsProcessor(LogitsProcessor): r""" [`LogitsProcessor`] that prevents the repetition of previous tokens through a penalty. This penalty is applied at most once per token. Note that, for decoder-only models like most LLMs, the considered tokens include the prompt. In the origin...
class_definition
12,693
15,346
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,668
class EncoderRepetitionPenaltyLogitsProcessor(LogitsProcessor): r""" [`LogitsProcessor`] that works similarly to [`RepetitionPenaltyLogitsProcessor`], but with an *inverse* penalty that is applied to the tokens present in the prompt. In other words, a penalty above 1.0 increases the odds of selecting to...
class_definition
15,349
18,067
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,669
class TopPLogitsWarper(LogitsProcessor): """ [`LogitsProcessor`] that performs top-p, i.e. restricting to top tokens summing to prob_cut_off <= prob_cut_off. Often used together with [`TemperatureLogitsWarper`] and [`TopKLogitsWarper`]. Args: top_p (`float`): If set to < 1, only the...
class_definition
18,070
21,221
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,670
class TopKLogitsWarper(LogitsProcessor): r""" [`LogitsProcessor`] that performs top-k, i.e. restricting to the k highest probability elements. Often used together with [`TemperatureLogitsWarper`] and [`TopPLogitsWarper`]. Args: top_k (`int`): The number of highest probability vocabu...
class_definition
21,224
23,672
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,671
class MinPLogitsWarper(LogitsProcessor): """ [`LogitsProcessor`] that performs min-p, i.e. keeps all tokens that are above a minimum probability, scaled by the probability of the most likely token. As a result, the filter becomes more agressive in the presence of high-probability tokens, which is a sign...
class_definition
23,675
27,627
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,672
class TypicalLogitsWarper(LogitsProcessor): r""" [`LogitsProcessor`] that performs typical decoding. Inspired on how humans use language, it prioritizes tokens whose log probability is close to the entropy of the token probability distribution. This means that the most likely tokens may be discarded in ...
class_definition
27,630
31,796
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,673
class EpsilonLogitsWarper(LogitsProcessor): r""" [`LogitsProcessor`] that performs epsilon-sampling, i.e. restricting to tokens with `prob >= epsilon`. Takes the largest min_tokens_to_keep tokens if no tokens satisfy this constraint. See [Truncation Sampling as Language Model Desmoothing](https://arxiv....
class_definition
31,799
35,054
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,674
class EtaLogitsWarper(LogitsProcessor): r""" [`LogitsProcessor`] that performs eta-sampling, a technique to filter out tokens with probabilities below a dynamic cutoff value, `eta`, which is calculated based on a combination of the hyperparameter `epsilon` and the entropy of the token probabilities, i.e...
class_definition
35,057
39,639
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,675
class NoRepeatNGramLogitsProcessor(LogitsProcessor): r""" N-grams are groups of "n" consecutive words, characters, or tokens taken from a sequence of text. Given the sentence: "She runs fast", the bi-grams (n=2) would be ("she", "runs") and ("runs", "fast"). In text generation, avoiding repetitions of w...
class_definition
42,614
45,492
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,676
class EncoderNoRepeatNGramLogitsProcessor(LogitsProcessor): r""" [`LogitsProcessor`] that works similarly to [`NoRepeatNGramLogitsProcessor`], but applied exclusively to prevent the repetition of n-grams present in the prompt. It was designed to promote chattiness in a language model, by preventing the...
class_definition
45,495
48,510
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,677
class SequenceBiasLogitsProcessor(LogitsProcessor): """ [`LogitsProcessor`] that applies an additive bias on sequences. The bias is applied to the last token of a sequence when the next generated token can complete it. Consequently, to take the most of biasing sequences with more than one token, conside...
class_definition
48,513
57,483
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,678
class NoBadWordsLogitsProcessor(SequenceBiasLogitsProcessor): """ [`LogitsProcessor`] that enforces that specified sequences will never be selected. <Tip> In order to get the token ids of the words that should not appear in the generated text, make sure to set `add_prefix_space=True` when initiali...
class_definition
57,486
61,585
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,679
class PrefixConstrainedLogitsProcessor(LogitsProcessor): r""" [`LogitsProcessor`] that enforces constrained generation and is useful for prefix-conditioned constrained generation. See [Autoregressive Entity Retrieval](https://arxiv.org/abs/2010.00904) for more information. Args: prefix_allowed_...
class_definition
61,588
65,178
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,680
class HammingDiversityLogitsProcessor(LogitsProcessor): r""" [`LogitsProcessor`] that enforces diverse beam search. Note that this logits processor is only effective for [`PreTrainedModel.group_beam_search`]. See [Diverse Beam Search: Decoding Diverse Solutions from Neural Sequence Models](https://arxi...
class_definition
65,181
72,374
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,681
class ForcedBOSTokenLogitsProcessor(LogitsProcessor): r""" [`LogitsProcessor`] that enforces the specified token as the first generated token. Used with encoder-decoder models. Args: bos_token_id (`int`): The id of the token to force as the first generated token. Examples: ...
class_definition
72,377
74,114
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,682
class ForcedEOSTokenLogitsProcessor(LogitsProcessor): r""" [`LogitsProcessor`] that enforces the specified token as the last generated token when `max_length` is reached. Args: max_length (`int`): The maximum length of the sequence to be generated. eos_token_id (`Union[int, List...
class_definition
74,117
76,502
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,683
class InfNanRemoveLogitsProcessor(LogitsProcessor): r""" [`LogitsProcessor`] that removes all `nan` and `inf` values to avoid the generation method to fail. Note that using the logits processor should only be used if necessary since it can slow down the generation method. This logits processor has no `...
class_definition
76,505
77,517
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,684
class ExponentialDecayLengthPenalty(LogitsProcessor): r""" [`LogitsProcessor`] that exponentially increases the score of the `eos_token_id` after `start_index` has been reached. This allows generating shorter sequences without having a hard cutoff, allowing the `eos_token` to be predicted in a meaningfu...
class_definition
77,520
82,275
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,685
class LogitNormalization(LogitsProcessor): r""" [`LogitsProcessor`] for normalizing the scores using log-softmax. It's important to normalize the scores during beam search, after applying the logits processors or warpers, since the search algorithm used in this library doesn't do it (it only does it bef...
class_definition
82,278
84,053
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,686
class SuppressTokensAtBeginLogitsProcessor(LogitsProcessor): r""" [`SuppressTokensAtBeginLogitsProcessor`] supresses a list of tokens as soon as the `generate` function starts generating using `begin_index` tokens. This should ensure that the tokens defined by `begin_suppress_tokens` are not generated a...
class_definition
84,056
86,621
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,687
class SuppressTokensLogitsProcessor(LogitsProcessor): r""" This processor can be used to suppress a list of tokens. The processor will set their log probs to `-inf` so that they are not generated. Originally created for [Whisper](https://huggingface.co/docs/transformers/model_doc/whisper). Examples...
class_definition
86,624
88,563
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,688
class WhisperTimeStampLogitsProcessor(LogitsProcessor): r""" [`LogitsProcessor`] that modifies the logits for the generation of timestamps in the transcription. When the input tokens are at a specific threshold, the processor sets the scores to negative infinity. The processor makes sure that timestamp...
class_definition
88,566
96,050
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,689
class WhisperNoSpeechDetection(LogitsProcessor): r"""This processor can be used to detect silence when using Whisper. It should take as input unprocessed logits to follow the original implementation""" def __init__(self, no_speech_token: int, begin_index: int, scores_is_logprobs: bool = False): self.no...
class_definition
96,053
98,245
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,690
class ClassifierFreeGuidanceLogitsProcessor(LogitsProcessor): r""" [`LogitsProcessor`] for classifier free guidance (CFG). The scores are split over the batch dimension, where the first half correspond to the conditional logits (predicted from the input prompt) and the second half correspond to the unco...
class_definition
98,248
101,292
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,691
class AlternatingCodebooksLogitsProcessor(LogitsProcessor): r""" [`LogitsProcessor`] enforcing alternated generation between the two codebooks of Bark. <Tip warning={true}> This logits processor is exclusively compatible with [Bark](https://huggingface.co/docs/transformers/en/model_doc/bark)'s fin...
class_definition
101,295
103,114
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,692
class UnbatchedClassifierFreeGuidanceLogitsProcessor(LogitsProcessor): r""" Logits processor for Classifier-Free Guidance (CFG). The processors computes a weighted average across scores from prompt conditional and prompt unconditional (or negative) logits, parameterized by the `guidance_scale`. The unco...
class_definition
103,117
108,999
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,693
class BarkEosPrioritizerLogitsProcessor(LogitsProcessor): r"""This processor ensures that the EOS token is selected if its probability is greater than the `min_eos_p`. <Tip warning={true}> This logits processor is exclusively compatible with [Bark](https://huggingface.co/docs/transformers/en/model_doc...
class_definition
109,002
111,131
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,694
class WatermarkLogitsProcessor(LogitsProcessor): r""" Logits processor for watermarking generated text. The processor modifies model output scores by adding a small bias to randomized set of "green" tokens before generating the next token. "Green" tokens selection process depends on the `seeding_scheme`...
class_definition
111,134
118,503
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,695
class SynthIDTextWatermarkState: """SynthID watermarking state.""" def __init__( self, batch_size: int, ngram_len: int, context_history_size: int, device: torch.device, ): """Initializes the state. Args: batch_size (`int`): Batch size. ...
class_definition
118,506
119,348
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,696
class SynthIDTextWatermarkLogitsProcessor(LogitsProcessor): r""" Logits processor that implements watermarking techniques for text generation models. This class facilitates the application of SynthID text watermarking, a method for embedding imperceptible signals into generated text to aid in detecting ...
class_definition
119,351
137,792
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/logits_process.py
null
10,697
class TFLogitsProcessor: """Abstract base class for all logit processors that can be applied during generation.""" @add_start_docstrings(TF_LOGITS_PROCESSOR_INPUTS_DOCSTRING) def __call__(self, input_ids: tf.Tensor, scores: tf.Tensor, cur_len: int) -> tf.Tensor: """TF method for processing logits."...
class_definition
2,011
2,482
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/tf_logits_process.py
null
10,698
class TFLogitsWarper: """Abstract base class for all logit warpers that can be applied during generation with multinomial sampling.""" @add_start_docstrings(TF_LOGITS_PROCESSOR_INPUTS_DOCSTRING) def __call__(self, input_ids: tf.Tensor, scores: tf.Tensor, cur_len: int) -> tf.Tensor: """TF method for...
class_definition
2,485
2,973
0
/Users/nielsrogge/Documents/python_projecten/transformers/src/transformers/generation/tf_logits_process.py
null
10,699