MCPcopy Create free account
hub / github.com/SooLab/CGFormer / batch_encode_plus

Method batch_encode_plus

bert/tokenization_utils_base.py:1764–1833  ·  view source on GitHub ↗

Returns a dictionary containing the encoded sequence or sequence pair and additional information: the mask for sequence classification and the overflowing elements if a ``max_length`` is specified. Args: batch_text_or_text_pairs (:obj:`List[str]`, :obj:`List[Tu

(
        self,
        batch_text_or_text_pairs: Union[
            List[TextInput],
            List[TextInputPair],
            List[PreTokenizedInput],
            List[PreTokenizedInputPair],
            List[EncodedInput],
            List[EncodedInputPair],
        ],
        add_special_tokens: bool = True,
        padding: Union[bool, str] = False,
        truncation: Union[bool, str] = False,
        max_length: Optional[int] = None,
        stride: int = 0,
        is_pretokenized: bool = False,
        pad_to_multiple_of: Optional[int] = None,
        return_tensors: Optional[Union[str, TensorType]] = None,
        return_token_type_ids: Optional[bool] = None,
        return_attention_mask: Optional[bool] = None,
        return_overflowing_tokens: bool = False,
        return_special_tokens_mask: bool = False,
        return_offsets_mapping: bool = False,
        return_length: bool = False,
        verbose: bool = True,
        **kwargs
    )

Source from the content-addressed store, hash-verified

1762
1763 @add_end_docstrings(ENCODE_KWARGS_DOCSTRING, ENCODE_PLUS_ADDITIONAL_KWARGS_DOCSTRING)
1764 def batch_encode_plus(
1765 self,
1766 batch_text_or_text_pairs: Union[
1767 List[TextInput],
1768 List[TextInputPair],
1769 List[PreTokenizedInput],
1770 List[PreTokenizedInputPair],
1771 List[EncodedInput],
1772 List[EncodedInputPair],
1773 ],
1774 add_special_tokens: bool = True,
1775 padding: Union[bool, str] = False,
1776 truncation: Union[bool, str] = False,
1777 max_length: Optional[int] = None,
1778 stride: int = 0,
1779 is_pretokenized: bool = False,
1780 pad_to_multiple_of: Optional[int] = None,
1781 return_tensors: Optional[Union[str, TensorType]] = None,
1782 return_token_type_ids: Optional[bool] = None,
1783 return_attention_mask: Optional[bool] = None,
1784 return_overflowing_tokens: bool = False,
1785 return_special_tokens_mask: bool = False,
1786 return_offsets_mapping: bool = False,
1787 return_length: bool = False,
1788 verbose: bool = True,
1789 **kwargs
1790 ) -> BatchEncoding:
1791 """
1792 Returns a dictionary containing the encoded sequence or sequence pair and additional information:
1793 the mask for sequence classification and the overflowing elements if a ``max_length`` is specified.
1794
1795 Args:
1796 batch_text_or_text_pairs (:obj:`List[str]`, :obj:`List[Tuple[str, str]]`,
1797 :obj:`List[List[str]]`, :obj:`List[Tuple[List[str], List[str]]]`,
1798 and for not-fast tokenizers, also:
1799 :obj:`List[List[int]]`, :obj:`List[Tuple[List[int], List[int]]]`):
1800 Batch of sequences or pair of sequences to be encoded.
1801 This can be a list of string/string-sequences/int-sequences or a list of pair of
1802 string/string-sequences/int-sequence (see details in encode_plus)
1803 """
1804
1805 # Backward compatibility for 'truncation_strategy', 'pad_to_max_length'
1806 padding_strategy, truncation_strategy, max_length, kwargs = self._get_padding_truncation_strategies(
1807 padding=padding,
1808 truncation=truncation,
1809 max_length=max_length,
1810 pad_to_multiple_of=pad_to_multiple_of,
1811 verbose=verbose,
1812 **kwargs,
1813 )
1814
1815 return self._batch_encode_plus(
1816 batch_text_or_text_pairs=batch_text_or_text_pairs,
1817 add_special_tokens=add_special_tokens,
1818 padding_strategy=padding_strategy,
1819 truncation_strategy=truncation_strategy,
1820 max_length=max_length,
1821 stride=stride,

Callers 1

__call__Method · 0.95

Calls 2

_batch_encode_plusMethod · 0.95

Tested by

no test coverage detected