id int64 0 328k | repository_name stringlengths 7 58 | file_path stringlengths 9 302 | class_name stringlengths 5 256 | human_written_code stringlengths 16 2.16M | class_skeleton stringlengths 18 1.49M ⌀ | total_program_units int64 1 1.76k | total_doc_str int64 0 771 | AvgCountLine float64 0 7.89k | AvgCountLineBlank float64 0 297 | AvgCountLineCode float64 0 7.89k | AvgCountLineComment float64 0 7.89k | AvgCyclomatic float64 0 130 | CommentToCodeRatio float64 0 168 | CountClassBase float64 0 40 | CountClassCoupled float64 0 583 | CountClassCoupledModified float64 0 575 | CountClassDerived float64 0 5.35k | CountDeclInstanceMethod float64 0 529 | CountDeclInstanceVariable float64 0 296 | CountDeclMethod float64 0 599 | CountDeclMethodAll float64 0 1.12k | CountLine float64 1 40.4k | CountLineBlank float64 0 8.16k | CountLineCode float64 1 25.7k | CountLineCodeDecl float64 1 8.15k | CountLineCodeExe float64 0 24.2k | CountLineComment float64 0 16.5k | CountStmt float64 1 9.71k | CountStmtDecl float64 1 8.15k | CountStmtExe float64 0 9.69k | MaxCyclomatic float64 0 759 | MaxInheritanceTree float64 0 16 | MaxNesting float64 0 34 | SumCyclomatic float64 0 2.9k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
300 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/beam_constraints.py | transformers.generation.beam_constraints.DisjunctiveConstraint | class DisjunctiveConstraint(Constraint):
"""
A special [`Constraint`] that is fulfilled by fulfilling just one of several constraints.
Args:
nested_token_ids (`list[list[int]]`):
A list of words, where each word is a list of ids. This constraint is fulfilled by generating just one from
... | class DisjunctiveConstraint(Constraint):
'''
A special [`Constraint`] that is fulfilled by fulfilling just one of several constraints.
Args:
nested_token_ids (`list[list[int]]`):
A list of words, where each word is a list of ids. This constraint is fulfilled by generating just one from
... | 8 | 1 | 10 | 2 | 8 | 0 | 2 | 0.13 | 1 | 6 | 1 | 0 | 7 | 5 | 7 | 35 | 88 | 20 | 60 | 19 | 52 | 8 | 52 | 19 | 44 | 4 | 5 | 1 | 16 |
301 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/beam_constraints.py | transformers.generation.beam_constraints.DisjunctiveTrie | class DisjunctiveTrie:
def __init__(self, nested_token_ids: list[list[int]], no_subsets=True):
"""
A helper class that builds a trie with the words represented in `nested_token_ids`.
"""
self.max_height = max([len(one) for one in nested_token_ids])
root = {}
for toke... | class DisjunctiveTrie:
def __init__(self, nested_token_ids: list[list[int]], no_subsets=True):
'''
A helper class that builds a trie with the words represented in `nested_token_ids`.
'''
pass
def next_tokens(self, current_seq):
'''
The next possible tokens that ... | 6 | 3 | 10 | 2 | 7 | 2 | 2 | 0.26 | 0 | 4 | 0 | 0 | 5 | 2 | 5 | 5 | 55 | 12 | 34 | 18 | 28 | 9 | 30 | 18 | 24 | 5 | 0 | 3 | 11 |
302 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/beam_constraints.py | transformers.generation.beam_constraints.PhrasalConstraint | class PhrasalConstraint(Constraint):
"""
[`Constraint`] enforcing that an ordered sequence of tokens is included in the output.
Args:
token_ids (`list[int]`):
The id of the token that must be generated by the output.
"""
def __init__(self, token_ids: list[int]):
super(C... | class PhrasalConstraint(Constraint):
'''
[`Constraint`] enforcing that an ordered sequence of tokens is included in the output.
Args:
token_ids (`list[int]`):
The id of the token that must be generated by the output.
'''
def __init__(self, token_ids: list[int]):
pass
... | 8 | 1 | 8 | 1 | 7 | 0 | 2 | 0.16 | 1 | 5 | 0 | 0 | 7 | 4 | 7 | 35 | 73 | 17 | 49 | 16 | 41 | 8 | 48 | 16 | 40 | 4 | 5 | 2 | 16 |
303 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/beam_search.py | transformers.generation.beam_search.BeamHypotheses | import torch
from typing import Optional, Union
class BeamHypotheses:
def __init__(self, num_beams: int, length_penalty: float, early_stopping: bool, max_length: Optional[int]=None):
"""
Initialize n-best list of hypotheses.
"""
logger.warning_once('`BeamHypotheses` is deprecated a... |
class BeamHypotheses:
def __init__(self, num_beams: int, length_penalty: float, early_stopping: bool, max_length: Optional[int]=None):
'''
Initialize n-best list of hypotheses.
'''
pass
def __len__(self):
'''
Number of hypotheses in the list.
'''
... | 5 | 4 | 20 | 1 | 13 | 6 | 3 | 0.43 | 0 | 5 | 0 | 0 | 4 | 6 | 4 | 4 | 84 | 7 | 54 | 21 | 43 | 23 | 38 | 15 | 33 | 6 | 0 | 3 | 13 |
304 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/beam_search.py | transformers.generation.beam_search.BeamScorer | from abc import ABC, abstractmethod
from ..utils import add_start_docstrings, logging
import torch
class BeamScorer(ABC):
"""
Abstract base class for all beam scorers that are used for [`~PreTrainedModel.beam_search`] and
[`~PreTrainedModel.beam_sample`].
"""
@abstractmethod
@add_start_docstri... |
class BeamScorer(ABC):
'''
Abstract base class for all beam scorers that are used for [`~PreTrainedModel.beam_search`] and
[`~PreTrainedModel.beam_sample`].
'''
@abstractmethod
@add_start_docstrings(PROCESS_INPUTS_DOCSTRING)
def process(self, input_ids: torch.LongTensor, next_scores: torch.... | 7 | 1 | 10 | 0 | 10 | 0 | 1 | 0.17 | 1 | 3 | 0 | 2 | 2 | 0 | 2 | 22 | 30 | 2 | 24 | 20 | 2 | 4 | 5 | 3 | 2 | 1 | 4 | 0 | 2 |
305 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/beam_search.py | transformers.generation.beam_search.BeamSearchScorer | from collections import UserDict
from typing import Optional, Union
import torch
class BeamSearchScorer(BeamScorer):
"""
[`BeamScorer`] implementing standard beam search decoding.
Adapted in part from [Facebook's XLM beam search
code](https://github.com/facebookresearch/XLM/blob/9e6f6814d17be4fe5b15f2... |
class BeamSearchScorer(BeamScorer):
'''
[`BeamScorer`] implementing standard beam search decoding.
Adapted in part from [Facebook's XLM beam search
code](https://github.com/facebookresearch/XLM/blob/9e6f6814d17be4fe5b15f2e6c43eb2b2d76daeb4/src/model/transformer.py#L529).
Reference for the diverse b... | 6 | 1 | 63 | 7 | 50 | 6 | 9 | 0.28 | 1 | 11 | 1 | 0 | 4 | 10 | 4 | 26 | 294 | 36 | 201 | 88 | 163 | 57 | 118 | 54 | 113 | 17 | 5 | 4 | 36 |
306 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/beam_search.py | transformers.generation.beam_search.ConstrainedBeamSearchScorer | from collections import UserDict
import numpy as np
from .beam_constraints import Constraint, ConstraintListState
from typing import Optional, Union
import torch
class ConstrainedBeamSearchScorer(BeamScorer):
"""
[`BeamScorer`] implementing constrained beam search decoding.
Args:
batch_size (`int... |
class ConstrainedBeamSearchScorer(BeamScorer):
'''
[`BeamScorer`] implementing constrained beam search decoding.
Args:
batch_size (`int`):
Batch Size of `input_ids` for which standard beam search decoding is run in parallel.
num_beams (`int`):
Number of beams for be... | 9 | 2 | 66 | 10 | 44 | 13 | 8 | 0.39 | 1 | 13 | 3 | 0 | 7 | 11 | 7 | 29 | 509 | 77 | 312 | 137 | 261 | 122 | 206 | 92 | 198 | 22 | 5 | 5 | 54 |
307 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/candidate_generator.py | transformers.generation.candidate_generator.AssistedCandidateGenerator | import copy
from .logits_process import LogitsProcessorList, MinLengthLogitsProcessor, SuppressTokensLogitsProcessor
from typing import TYPE_CHECKING, Any, Optional
from ..utils import is_sklearn_available
import numpy as np
import torch.nn as nn
import torch
class AssistedCandidateGenerator(CandidateGenerator):
"... |
class AssistedCandidateGenerator(CandidateGenerator):
'''
`CandidateGenerator` class to be used for assisted generation and speculative decoding. This class generates
candidates through the use of a smaller model. Read the following blog post for more information:
https://huggingface.co/blog/assisted-g... | 8 | 7 | 32 | 3 | 21 | 8 | 4 | 0.49 | 1 | 8 | 2 | 2 | 7 | 10 | 7 | 9 | 250 | 28 | 150 | 52 | 134 | 74 | 98 | 44 | 90 | 15 | 1 | 2 | 30 |
308 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/candidate_generator.py | transformers.generation.candidate_generator.AssistedCandidateGeneratorDifferentTokenizers | import torch.nn as nn
import numpy as np
import torch
from typing import TYPE_CHECKING, Any, Optional
class AssistedCandidateGeneratorDifferentTokenizers(AssistedCandidateGenerator):
"""
`CandidateGenerator` class to be used for Universal Assisted Generation (UAD): assisted generation with different tokenizers... |
class AssistedCandidateGeneratorDifferentTokenizers(AssistedCandidateGenerator):
'''
`CandidateGenerator` class to be used for Universal Assisted Generation (UAD): assisted generation with different tokenizers
for the assistant and main models. This class generates candidates through the use of a smaller
... | 12 | 8 | 30 | 4 | 19 | 6 | 3 | 0.51 | 1 | 6 | 0 | 0 | 5 | 6 | 8 | 17 | 280 | 45 | 156 | 80 | 127 | 79 | 114 | 60 | 105 | 7 | 2 | 4 | 25 |
309 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/candidate_generator.py | transformers.generation.candidate_generator.CandidateGenerator | import torch.nn as nn
import torch
from typing import TYPE_CHECKING, Any, Optional
class CandidateGenerator:
"""Abstract base class for all candidate generators that can be applied during assisted generation."""
def get_candidates(self, input_ids: torch.LongTensor) -> tuple[torch.LongTensor, Optional[torch.Fl... |
class CandidateGenerator:
'''Abstract base class for all candidate generators that can be applied during assisted generation.'''
def get_candidates(self, input_ids: torch.LongTensor) -> tuple[torch.LongTensor, Optional[torch.FloatTensor]]:
'''
Fetches the candidates to be tried for the current... | 3 | 3 | 17 | 2 | 5 | 11 | 1 | 2.2 | 0 | 2 | 0 | 2 | 2 | 0 | 2 | 2 | 37 | 5 | 10 | 3 | 7 | 22 | 5 | 3 | 2 | 1 | 0 | 0 | 2 |
310 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/candidate_generator.py | transformers.generation.candidate_generator.EarlyExitCandidateGenerator | from typing import TYPE_CHECKING, Any, Optional
import torch
import torch.nn as nn
class EarlyExitCandidateGenerator(AssistedCandidateGenerator):
"""
`CandidateGenerator` class to be used for assisted generation and speculative decoding. This class generates
candidates through the use of **the model itself... |
class EarlyExitCandidateGenerator(AssistedCandidateGenerator):
'''
`CandidateGenerator` class to be used for assisted generation and speculative decoding. This class generates
candidates through the use of **the model itself**, exiting early. Can only be used with models that support early
exit, e.g., ... | 3 | 1 | 15 | 0 | 13 | 2 | 1 | 0.89 | 1 | 2 | 0 | 0 | 2 | 1 | 2 | 11 | 54 | 3 | 27 | 15 | 16 | 24 | 12 | 7 | 9 | 1 | 2 | 0 | 2 |
311 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/candidate_generator.py | transformers.generation.candidate_generator.PromptLookupCandidateGenerator | import torch
from typing import TYPE_CHECKING, Any, Optional
from ..pytorch_utils import isin_mps_friendly
import torch.nn as nn
class PromptLookupCandidateGenerator(CandidateGenerator):
"""
`CandidateGenerator` class to be used for prompt lookup generation. This class generates candidates by looking up
li... |
class PromptLookupCandidateGenerator(CandidateGenerator):
'''
`CandidateGenerator` class to be used for prompt lookup generation. This class generates candidates by looking up
likely continuations in the provided prompt (input_ids) itself.
Read the following blog post for more information: https://gith... | 4 | 3 | 31 | 5 | 15 | 11 | 4 | 0.96 | 1 | 4 | 0 | 0 | 3 | 4 | 3 | 5 | 110 | 18 | 47 | 29 | 37 | 45 | 41 | 23 | 37 | 8 | 1 | 4 | 12 |
312 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/configuration_utils.py | transformers.generation.configuration_utils.BaseWatermarkingConfig | from abc import ABC, abstractmethod
import copy
from dataclasses import dataclass, is_dataclass
from typing import TYPE_CHECKING, Any, Callable, Optional, Union
import json
import os
@dataclass
class BaseWatermarkingConfig(ABC):
"""Generic watermarking config"""
@classmethod
def from_dict(cls, config_dict... | @dataclass
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 contain... | 14 | 6 | 7 | 1 | 3 | 3 | 2 | 0.83 | 1 | 3 | 0 | 2 | 8 | 1 | 9 | 29 | 80 | 16 | 35 | 23 | 24 | 29 | 34 | 18 | 24 | 4 | 4 | 2 | 15 |
313 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/configuration_utils.py | transformers.generation.configuration_utils.CompileConfig | from typing import TYPE_CHECKING, Any, Callable, Optional, Union
from dataclasses import dataclass, is_dataclass
import copy
@dataclass
class CompileConfig:
"""
Class that holds arguments relative to `torch.compile` behavior, when using automatic compilation in `generate`.
See [`torch.compile`](https://pyt... | @dataclass
class CompileConfig:
'''
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`, *op... | 3 | 2 | 3 | 0 | 2 | 1 | 1 | 3.44 | 0 | 2 | 0 | 0 | 1 | 0 | 1 | 1 | 47 | 7 | 9 | 8 | 7 | 31 | 9 | 8 | 7 | 1 | 0 | 0 | 1 |
314 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/configuration_utils.py | transformers.generation.configuration_utils.GenerationConfig | from ..configuration_utils import PretrainedConfig
import copy
from typing import TYPE_CHECKING, Any, Callable, Optional, Union
from ..utils import GENERATION_CONFIG_NAME, ExplicitEnum, PushToHubMixin, cached_file, download_url, extract_commit_hash, is_remote_url, is_torch_available, logging
from dataclasses import dat... |
class GenerationConfig(PushToHubMixin):
'''
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_sample=False`
... | 24 | 13 | 49 | 5 | 32 | 12 | 7 | 0.82 | 1 | 21 | 5 | 4 | 13 | 69 | 17 | 17 | 1,230 | 141 | 599 | 173 | 559 | 493 | 378 | 148 | 358 | 47 | 1 | 3 | 126 |
315 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/configuration_utils.py | transformers.generation.configuration_utils.GenerationMode | from ..utils import GENERATION_CONFIG_NAME, ExplicitEnum, PushToHubMixin, cached_file, download_url, extract_commit_hash, is_remote_url, is_torch_available, logging
class GenerationMode(ExplicitEnum):
"""
Possible generation modes, downstream of the [`~generation.GenerationMixin.generate`] method.
"""
... |
class GenerationMode(ExplicitEnum):
'''
Possible generation modes, downstream of the [`~generation.GenerationMixin.generate`] method.
'''
pass | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.5 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 16 | 1 | 10 | 10 | 9 | 5 | 10 | 10 | 9 | 0 | 1 | 0 | 0 |
316 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/configuration_utils.py | transformers.generation.configuration_utils.SynthIDTextWatermarkingConfig | from dataclasses import dataclass, is_dataclass
@dataclass
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... | @dataclass
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:
... | 5 | 1 | 14 | 0 | 14 | 0 | 1 | 0.88 | 1 | 4 | 1 | 0 | 3 | 7 | 3 | 32 | 87 | 8 | 42 | 21 | 29 | 37 | 15 | 12 | 11 | 2 | 5 | 1 | 4 |
317 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/configuration_utils.py | transformers.generation.configuration_utils.WatermarkingConfig | from typing import TYPE_CHECKING, Any, Callable, Optional, Union
from dataclasses import dataclass, is_dataclass
@dataclass
class WatermarkingConfig(BaseWatermarkingConfig):
"""
Class that holds arguments for watermark generation and should be passed into `GenerationConfig` during `generate`.
See [this pap... | @dataclass
class WatermarkingConfig(BaseWatermarkingConfig):
'''
Class that holds arguments for watermark generation and should be passed into `GenerationConfig` during `generate`.
See [this paper](https://huggingface.co/papers/2306.04634) for more details on the arguments.
Accepts the following keys:
... | 5 | 1 | 17 | 0 | 17 | 0 | 2 | 0.34 | 1 | 5 | 1 | 0 | 3 | 5 | 3 | 32 | 75 | 4 | 53 | 17 | 42 | 18 | 17 | 10 | 13 | 4 | 5 | 1 | 6 |
318 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.AlternatingCodebooksLogitsProcessor | import torch
class AlternatingCodebooksLogitsProcessor(LogitsProcessor):
"""
[`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_do... |
class AlternatingCodebooksLogitsProcessor(LogitsProcessor):
'''
[`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 fine ... | 3 | 1 | 11 | 2 | 8 | 1 | 2 | 0.94 | 1 | 3 | 0 | 0 | 2 | 3 | 2 | 3 | 43 | 10 | 17 | 9 | 14 | 16 | 16 | 9 | 13 | 2 | 1 | 1 | 4 |
319 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.BarkEosPrioritizerLogitsProcessor | from ..utils import add_start_docstrings
from typing import TYPE_CHECKING, Callable, Optional, Union
import torch
class BarkEosPrioritizerLogitsProcessor(LogitsProcessor):
"""This processor ensures that the EOS token is selected if its probability is greater than the `min_eos_p`.
<Tip warning={true}>
Thi... |
class BarkEosPrioritizerLogitsProcessor(LogitsProcessor):
'''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/b... | 4 | 1 | 13 | 2 | 11 | 1 | 4 | 0.52 | 1 | 5 | 0 | 0 | 2 | 2 | 2 | 3 | 45 | 10 | 23 | 10 | 19 | 12 | 22 | 9 | 19 | 5 | 1 | 2 | 7 |
320 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.ClassifierFreeGuidanceLogitsProcessor | from ..utils import add_start_docstrings
import torch
class ClassifierFreeGuidanceLogitsProcessor(LogitsProcessor):
"""
[`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 ... |
class ClassifierFreeGuidanceLogitsProcessor(LogitsProcessor):
'''
[`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... | 4 | 1 | 11 | 0 | 10 | 1 | 2 | 1.43 | 1 | 1 | 0 | 0 | 2 | 1 | 2 | 3 | 62 | 11 | 21 | 8 | 17 | 30 | 12 | 7 | 9 | 2 | 1 | 1 | 4 |
321 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.EncoderNoRepeatNGramLogitsProcessor | from ..utils import add_start_docstrings
import torch
class EncoderNoRepeatNGramLogitsProcessor(LogitsProcessor):
"""
[`LogitsProcessor`] that works similarly to [`NoRepeatNGramLogitsProcessor`], but applied exclusively to prevent
the repetition of n-grams present in the prompt.
It was designed to pro... |
class EncoderNoRepeatNGramLogitsProcessor(LogitsProcessor):
'''
[`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 ... | 4 | 1 | 14 | 1 | 12 | 1 | 3 | 1.12 | 1 | 5 | 0 | 0 | 2 | 3 | 2 | 3 | 67 | 12 | 26 | 13 | 22 | 29 | 18 | 12 | 15 | 3 | 1 | 1 | 5 |
322 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.EncoderRepetitionPenaltyLogitsProcessor | from ..utils import add_start_docstrings
import torch
class EncoderRepetitionPenaltyLogitsProcessor(LogitsProcessor):
"""
[`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 pe... |
class EncoderRepetitionPenaltyLogitsProcessor(LogitsProcessor):
'''
[`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... | 4 | 1 | 7 | 2 | 5 | 1 | 2 | 2.42 | 1 | 2 | 0 | 0 | 2 | 2 | 2 | 3 | 53 | 12 | 12 | 8 | 8 | 29 | 11 | 7 | 8 | 2 | 1 | 1 | 3 |
323 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.EpsilonLogitsWarper | from ..utils import add_start_docstrings
import torch
class EpsilonLogitsWarper(LogitsProcessor):
"""
[`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 Samp... |
class EpsilonLogitsWarper(LogitsProcessor):
'''
[`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://huggin... | 4 | 1 | 13 | 2 | 10 | 2 | 2 | 1.67 | 1 | 3 | 0 | 0 | 2 | 3 | 2 | 3 | 67 | 12 | 21 | 11 | 17 | 35 | 18 | 10 | 15 | 3 | 1 | 1 | 4 |
324 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.EtaLogitsWarper | from ..utils import add_start_docstrings
import torch
class EtaLogitsWarper(LogitsProcessor):
"""
[`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 `epsilo... |
class EtaLogitsWarper(LogitsProcessor):
'''
[`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... | 4 | 1 | 14 | 2 | 12 | 1 | 2 | 1.8 | 1 | 5 | 0 | 0 | 2 | 3 | 2 | 3 | 82 | 13 | 25 | 15 | 19 | 45 | 20 | 12 | 17 | 3 | 1 | 1 | 4 |
325 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.ExponentialDecayLengthPenalty | from ..utils import add_start_docstrings
from typing import TYPE_CHECKING, Callable, Optional, Union
import torch
class ExponentialDecayLengthPenalty(LogitsProcessor):
"""
[`LogitsProcessor`] that exponentially increases the score of the `eos_token_id` after `start_index` has been
reached. This allows gene... |
class ExponentialDecayLengthPenalty(LogitsProcessor):
'''
[`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... | 4 | 1 | 15 | 1 | 13 | 1 | 3 | 2.11 | 1 | 4 | 0 | 0 | 2 | 3 | 2 | 3 | 99 | 12 | 28 | 17 | 19 | 59 | 22 | 11 | 19 | 4 | 1 | 2 | 6 |
326 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.ForcedBOSTokenLogitsProcessor | import torch
from ..utils import add_start_docstrings
import math
class ForcedBOSTokenLogitsProcessor(LogitsProcessor):
"""
[`LogitsProcessor`] that enforces the specified token as the first generated token. Used with encoder-decoder
models.
Args:
bos_token_id (`int`):
The id of th... |
class ForcedBOSTokenLogitsProcessor(LogitsProcessor):
'''
[`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:
``... | 4 | 1 | 5 | 0 | 5 | 0 | 2 | 2.09 | 1 | 1 | 0 | 0 | 2 | 1 | 2 | 3 | 43 | 9 | 11 | 7 | 7 | 23 | 10 | 6 | 7 | 2 | 1 | 1 | 3 |
327 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.ForcedEOSTokenLogitsProcessor | from ..utils import add_start_docstrings
from typing import TYPE_CHECKING, Callable, Optional, Union
import torch
import math
class ForcedEOSTokenLogitsProcessor(LogitsProcessor):
"""
[`LogitsProcessor`] that enforces the specified token as the last generated token when `max_length` is reached.
Args:
... |
class ForcedEOSTokenLogitsProcessor(LogitsProcessor):
'''
[`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[... | 4 | 1 | 9 | 1 | 8 | 0 | 3 | 1.39 | 1 | 4 | 0 | 0 | 2 | 2 | 2 | 3 | 54 | 11 | 18 | 8 | 14 | 25 | 17 | 7 | 14 | 4 | 1 | 2 | 6 |
328 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.HammingDiversityLogitsProcessor | import torch
class HammingDiversityLogitsProcessor(LogitsProcessor):
"""
[`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](... |
class HammingDiversityLogitsProcessor(LogitsProcessor):
'''
[`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://huggi... | 3 | 2 | 30 | 2 | 18 | 10 | 4 | 2.16 | 1 | 4 | 0 | 0 | 2 | 3 | 2 | 3 | 134 | 17 | 37 | 21 | 28 | 80 | 27 | 15 | 24 | 5 | 1 | 1 | 8 |
329 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.InfNanRemoveLogitsProcessor | from ..utils import add_start_docstrings
import torch
class InfNanRemoveLogitsProcessor(LogitsProcessor):
"""
[`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 ... |
class InfNanRemoveLogitsProcessor(LogitsProcessor):
'''
[`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 `g... | 3 | 1 | 9 | 2 | 5 | 2 | 1 | 1.14 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 2 | 19 | 4 | 7 | 4 | 4 | 8 | 6 | 3 | 4 | 1 | 1 | 0 | 1 |
330 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.LogitNormalization | from ..utils import add_start_docstrings
import torch
class LogitNormalization(LogitsProcessor):
"""
[`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 ... |
class LogitNormalization(LogitsProcessor):
'''
[`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... | 3 | 1 | 3 | 0 | 3 | 0 | 1 | 4.6 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 2 | 35 | 7 | 5 | 4 | 2 | 23 | 4 | 3 | 2 | 1 | 1 | 0 | 1 |
331 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.LogitsProcessor | from ..utils import add_start_docstrings
import torch
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) -> torc... |
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:
pass | 3 | 1 | 4 | 0 | 4 | 0 | 1 | 0.17 | 0 | 1 | 0 | 31 | 1 | 0 | 1 | 1 | 8 | 1 | 6 | 3 | 3 | 1 | 3 | 2 | 1 | 1 | 0 | 0 | 1 |
332 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.LogitsProcessorList | import inspect
import torch
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.
"""
... |
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... | 2 | 2 | 29 | 3 | 13 | 13 | 4 | 1.29 | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 34 | 36 | 4 | 14 | 4 | 12 | 18 | 10 | 4 | 8 | 4 | 2 | 3 | 4 |
333 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.MinLengthLogitsProcessor | from ..utils import add_start_docstrings
from typing import TYPE_CHECKING, Callable, Optional, Union
from ..pytorch_utils import isin_mps_friendly
import torch
import math
class MinLengthLogitsProcessor(LogitsProcessor):
"""
[`LogitsProcessor`] enforcing a min-length by setting EOS probability to 0. Note that,... |
class MinLengthLogitsProcessor(LogitsProcessor):
'''
[`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 `... | 4 | 1 | 9 | 1 | 8 | 0 | 3 | 1.67 | 1 | 4 | 0 | 0 | 2 | 2 | 2 | 3 | 59 | 11 | 18 | 9 | 14 | 30 | 17 | 8 | 14 | 4 | 1 | 2 | 6 |
334 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.MinNewTokensLengthLogitsProcessor | from ..utils import add_start_docstrings
from typing import TYPE_CHECKING, Callable, Optional, Union
from ..pytorch_utils import isin_mps_friendly
import torch
import math
class MinNewTokensLengthLogitsProcessor(LogitsProcessor):
"""
[`LogitsProcessor`] enforcing a min-length of new tokens by setting EOS (End-... |
class MinNewTokensLengthLogitsProcessor(LogitsProcessor):
'''
[`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`):
... | 4 | 1 | 16 | 2 | 14 | 0 | 4 | 0.97 | 1 | 4 | 0 | 0 | 2 | 3 | 2 | 3 | 70 | 11 | 30 | 18 | 20 | 29 | 20 | 11 | 17 | 5 | 1 | 2 | 7 |
335 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.MinPLogitsWarper | import torch
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 aggressive in the presence of
high-probability tokens, ... |
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 aggressive in the presence of
high-probability tokens, which is a si... | 3 | 1 | 14 | 2 | 10 | 3 | 2 | 2.05 | 1 | 3 | 0 | 0 | 2 | 3 | 2 | 3 | 75 | 14 | 20 | 14 | 17 | 41 | 20 | 14 | 17 | 3 | 1 | 1 | 4 |
336 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.NoBadWordsLogitsProcessor | from typing import TYPE_CHECKING, Callable, Optional, Union
import numpy as np
import torch
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... |
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 initializ... | 3 | 1 | 17 | 2 | 14 | 1 | 4 | 1.45 | 1 | 8 | 0 | 0 | 2 | 1 | 2 | 8 | 89 | 18 | 29 | 8 | 24 | 42 | 20 | 6 | 17 | 4 | 2 | 3 | 8 |
337 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.NoRepeatNGramLogitsProcessor | from ..utils import add_start_docstrings
import torch
class NoRepeatNGramLogitsProcessor(LogitsProcessor):
"""
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", "fas... |
class NoRepeatNGramLogitsProcessor(LogitsProcessor):
'''
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... | 4 | 1 | 7 | 1 | 6 | 0 | 2 | 2.21 | 1 | 4 | 0 | 0 | 2 | 1 | 2 | 3 | 57 | 12 | 14 | 10 | 10 | 31 | 13 | 9 | 10 | 2 | 1 | 1 | 4 |
338 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.PrefixConstrainedLogitsProcessor | from ..utils import add_start_docstrings
from typing import TYPE_CHECKING, Callable, Optional, Union
import torch
import math
class PrefixConstrainedLogitsProcessor(LogitsProcessor):
"""
[`LogitsProcessor`] that enforces constrained generation and is useful for prefix-conditioned constrained
generation. Se... |
class PrefixConstrainedLogitsProcessor(LogitsProcessor):
'''
[`LogitsProcessor`] that enforces constrained generation and is useful for prefix-conditioned constrained
generation. See [Autoregressive Entity Retrieval](https://huggingface.co/papers/2010.00904) for more information.
Args:
prefix_a... | 4 | 1 | 9 | 1 | 9 | 0 | 3 | 1.95 | 1 | 4 | 0 | 0 | 2 | 2 | 2 | 3 | 67 | 11 | 19 | 11 | 15 | 37 | 14 | 10 | 11 | 4 | 1 | 3 | 5 |
339 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.RepetitionPenaltyLogitsProcessor | from ..utils import add_start_docstrings
from typing import TYPE_CHECKING, Callable, Optional, Union
import torch
class RepetitionPenaltyLogitsProcessor(LogitsProcessor):
"""
[`LogitsProcessor`] that prevents the repetition of previous tokens through a penalty. This penalty is applied at
most once per toke... |
class RepetitionPenaltyLogitsProcessor(LogitsProcessor):
'''
[`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
by default.
... | 5 | 1 | 7 | 2 | 5 | 1 | 2 | 2.64 | 1 | 2 | 0 | 0 | 2 | 1 | 2 | 3 | 52 | 12 | 11 | 7 | 7 | 29 | 10 | 6 | 7 | 2 | 1 | 1 | 3 |
340 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.SequenceBiasLogitsProcessor | from ..utils import add_start_docstrings
from typing import TYPE_CHECKING, Callable, Optional, Union
import numpy as np
import torch
class SequenceBiasLogitsProcessor(LogitsProcessor):
"""
[`LogitsProcessor`] that applies an additive bias on sequences. The bias is applied to the last token of a sequence
wh... |
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, consid... | 8 | 2 | 19 | 2 | 15 | 2 | 4 | 0.74 | 1 | 6 | 0 | 1 | 5 | 3 | 5 | 6 | 175 | 27 | 86 | 24 | 78 | 64 | 55 | 23 | 48 | 7 | 1 | 3 | 22 |
341 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.SuppressTokensAtBeginLogitsProcessor | from ..utils import add_start_docstrings
import torch
from ..pytorch_utils import isin_mps_friendly
class SuppressTokensAtBeginLogitsProcessor(LogitsProcessor):
"""
[`SuppressTokensAtBeginLogitsProcessor`] suppresses a list of tokens as soon as the `generate` function starts
generating using `begin_index` ... |
class SuppressTokensAtBeginLogitsProcessor(LogitsProcessor):
'''
[`SuppressTokensAtBeginLogitsProcessor`] suppresses 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 ... | 5 | 1 | 4 | 0 | 4 | 0 | 1 | 2 | 1 | 3 | 0 | 0 | 3 | 2 | 3 | 4 | 51 | 9 | 14 | 10 | 9 | 28 | 13 | 9 | 9 | 2 | 1 | 1 | 4 |
342 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.SuppressTokensLogitsProcessor | from ..utils import add_start_docstrings
import torch
from ..pytorch_utils import isin_mps_friendly
class SuppressTokensLogitsProcessor(LogitsProcessor):
"""
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 ... |
class SuppressTokensLogitsProcessor(LogitsProcessor):
'''
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:... | 4 | 1 | 4 | 0 | 4 | 0 | 1 | 2.44 | 1 | 3 | 0 | 0 | 2 | 1 | 2 | 3 | 38 | 7 | 9 | 7 | 5 | 22 | 8 | 6 | 5 | 1 | 1 | 0 | 2 |
343 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.SynthIDTextWatermarkLogitsProcessor | from ..utils import add_start_docstrings
import torch
class SynthIDTextWatermarkLogitsProcessor(LogitsProcessor):
"""
Logits processor that implements watermarking techniques for text generation models.
This class facilitates the application of SynthID text watermarking, a method for embedding imperceptibl... |
class SynthIDTextWatermarkLogitsProcessor(LogitsProcessor):
'''
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 ... | 15 | 12 | 27 | 4 | 14 | 10 | 2 | 1.07 | 1 | 6 | 1 | 0 | 13 | 8 | 13 | 14 | 442 | 72 | 179 | 82 | 146 | 191 | 113 | 63 | 99 | 5 | 1 | 2 | 25 |
344 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.SynthIDTextWatermarkState | import torch
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.
ngram_len (`int`): Ngra... |
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.
ngram_len (`int`): Ngram length.
... | 2 | 2 | 26 | 1 | 18 | 7 | 1 | 0.42 | 0 | 1 | 0 | 0 | 1 | 3 | 1 | 1 | 29 | 2 | 19 | 11 | 11 | 8 | 5 | 5 | 3 | 1 | 0 | 0 | 1 |
345 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.TemperatureLogitsWarper | from ..utils import add_start_docstrings
import torch
class TemperatureLogitsWarper(LogitsProcessor):
"""
[`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 [... |
class TemperatureLogitsWarper(LogitsProcessor):
'''
[`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`].
... | 4 | 1 | 7 | 1 | 7 | 0 | 2 | 2.4 | 1 | 2 | 0 | 0 | 2 | 1 | 2 | 3 | 64 | 13 | 15 | 7 | 11 | 36 | 11 | 6 | 8 | 3 | 1 | 2 | 4 |
346 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.TopKLogitsWarper | from ..utils import add_start_docstrings
import torch
class TopKLogitsWarper(LogitsProcessor):
"""
[`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`)... |
class TopKLogitsWarper(LogitsProcessor):
'''
[`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 vocabul... | 4 | 1 | 6 | 1 | 5 | 1 | 2 | 2.5 | 1 | 3 | 0 | 0 | 2 | 2 | 2 | 3 | 51 | 10 | 12 | 9 | 8 | 30 | 11 | 8 | 8 | 2 | 1 | 1 | 3 |
347 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.TopPLogitsWarper | from ..utils import add_start_docstrings
import torch
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:
... |
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... | 4 | 1 | 12 | 2 | 9 | 2 | 2 | 1.79 | 1 | 3 | 0 | 0 | 2 | 3 | 2 | 3 | 65 | 12 | 19 | 12 | 15 | 34 | 18 | 11 | 15 | 3 | 1 | 1 | 4 |
348 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.TypicalLogitsWarper | from ..utils import add_start_docstrings
import torch
class TypicalLogitsWarper(LogitsProcessor):
"""
[`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 mean... |
class TypicalLogitsWarper(LogitsProcessor):
'''
[`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 ... | 4 | 1 | 16 | 2 | 12 | 2 | 2 | 1.69 | 1 | 3 | 0 | 0 | 2 | 3 | 2 | 3 | 86 | 16 | 26 | 18 | 22 | 44 | 25 | 17 | 22 | 3 | 1 | 1 | 4 |
349 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.UnbatchedClassifierFreeGuidanceLogitsProcessor | from typing import TYPE_CHECKING, Callable, Optional, Union
import torch
class UnbatchedClassifierFreeGuidanceLogitsProcessor(LogitsProcessor):
"""
Logits processor for Classifier-Free Guidance (CFG). The processors computes a weighted average across scores
from prompt conditional and prompt unconditional ... |
class UnbatchedClassifierFreeGuidanceLogitsProcessor(LogitsProcessor):
'''
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... | 4 | 1 | 21 | 1 | 19 | 0 | 3 | 0.71 | 1 | 2 | 0 | 0 | 3 | 3 | 3 | 4 | 116 | 15 | 59 | 19 | 48 | 42 | 31 | 12 | 27 | 5 | 1 | 2 | 8 |
350 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.WatermarkLogitsProcessor | from ..utils import add_start_docstrings
import torch
class WatermarkLogitsProcessor(LogitsProcessor):
"""
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... |
class WatermarkLogitsProcessor(LogitsProcessor):
'''
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`... | 7 | 2 | 15 | 1 | 13 | 1 | 3 | 0.86 | 1 | 6 | 0 | 0 | 5 | 9 | 5 | 6 | 140 | 19 | 65 | 37 | 49 | 56 | 48 | 27 | 42 | 4 | 1 | 2 | 13 |
351 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.WhisperNoSpeechDetection | from ..utils import add_start_docstrings
import inspect
import torch
class WhisperNoSpeechDetection(LogitsProcessor):
"""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,... |
class WhisperNoSpeechDetection(LogitsProcessor):
'''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):
pass
... | 9 | 1 | 8 | 1 | 6 | 1 | 2 | 0.14 | 1 | 2 | 0 | 0 | 6 | 7 | 6 | 7 | 55 | 13 | 37 | 21 | 28 | 5 | 33 | 19 | 26 | 4 | 1 | 3 | 9 |
352 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/logits_process.py | transformers.generation.logits_process.WhisperTimeStampLogitsProcessor | from ..utils import add_start_docstrings
from typing import TYPE_CHECKING, Callable, Optional, Union
import torch
class WhisperTimeStampLogitsProcessor(LogitsProcessor):
"""
[`LogitsProcessor`] that modifies the logits for the generation of timestamps in the transcription. When the input
tokens are at a s... |
class WhisperTimeStampLogitsProcessor(LogitsProcessor):
'''
[`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 ... | 5 | 1 | 24 | 4 | 18 | 4 | 5 | 1.05 | 1 | 5 | 0 | 0 | 3 | 6 | 3 | 4 | 134 | 24 | 55 | 29 | 45 | 58 | 41 | 23 | 37 | 10 | 1 | 3 | 14 |
353 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/stopping_criteria.py | transformers.generation.stopping_criteria.ConfidenceCriteria | import torch
class ConfidenceCriteria(StoppingCriteria):
"""
This class can be used to stop generation whenever assistant model's confidence in its prediction for the current token is lower than the threshold
`model.generation_config.assistant_confidence_threshold` even if the number of speculative tok... |
class ConfidenceCriteria(StoppingCriteria):
'''
This class can be used to stop generation whenever assistant model's confidence in its prediction for the current token is lower than the threshold
`model.generation_config.assistant_confidence_threshold` even if the number of speculative tokens (defined ... | 3 | 1 | 4 | 0 | 4 | 0 | 2 | 0.78 | 1 | 0 | 0 | 0 | 2 | 1 | 2 | 23 | 19 | 3 | 9 | 6 | 6 | 7 | 9 | 6 | 6 | 2 | 5 | 1 | 3 |
354 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/stopping_criteria.py | transformers.generation.stopping_criteria.EosTokenCriteria | from ..utils import add_start_docstrings, logging
import torch
from ..pytorch_utils import isin_mps_friendly
from typing import Optional, Union
class EosTokenCriteria(StoppingCriteria):
"""
This class can be used to stop generation whenever the "end-of-sequence" token is generated.
By default, it uses the ... |
class EosTokenCriteria(StoppingCriteria):
'''
This class can be used to stop generation whenever the "end-of-sequence" token is generated.
By default, it uses the `model.generation_config.eos_token_id`.
Args:
eos_token_id (`Union[int, list[int], torch.Tensor]`):
The id(s) of the *en... | 4 | 1 | 5 | 0 | 5 | 0 | 2 | 0.58 | 1 | 2 | 0 | 0 | 2 | 1 | 2 | 23 | 22 | 3 | 12 | 6 | 8 | 7 | 11 | 5 | 8 | 3 | 5 | 2 | 4 |
355 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/stopping_criteria.py | transformers.generation.stopping_criteria.MaxLengthCriteria | import torch
from ..utils import add_start_docstrings, logging
from typing import Optional, Union
class MaxLengthCriteria(StoppingCriteria):
"""
This class can be used to stop generation whenever the full generated number of tokens exceeds `max_length`. Keep
in mind for decoder-only type of transformers, t... |
class MaxLengthCriteria(StoppingCriteria):
'''
This class can be used to stop generation whenever the full generated number of tokens exceeds `max_length`. Keep
in mind for decoder-only type of transformers, this will include the initial prompted tokens.
Args:
max_length (`int`):
Th... | 4 | 1 | 7 | 0 | 7 | 0 | 2 | 0.6 | 1 | 2 | 0 | 0 | 2 | 2 | 2 | 23 | 27 | 3 | 15 | 8 | 11 | 9 | 10 | 7 | 7 | 2 | 5 | 1 | 3 |
356 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/stopping_criteria.py | transformers.generation.stopping_criteria.MaxTimeCriteria | from typing import Optional, Union
import torch
import time
from ..utils import add_start_docstrings, logging
class MaxTimeCriteria(StoppingCriteria):
"""
This class can be used to stop generation whenever the full generation exceeds some amount of time. By default, the
time will start being counted when y... |
class MaxTimeCriteria(StoppingCriteria):
'''
This class can be used to stop generation whenever the full generation exceeds some amount of time. By default, the
time will start being counted when you initialize this function. You can override this by passing an
`initial_time`.
Args:
max_tim... | 4 | 1 | 3 | 0 | 3 | 0 | 2 | 1.25 | 1 | 2 | 0 | 0 | 2 | 2 | 2 | 23 | 21 | 3 | 8 | 7 | 4 | 10 | 7 | 6 | 4 | 2 | 5 | 0 | 3 |
357 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/stopping_criteria.py | transformers.generation.stopping_criteria.StopStringCriteria | from torch.nn import functional as F
from ..utils import add_start_docstrings, logging
from ..tokenization_utils_base import PreTrainedTokenizerBase
from typing import Optional, Union
import numpy as np
import torch
class StopStringCriteria(StoppingCriteria):
"""
This class can be used to stop generation whene... |
class StopStringCriteria(StoppingCriteria):
'''
This class can be used to stop generation whenever specific string sequences are generated. It preprocesses
the strings together with the tokenizer vocab to find positions where tokens can validly complete the stop strings.
Generation is stopped as soon a... | 11 | 4 | 33 | 4 | 22 | 8 | 4 | 1.12 | 1 | 9 | 1 | 0 | 3 | 7 | 6 | 27 | 339 | 50 | 138 | 65 | 125 | 154 | 101 | 59 | 94 | 9 | 5 | 5 | 24 |
358 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/stopping_criteria.py | transformers.generation.stopping_criteria.StoppingCriteria | from abc import ABC
import torch
from ..utils import add_start_docstrings, logging
class StoppingCriteria(ABC):
"""Abstract base class for all stopping criteria that can be applied during generation.
If your stopping criteria depends on the `scores` input, make sure you pass `return_dict_in_generate=True,
... |
class StoppingCriteria(ABC):
'''Abstract base class for all stopping criteria that can be applied during generation.
If your stopping criteria depends on the `scores` input, make sure you pass `return_dict_in_generate=True,
output_scores=True` to `generate`.
'''
@add_start_docstrings(STOPPING_CRITE... | 3 | 1 | 2 | 0 | 2 | 0 | 1 | 1 | 1 | 1 | 0 | 5 | 1 | 0 | 1 | 21 | 10 | 2 | 4 | 3 | 1 | 4 | 3 | 2 | 1 | 1 | 4 | 0 | 1 |
359 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/stopping_criteria.py | transformers.generation.stopping_criteria.StoppingCriteriaList | from typing import Optional, Union
from ..utils import add_start_docstrings, logging
import torch
class StoppingCriteriaList(list):
@add_start_docstrings(STOPPING_CRITERIA_INPUTS_DOCSTRING)
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> torch.BoolTensor:
is_don... |
class StoppingCriteriaList(list):
@add_start_docstrings(STOPPING_CRITERIA_INPUTS_DOCSTRING)
def __call__(self, input_ids: torch.LongTensor, scores: torch.FloatTensor, **kwargs) -> torch.BoolTensor:
pass
@property
def max_length(self) -> Optional[int]:
pass | 5 | 0 | 5 | 0 | 5 | 0 | 3 | 0 | 1 | 3 | 1 | 0 | 2 | 0 | 2 | 35 | 14 | 1 | 13 | 8 | 8 | 0 | 11 | 6 | 8 | 3 | 2 | 2 | 5 |
360 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/streamers.py | transformers.generation.streamers.AsyncTextIteratorStreamer | import asyncio
class AsyncTextIteratorStreamer(TextStreamer):
"""
Streamer that stores print-ready text in a queue, to be used by a downstream application as an async iterator.
This is useful for applications that benefit from accessing the generated text asynchronously (e.g. in an
interactive Gradio d... |
class AsyncTextIteratorStreamer(TextStreamer):
'''
Streamer that stores print-ready text in a queue, to be used by a downstream application as an async iterator.
This is useful for applications that benefit from accessing the generated text asynchronously (e.g. in an
interactive Gradio demo).
<Tip ... | 5 | 2 | 8 | 0 | 7 | 0 | 2 | 1.43 | 1 | 5 | 0 | 0 | 4 | 5 | 4 | 11 | 86 | 13 | 30 | 13 | 23 | 43 | 26 | 11 | 21 | 4 | 2 | 3 | 8 |
361 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/streamers.py | transformers.generation.streamers.BaseStreamer | class BaseStreamer:
"""
Base class from which `.generate()` streamers should inherit.
"""
def put(self, value):
"""Function that is called by `.generate()` to push new tokens"""
raise NotImplementedError()
def end(self):
"""Function that is called by `.generate()` to signal... | class BaseStreamer:
'''
Base class from which `.generate()` streamers should inherit.
'''
def put(self, value):
'''Function that is called by `.generate()` to push new tokens'''
pass
def end(self):
'''Function that is called by `.generate()` to signal the end of generat... | 3 | 3 | 3 | 0 | 2 | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 2 | 0 | 2 | 2 | 12 | 2 | 5 | 3 | 2 | 5 | 5 | 3 | 2 | 1 | 0 | 0 | 2 |
362 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/streamers.py | transformers.generation.streamers.TextIteratorStreamer | from queue import Queue
class TextIteratorStreamer(TextStreamer):
"""
Streamer that stores print-ready text in a queue, to be used by a downstream application as an iterator. This is
useful for applications that benefit from accessing the generated text in a non-blocking way (e.g. in an interactive
Gra... |
class TextIteratorStreamer(TextStreamer):
'''
Streamer that stores print-ready text in a queue, to be used by a downstream application as an iterator. This is
useful for applications that benefit from accessing the generated text in a non-blocking way (e.g. in an interactive
Gradio demo).
<Tip warn... | 5 | 2 | 5 | 0 | 5 | 0 | 2 | 1.85 | 1 | 6 | 0 | 0 | 4 | 3 | 4 | 11 | 69 | 12 | 20 | 11 | 13 | 37 | 17 | 9 | 12 | 2 | 2 | 1 | 6 |
363 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/streamers.py | transformers.generation.streamers.TextStreamer | class TextStreamer(BaseStreamer):
"""
Simple text streamer that prints the token(s) to stdout as soon as entire words are formed.
<Tip warning={true}>
The API for the streamer classes is still under development and may change in the future.
</Tip>
Parameters:
tokenizer (`AutoTokenize... | class TextStreamer(BaseStreamer):
'''
Simple text streamer that prints the token(s) to stdout as soon as entire words are formed.
<Tip warning={true}>
The API for the streamer classes is still under development and may change in the future.
</Tip>
Parameters:
tokenizer (`AutoTokenizer`):... | 6 | 5 | 16 | 1 | 11 | 6 | 3 | 0.96 | 1 | 3 | 0 | 2 | 5 | 6 | 5 | 7 | 119 | 20 | 54 | 16 | 48 | 52 | 41 | 16 | 35 | 6 | 1 | 1 | 13 |
364 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/utils.py | transformers.generation.utils.GenerateBeamDecoderOnlyOutput | from typing import TYPE_CHECKING, Any, Callable, Optional, Union
from ..utils import ModelOutput, TransformersKwargs, is_accelerate_available, is_hqq_available, is_optimum_quanto_available, is_torchdynamo_exporting, logging
from ..cache_utils import Cache, DynamicCache, EncoderDecoderCache, QuantizedCache, StaticCache
... | @dataclass
class GenerateBeamDecoderOnlyOutput(ModelOutput):
'''
Outputs of decoder-only generation models, when using beam methods.
Args:
sequences (`torch.LongTensor` of shape `(batch_size*num_return_sequences, sequence_length)`):
The generated sequences. The second dimension (sequence... | 2 | 1 | 0 | 0 | 0 | 0 | 0 | 3.33 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 41 | 2 | 9 | 9 | 8 | 30 | 9 | 9 | 8 | 0 | 1 | 0 | 0 |
365 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/utils.py | transformers.generation.utils.GenerateBeamEncoderDecoderOutput | from typing import TYPE_CHECKING, Any, Callable, Optional, Union
from ..utils import ModelOutput, TransformersKwargs, is_accelerate_available, is_hqq_available, is_optimum_quanto_available, is_torchdynamo_exporting, logging
import torch.distributed as dist
from dataclasses import dataclass
import torch
from ..cache_uti... | @dataclass
class GenerateBeamEncoderDecoderOutput(ModelOutput):
'''
Outputs of encoder-decoder generation models, when using beam methods.
Args:
sequences (`torch.LongTensor` of shape `(batch_size*num_return_sequences, sequence_length)`):
The generated sequences. The second dimension (se... | 2 | 1 | 0 | 0 | 0 | 0 | 0 | 3.33 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 54 | 2 | 12 | 12 | 11 | 40 | 12 | 12 | 11 | 0 | 1 | 0 | 0 |
366 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/utils.py | transformers.generation.utils.GenerateDecoderOnlyOutput | from typing import TYPE_CHECKING, Any, Callable, Optional, Union
from ..utils import ModelOutput, TransformersKwargs, is_accelerate_available, is_hqq_available, is_optimum_quanto_available, is_torchdynamo_exporting, logging
import torch.distributed as dist
from dataclasses import dataclass
import torch
from ..cache_uti... | @dataclass
class GenerateDecoderOnlyOutput(ModelOutput):
'''
Outputs of decoder-only generation models, when using non-beam methods.
Args:
sequences (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
The generated sequences. The second dimension (sequence_length) is either eq... | 2 | 1 | 0 | 0 | 0 | 0 | 0 | 3.43 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 33 | 2 | 7 | 7 | 6 | 24 | 7 | 7 | 6 | 0 | 1 | 0 | 0 |
367 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/utils.py | transformers.generation.utils.GenerateEncoderDecoderOutput | from dataclasses import dataclass
import torch
from ..cache_utils import Cache, DynamicCache, EncoderDecoderCache, QuantizedCache, StaticCache
from ..utils import ModelOutput, TransformersKwargs, is_accelerate_available, is_hqq_available, is_optimum_quanto_available, is_torchdynamo_exporting, logging
from typing import... | @dataclass
class GenerateEncoderDecoderOutput(ModelOutput):
'''
Outputs of encoder-decoder generation models, when using non-beam methods.
Args:
sequences (`torch.LongTensor` of shape `(batch_size*num_return_sequences, sequence_length)`):
The generated sequences. The second dimension (se... | 2 | 1 | 0 | 0 | 0 | 0 | 0 | 3.3 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 45 | 2 | 10 | 10 | 9 | 33 | 10 | 10 | 9 | 0 | 1 | 0 | 0 |
368 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/utils.py | transformers.generation.utils.GenerationMixin | from .candidate_generator import AssistantVocabTranslatorCache, AssistedCandidateGenerator, AssistedCandidateGeneratorDifferentTokenizers, CandidateGenerator, EarlyExitCandidateGenerator, PromptLookupCandidateGenerator, UniversalSpeculativeDecodingGenerator, _prepare_attention_mask, _prepare_token_type_ids
from .logits... | null | 59 | 40 | 99 | 10 | 68 | 21 | 14 | 0.32 | 0 | 78 | 58 | 7 | 37 | 4 | 38 | 38 | 4,074 | 453 | 2,762 | 656 | 2,521 | 888 | 1,406 | 453 | 1,364 | 54 | 0 | 5 | 561 |
369 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/watermarking.py | transformers.generation.watermarking.BayesianDetectorConfig | from typing import Any, Optional, Union
from .configuration_utils import PretrainedConfig, WatermarkingConfig
class BayesianDetectorConfig(PretrainedConfig):
"""
This is the configuration class to store the configuration of a [`BayesianDetectorModel`]. It is used to
instantiate a Bayesian Detector model ac... |
class BayesianDetectorConfig(PretrainedConfig):
'''
This is the configuration class to store the configuration of a [`BayesianDetectorModel`]. It is used to
instantiate a Bayesian Detector model according to the specified arguments.
Configuration objects inherit from [`PretrainedConfig`] and can be use... | 3 | 1 | 6 | 1 | 5 | 1 | 1 | 1.2 | 1 | 3 | 0 | 0 | 2 | 4 | 2 | 2 | 27 | 5 | 10 | 7 | 7 | 12 | 10 | 7 | 7 | 1 | 1 | 0 | 2 |
370 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/watermarking.py | transformers.generation.watermarking.BayesianDetectorModel | from torch import nn
import torch
from torch.nn import BCELoss
from typing import Any, Optional, Union
from ..modeling_utils import PreTrainedModel
class BayesianDetectorModel(PreTrainedModel):
"""
Bayesian classifier for watermark detection.
This detector uses Bayes' rule to compute a watermarking score,... |
class BayesianDetectorModel(PreTrainedModel):
'''
Bayesian classifier for watermark detection.
This detector uses Bayes' rule to compute a watermarking score, which is the sigmoid of the log of ratio of the
posterior probabilities P(watermarked|g_values) and P(unwatermarked|g_values). Please see the se... | 5 | 4 | 24 | 3 | 13 | 8 | 2 | 0.91 | 1 | 5 | 2 | 0 | 4 | 4 | 4 | 4 | 128 | 23 | 55 | 37 | 37 | 50 | 35 | 24 | 30 | 4 | 1 | 1 | 8 |
371 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/watermarking.py | transformers.generation.watermarking.BayesianDetectorWatermarkedLikelihood | import torch
from torch import nn
class BayesianDetectorWatermarkedLikelihood(nn.Module):
"""Watermarked likelihood model for binary-valued g-values.
This takes in g-values and returns p(g_values|watermarked).
"""
def __init__(self, watermarking_depth: int):
"""Initializes the model parameter... |
class BayesianDetectorWatermarkedLikelihood(nn.Module):
'''Watermarked likelihood model for binary-valued g-values.
This takes in g-values and returns p(g_values|watermarked).
'''
def __init__(self, watermarking_depth: int):
'''Initializes the model parameters.'''
pass
def _comput... | 4 | 4 | 17 | 3 | 5 | 9 | 1 | 1.94 | 1 | 3 | 0 | 0 | 3 | 3 | 3 | 13 | 60 | 13 | 16 | 12 | 12 | 31 | 16 | 12 | 12 | 1 | 1 | 0 | 3 |
372 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/watermarking.py | transformers.generation.watermarking.SynthIDTextWatermarkDetector | import torch
from typing import Any, Optional, Union
class SynthIDTextWatermarkDetector:
"""
SynthID text watermark detector class.
This class has to be initialized with the trained bayesian detector module check script
in examples/synthid_text/detector_training.py for example in training/saving/loadi... |
class SynthIDTextWatermarkDetector:
'''
SynthID text watermark detector class.
This class has to be initialized with the trained bayesian detector module check script
in examples/synthid_text/detector_training.py for example in training/saving/loading this
detector module. The folder also showcases... | 3 | 1 | 15 | 2 | 11 | 3 | 1 | 1.52 | 0 | 4 | 2 | 0 | 2 | 3 | 2 | 2 | 68 | 10 | 23 | 15 | 15 | 35 | 11 | 10 | 8 | 1 | 0 | 0 | 2 |
373 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/watermarking.py | transformers.generation.watermarking.WatermarkDetector | import torch
from typing import Any, Optional, Union
import collections
from .configuration_utils import PretrainedConfig, WatermarkingConfig
from functools import lru_cache
import numpy as np
class WatermarkDetector:
"""
Detector for detection of watermark generated text. The detector needs to be given the ex... | null | 7 | 2 | 19 | 2 | 14 | 3 | 3 | 0.69 | 0 | 11 | 3 | 0 | 6 | 5 | 6 | 6 | 170 | 25 | 86 | 48 | 67 | 59 | 55 | 36 | 48 | 5 | 0 | 2 | 15 |
374 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/generation/watermarking.py | transformers.generation.watermarking.WatermarkDetectorOutput | from dataclasses import dataclass
import numpy as np
from typing import Any, Optional, Union
@dataclass
class WatermarkDetectorOutput:
"""
Outputs of a watermark detector.
Args:
num_tokens_scored (np.array of shape (batch_size)):
Array containing the number of tokens scored for each el... | @dataclass
class WatermarkDetectorOutput:
'''
Outputs of a watermark detector.
Args:
num_tokens_scored (np.array of shape (batch_size)):
Array containing the number of tokens scored for each element in the batch.
num_green_tokens (np.array of shape (batch_size)):
Arra... | 2 | 1 | 0 | 0 | 0 | 0 | 0 | 2.5 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 30 | 2 | 8 | 8 | 7 | 20 | 8 | 8 | 7 | 0 | 0 | 0 | 0 |
375 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/hf_argparser.py | transformers.hf_argparser.HfArgumentParser | import types
import dataclasses
import json
from typing import Any, Callable, Literal, NewType, Optional, Union, get_type_hints
from copy import copy
from enum import Enum
import sys
from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, ArgumentTypeError
from collections.abc import Iterable
from inspect i... |
class HfArgumentParser(ArgumentParser):
'''
This subclass of `argparse.ArgumentParser` uses type hints on dataclasses to generate arguments.
The class is designed to play well with the native argparse. In particular, you can add more (non-dataclass backed)
arguments to the parser after initialization a... | 9 | 5 | 44 | 5 | 26 | 13 | 8 | 0.55 | 1 | 18 | 0 | 0 | 6 | 0 | 7 | 57 | 333 | 42 | 188 | 54 | 168 | 103 | 135 | 40 | 127 | 22 | 3 | 3 | 54 |
376 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/hyperparameter_search.py | transformers.hyperparameter_search.HyperParamSearchBackendBase | from typing import Optional
class HyperParamSearchBackendBase:
name: str
pip_package: Optional[str] = None
@staticmethod
def is_available():
raise NotImplementedError
def run(self, trainer, n_trials: int, direction: str, **kwargs):
raise NotImplementedError
def default_hp_spa... |
class HyperParamSearchBackendBase:
@staticmethod
def is_available():
pass
def run(self, trainer, n_trials: int, direction: str, **kwargs):
pass
def default_hp_space(self, trial):
pass
def ensure_available(self):
pass
@classmethod
def pip_install(cls):
... | 8 | 0 | 3 | 0 | 3 | 0 | 1 | 0 | 0 | 4 | 0 | 4 | 3 | 0 | 5 | 5 | 23 | 5 | 18 | 9 | 10 | 0 | 14 | 7 | 8 | 2 | 0 | 1 | 6 |
377 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/hyperparameter_search.py | transformers.hyperparameter_search.OptunaBackend | from .trainer_utils import HPSearchBackend, default_hp_space_optuna, default_hp_space_ray, default_hp_space_sigopt, default_hp_space_wandb
from .integrations import is_optuna_available, is_ray_tune_available, is_sigopt_available, is_wandb_available, run_hp_search_optuna, run_hp_search_ray, run_hp_search_sigopt, run_hp_... |
class OptunaBackend(HyperParamSearchBackendBase):
@staticmethod
def is_available():
pass
def run(self, trainer, n_trials: int, direction: str, **kwargs):
pass
def default_hp_space(self, trial):
pass | 5 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 2 | 0 | 0 | 2 | 0 | 3 | 8 | 12 | 3 | 9 | 6 | 4 | 0 | 8 | 5 | 4 | 1 | 1 | 0 | 3 |
378 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/hyperparameter_search.py | transformers.hyperparameter_search.RayTuneBackend | from .trainer_utils import HPSearchBackend, default_hp_space_optuna, default_hp_space_ray, default_hp_space_sigopt, default_hp_space_wandb
from .integrations import is_optuna_available, is_ray_tune_available, is_sigopt_available, is_wandb_available, run_hp_search_optuna, run_hp_search_ray, run_hp_search_sigopt, run_hp_... |
class RayTuneBackend(HyperParamSearchBackendBase):
@staticmethod
def is_available():
pass
def run(self, trainer, n_trials: int, direction: str, **kwargs):
pass
def default_hp_space(self, trial):
pass | 5 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 2 | 0 | 0 | 2 | 0 | 3 | 8 | 13 | 3 | 10 | 7 | 5 | 0 | 9 | 6 | 5 | 1 | 1 | 0 | 3 |
379 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/hyperparameter_search.py | transformers.hyperparameter_search.SigOptBackend | from .integrations import is_optuna_available, is_ray_tune_available, is_sigopt_available, is_wandb_available, run_hp_search_optuna, run_hp_search_ray, run_hp_search_sigopt, run_hp_search_wandb
from .trainer_utils import HPSearchBackend, default_hp_space_optuna, default_hp_space_ray, default_hp_space_sigopt, default_hp... |
class SigOptBackend(HyperParamSearchBackendBase):
@staticmethod
def is_available():
pass
def run(self, trainer, n_trials: int, direction: str, **kwargs):
pass
def default_hp_space(self, trial):
pass | 5 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 2 | 0 | 0 | 2 | 0 | 3 | 8 | 12 | 3 | 9 | 6 | 4 | 0 | 8 | 5 | 4 | 1 | 1 | 0 | 3 |
380 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/hyperparameter_search.py | transformers.hyperparameter_search.WandbBackend | from .trainer_utils import HPSearchBackend, default_hp_space_optuna, default_hp_space_ray, default_hp_space_sigopt, default_hp_space_wandb
from .integrations import is_optuna_available, is_ray_tune_available, is_sigopt_available, is_wandb_available, run_hp_search_optuna, run_hp_search_ray, run_hp_search_sigopt, run_hp_... |
class WandbBackend(HyperParamSearchBackendBase):
@staticmethod
def is_available():
pass
def run(self, trainer, n_trials: int, direction: str, **kwargs):
pass
def default_hp_space(self, trial):
pass | 5 | 0 | 2 | 0 | 2 | 0 | 1 | 0 | 1 | 2 | 0 | 0 | 2 | 0 | 3 | 8 | 12 | 3 | 9 | 6 | 4 | 0 | 8 | 5 | 4 | 1 | 1 | 0 | 3 |
381 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/image_processing_base.py | transformers.image_processing_base.BatchFeature | from .feature_extraction_utils import BatchFeature as BaseBatchFeature
class BatchFeature(BaseBatchFeature):
"""
Holds the output of the image processor specific `__call__` methods.
This class is derived from a python dictionary and can be used as a dictionary.
Args:
data (`dict`):
... |
class BatchFeature(BaseBatchFeature):
'''
Holds the output of the image processor specific `__call__` methods.
This class is derived from a python dictionary and can be used as a dictionary.
Args:
data (`dict`):
Dictionary of lists/arrays/tensors returned by the __call__ method ('pi... | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 10 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 66 | 13 | 2 | 1 | 1 | 0 | 10 | 1 | 1 | 0 | 0 | 9 | 0 | 0 |
382 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/image_processing_base.py | transformers.image_processing_base.ImageProcessingMixin | import numpy as np
import json
import os
import warnings
from .utils.hub import cached_file
from .image_utils import is_valid_image, load_image
from typing import Any, Optional, TypeVar, Union
import copy
from .dynamic_module_utils import custom_object_save
from .utils import IMAGE_PROCESSOR_NAME, PROCESSOR_NAME, PushT... |
class ImageProcessingMixin(PushToHubMixin):
'''
This is an image processor mixin used to provide saving/loading functionality for sequential and image feature
extractors.
'''
def __init__(self, **kwargs):
'''Set elements of `kwargs` as attributes.'''
pass
def _set_processor_cl... | 19 | 13 | 35 | 4 | 18 | 13 | 4 | 0.74 | 1 | 13 | 0 | 1 | 8 | 1 | 13 | 13 | 481 | 72 | 235 | 75 | 204 | 174 | 162 | 55 | 147 | 14 | 1 | 2 | 50 |
383 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/image_processing_utils.py | transformers.image_processing_utils.BaseImageProcessor | from .utils.import_utils import requires
from .image_utils import ChannelDimension, get_image_size
from .image_processing_base import BatchFeature, ImageProcessingMixin
from .image_transforms import center_crop, normalize, rescale
from collections.abc import Iterable
from typing import Optional, Union
import numpy as n... | @requires(backends=('vision',))
class BaseImageProcessor(ImageProcessingMixin):
def __init__(self, **kwargs):
pass
@property
def is_fast(self) -> bool:
'''
`bool`: Whether or not this image processor is a fast processor (backed by PyTorch and TorchVision).
'''
pass
... | 11 | 5 | 17 | 1 | 7 | 9 | 1 | 1.24 | 1 | 8 | 2 | 78 | 7 | 0 | 7 | 20 | 123 | 11 | 50 | 31 | 20 | 62 | 20 | 9 | 12 | 2 | 2 | 1 | 8 |
384 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/image_processing_utils_fast.py | transformers.image_processing_utils_fast.BaseImageProcessorFast | from collections.abc import Iterable
from copy import deepcopy
from typing import Any, Optional, TypedDict, Union
from .image_processing_utils import BaseImageProcessor, BatchFeature, get_size_dict
from .image_transforms import convert_to_rgb, get_resize_output_image_size, get_size_with_aspect_ratio, group_images_by_sh... | @auto_docstring
class BaseImageProcessorFast(BaseImageProcessor):
def __init__(self, **kwargs: Unpack[DefaultFastImageProcessorKwargs]):
pass
@property
def is_fast(self) -> bool:
'''
`bool`: Whether or not this image processor is a fast processor (backed by PyTorch and TorchVision).... | 28 | 15 | 27 | 2 | 19 | 6 | 3 | 0.31 | 1 | 15 | 6 | 15 | 14 | 0 | 14 | 34 | 416 | 45 | 284 | 145 | 183 | 87 | 126 | 58 | 111 | 8 | 3 | 2 | 47 |
385 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/image_transforms.py | transformers.image_transforms.NumpyToTensor | import numpy as np
class NumpyToTensor:
"""
Convert a numpy array to a PyTorch tensor.
"""
def __call__(self, image: np.ndarray):
return torch.from_numpy(image.transpose(2, 0, 1)).contiguous() |
class NumpyToTensor:
'''
Convert a numpy array to a PyTorch tensor.
'''
def __call__(self, image: np.ndarray):
pass | 2 | 1 | 4 | 0 | 2 | 2 | 1 | 1.67 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 9 | 1 | 3 | 2 | 1 | 5 | 3 | 2 | 1 | 1 | 0 | 0 | 1 |
386 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/image_transforms.py | transformers.image_transforms.PaddingMode | from .utils import ExplicitEnum, TensorType, is_torch_tensor
class PaddingMode(ExplicitEnum):
"""
Enum class for the different padding modes to use when padding images.
"""
CONSTANT = 'constant'
REFLECT = 'reflect'
REPLICATE = 'replicate'
SYMMETRIC = 'symmetric' |
class PaddingMode(ExplicitEnum):
'''
Enum class for the different padding modes to use when padding images.
'''
pass | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0.6 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 9 | 1 | 5 | 5 | 4 | 3 | 5 | 5 | 4 | 0 | 1 | 0 | 0 |
387 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/image_utils.py | transformers.image_utils.AnnotationFormat | from .utils import ExplicitEnum, is_numpy_array, is_torch_available, is_torch_tensor, is_torchvision_available, is_torchvision_v2_available, is_vision_available, logging, requires_backends, to_numpy
class AnnotationFormat(ExplicitEnum):
COCO_DETECTION = 'coco_detection'
COCO_PANOPTIC = 'coco_panoptic' |
class AnnotationFormat(ExplicitEnum):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 | 0 | 3 | 3 | 2 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
388 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/image_utils.py | transformers.image_utils.AnnotionFormat | from .utils import ExplicitEnum, is_numpy_array, is_torch_available, is_torch_tensor, is_torchvision_available, is_torchvision_v2_available, is_vision_available, logging, requires_backends, to_numpy
class AnnotionFormat(ExplicitEnum):
COCO_DETECTION = AnnotationFormat.COCO_DETECTION.value
COCO_PANOPTIC = Annot... |
class AnnotionFormat(ExplicitEnum):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 | 0 | 3 | 3 | 2 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
389 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/image_utils.py | transformers.image_utils.ChannelDimension | from .utils import ExplicitEnum, is_numpy_array, is_torch_available, is_torch_tensor, is_torchvision_available, is_torchvision_v2_available, is_vision_available, logging, requires_backends, to_numpy
class ChannelDimension(ExplicitEnum):
FIRST = 'channels_first'
LAST = 'channels_last' |
class ChannelDimension(ExplicitEnum):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 | 0 | 3 | 3 | 2 | 0 | 3 | 3 | 2 | 0 | 1 | 0 | 0 |
390 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/image_utils.py | transformers.image_utils.ImageFeatureExtractionMixin | import numpy as np
from typing import Optional, Union
from .utils import ExplicitEnum, is_numpy_array, is_torch_available, is_torch_tensor, is_torchvision_available, is_torchvision_v2_available, is_vision_available, logging, requires_backends, to_numpy
class ImageFeatureExtractionMixin:
"""
Mixin that contain ... |
class ImageFeatureExtractionMixin:
'''
Mixin that contain utilities for preparing image features.
'''
def _ensure_format_supported(self, image):
pass
def to_pil_image(self, image, rescale=None):
'''
Converts `image` to a PIL Image. Optionally rescales it and puts the chann... | 12 | 11 | 30 | 5 | 15 | 11 | 6 | 0.77 | 0 | 7 | 0 | 0 | 11 | 0 | 11 | 11 | 349 | 65 | 162 | 29 | 149 | 124 | 142 | 29 | 129 | 14 | 0 | 4 | 66 |
391 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/image_utils.py | transformers.image_utils.ImageType | from .utils import ExplicitEnum, is_numpy_array, is_torch_available, is_torch_tensor, is_torchvision_available, is_torchvision_v2_available, is_vision_available, logging, requires_backends, to_numpy
class ImageType(ExplicitEnum):
PIL = 'pillow'
TORCH = 'torch'
NUMPY = 'numpy' |
class ImageType(ExplicitEnum):
pass | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 6 | 0 | 6 | 6 | 5 | 0 | 6 | 6 | 5 | 0 | 1 | 0 | 0 |
392 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/image_utils.py | transformers.image_utils.SizeDict | from typing import Optional, Union
from dataclasses import dataclass
@dataclass(frozen=True)
class SizeDict:
"""
Hashable dictionary to store image size information.
"""
height: Optional[int] = None
width: Optional[int] = None
longest_edge: Optional[int] = None
shortest_edge: Optional[int] ... | @dataclass(frozen=True)
class SizeDict:
'''
Hashable dictionary to store image size information.
'''
def __getitem__(self, key):
pass | 3 | 1 | 4 | 0 | 4 | 0 | 2 | 0.27 | 0 | 1 | 0 | 0 | 1 | 0 | 1 | 1 | 16 | 2 | 11 | 8 | 9 | 3 | 11 | 8 | 9 | 2 | 0 | 1 | 2 |
393 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/integrations/bitnet.py | transformers.integrations.bitnet.BitLinear | class BitLinear(nn.Module):
def __init__(self, in_features: int, out_features: int, bias: bool, device=None, dtype=None, use_rms_norm: bool=False, rms_norm_eps: float=1e-06):
super().__init__()
self.dtype = dtype
self.in_features = in_features
self.out_features = out_features
... | class BitLinear(nn.Module):
def __init__(self, in_features: int, out_features: int, bias: bool, device=None, dtype=None, use_rms_norm: bool=False, rms_norm_eps: float=1e-06):
pass
@torch.compile
def activation_quant(self, input, num_bits=8):
'''
Activation function : Performs symmet... | 7 | 1 | 15 | 0 | 11 | 4 | 2 | 0.33 | 1 | 3 | 0 | 0 | 4 | 4 | 4 | 14 | 65 | 4 | 46 | 20 | 39 | 15 | 29 | 18 | 24 | 2 | 1 | 1 | 6 |
394 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/integrations/deepspeed.py | transformers.integrations.deepspeed.HfDeepSpeedConfig | from ..dependency_versions_check import dep_version_check
class HfDeepSpeedConfig(DeepSpeedConfig):
"""
This object contains a DeepSpeed configuration dictionary and can be quickly queried for things like zero stage.
A `weakref` of this object is stored in the module's globals to be able to access the con... |
class HfDeepSpeedConfig(DeepSpeedConfig):
'''
This object contains a DeepSpeed configuration dictionary and can be quickly queried for things like zero stage.
A `weakref` of this object is stored in the module's globals to be able to access the config from areas where
things like the Trainer object is ... | 2 | 1 | 6 | 0 | 5 | 1 | 1 | 2 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | 11 | 23 | 5 | 6 | 2 | 4 | 12 | 6 | 2 | 4 | 1 | 1 | 0 | 1 |
395 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/integrations/deepspeed.py | transformers.integrations.deepspeed.HfTrainerDeepSpeedConfig | from functools import partialmethod
class HfTrainerDeepSpeedConfig(HfDeepSpeedConfig):
"""
The `HfTrainerDeepSpeedConfig` object is meant to be created during `TrainingArguments` object creation and has the
same lifespan as the latter.
"""
def __init__(self, config_file_or_dict):
super()._... |
class HfTrainerDeepSpeedConfig(HfDeepSpeedConfig):
'''
The `HfTrainerDeepSpeedConfig` object is meant to be created during `TrainingArguments` object creation and has the
same lifespan as the latter.
'''
def __init__(self, config_file_or_dict):
pass
def dtype(self):
pass
... | 8 | 5 | 30 | 3 | 21 | 5 | 4 | 0.28 | 1 | 3 | 0 | 0 | 6 | 2 | 6 | 17 | 190 | 27 | 128 | 19 | 121 | 36 | 72 | 19 | 65 | 8 | 2 | 2 | 24 |
396 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/integrations/executorch.py | transformers.integrations.executorch.TorchExportableModuleWithStaticCache | import torch
from ..modeling_utils import ALL_ATTENTION_FUNCTIONS, PreTrainedModel
from typing import Callable, Optional
from ..cache_utils import DynamicCache, DynamicLayer, DynamicSlidingWindowLayer, EncoderDecoderCache, StaticCache
class TorchExportableModuleWithStaticCache(torch.nn.Module):
"""
A recipe mo... |
class TorchExportableModuleWithStaticCache(torch.nn.Module):
'''
A recipe module designed to make a `PreTrainedModel` exportable with `torch.export`,
specifically for decoder-only LM to `StaticCache`. This module ensures that the
exported model is compatible with further lowering and execution in `Exec... | 5 | 4 | 44 | 6 | 25 | 13 | 4 | 0.62 | 1 | 9 | 0 | 0 | 2 | 3 | 3 | 13 | 145 | 22 | 76 | 22 | 69 | 47 | 39 | 19 | 35 | 5 | 1 | 2 | 12 |
397 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/integrations/fbgemm_fp8.py | transformers.integrations.fbgemm_fp8.FbgemmFp8Linear | class FbgemmFp8Linear(torch.nn.Linear):
def __init__(self, in_features, out_features, bias, weight_dtype=torch.float32):
super().__init__(in_features, out_features, bias)
self.in_features = in_features
self.out_features = out_features
self.weight = torch.nn.Parameter(torch.zeros((ou... | class FbgemmFp8Linear(torch.nn.Linear):
def __init__(self, in_features, out_features, bias, weight_dtype=torch.float32):
pass
def forward(self, x):
pass | 3 | 0 | 18 | 2 | 13 | 4 | 2 | 0.27 | 1 | 2 | 0 | 0 | 2 | 5 | 2 | 12 | 37 | 4 | 26 | 11 | 23 | 7 | 21 | 10 | 18 | 2 | 1 | 1 | 4 |
398 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/integrations/ggml.py | transformers.integrations.ggml.GGUFGPTConverter | from ..convert_slow_tokenizer import GemmaConverter, GPT2Converter, LlamaConverter, Qwen2Converter, T5Converter
from tokenizers import Tokenizer, decoders, normalizers, pre_tokenizers, processors
class GGUFGPTConverter(GPT2Converter):
def __init__(self, tokenizer_dict):
self.original_tokenizer = GGUFToken... |
class GGUFGPTConverter(GPT2Converter):
def __init__(self, tokenizer_dict):
pass
def converted(self) -> Tokenizer:
pass | 3 | 0 | 4 | 0 | 4 | 0 | 1 | 0 | 1 | 3 | 1 | 0 | 2 | 2 | 2 | 5 | 10 | 1 | 9 | 8 | 6 | 0 | 9 | 8 | 6 | 1 | 2 | 0 | 2 |
399 | huggingface/pytorch-pretrained-BERT | huggingface_pytorch-pretrained-BERT/src/transformers/integrations/ggml.py | transformers.integrations.ggml.GGUFGemmaConverter | from ..convert_slow_tokenizer import GemmaConverter, GPT2Converter, LlamaConverter, Qwen2Converter, T5Converter
from tokenizers import Tokenizer, decoders, normalizers, pre_tokenizers, processors
from tokenizers.models import BPE, Unigram
class GGUFGemmaConverter(GemmaConverter):
def __init__(self, tokenizer_dict... |
class GGUFGemmaConverter(GemmaConverter):
def __init__(self, tokenizer_dict):
pass
def vocab(self, proto):
pass
def normalizer(self, proto):
pass
def decoder(self, replacement, add_prefix_space):
pass
def converted(self) -> Tokenizer:
pass | 6 | 0 | 12 | 2 | 10 | 0 | 2 | 0.02 | 1 | 3 | 1 | 0 | 5 | 3 | 5 | 21 | 63 | 12 | 50 | 20 | 44 | 1 | 38 | 20 | 32 | 4 | 3 | 2 | 12 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.