examples/sentiment_analysis/skep/predict_opinion.py
def convert_example(example, tokenizer, max_seq_length=512, is_test=False):
    """
    Builds model inputs from a sequence or a pair of sequence for sequence classification tasks
    by concatenating and adding special tokens. And creates a mask from the two sequences passed 
    to be used in a sequence-pair classification task.
        
    A skep_ernie_1.0_large_ch/skep_ernie_2.0_large_en sequence has the following format:
    ::
        - single sequence: ``[CLS] X [SEP]``
        - pair of sequences: ``[CLS] A [SEP] B [SEP]``

    A skep_ernie_1.0_large_ch/skep_ernie_2.0_large_en sequence pair mask has the following format:
    ::

        0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1
        | first sequence    | second sequence |

    If `token_ids_1` is `None`, this method only returns the first portion of the mask (0s).

    Args:
        example(obj:`list[str]`): List of input data, containing text and label if it have label.
        tokenizer(obj:`PretrainedTokenizer`): This tokenizer inherits from :class:`~paddlenlp.transformers.PretrainedTokenizer` 
            which contains most of the methods. Users should refer to the superclass for more information regarding methods.
        max_seq_len(obj:`int`): The maximum total input sequence length after tokenization. 
            Sequences longer than this will be truncated, sequences shorter will be padded.

    Returns:
        input_ids(obj:`list[int]`): The list of token ids.
        token_type_ids(obj: `list[int]`): List of sequence pair mask. 
    """
    tokens = example["tokens"]
    encoded_inputs = tokenizer(
        tokens,
        return_length=True,
        is_split_into_words=True,
        max_seq_len=max_seq_length)
    input_ids = np.array(encoded_inputs["input_ids"], dtype="int64")
    token_type_ids = np.array(encoded_inputs["token_type_ids"], dtype="int64")
    seq_len = np.array(encoded_inputs["seq_len"], dtype="int64")

    return input_ids, token_type_ids, seq_len

    Builds model inputs from a sequence or a pair of sequence for sequence classification tasks
    by concatenating and adding special tokens. And creates a mask from the two sequences passed 
    to be used in a sequence-pair classification task.
        
    A skep_ernie_1.0_large_ch/skep_ernie_2.0_large_en sequence has the following format:
    ::
        - single sequence: ``[CLS] X [SEP]``
        - pair of sequences: ``[CLS] A [SEP] B [SEP]``

    A skep_ernie_1.0_large_ch/skep_ernie_2.0_large_en sequence pair mask has the following format:
    ::

        0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1
        | first sequence    | second sequence |

    If `token_ids_1` is `None`, this method only returns the first portion of the mask (0s).

    Args:
        example(obj:`list[str]`): List of input data, containing text and label if it have label.
        tokenizer(obj:`PretrainedTokenizer`): This tokenizer inherits from :class:`~paddlenlp.transformers.PretrainedTokenizer` 
            which contains most of the methods. Users should refer to the superclass for more information regarding methods.
        max_seq_len(obj:`int`): The maximum total input sequence length after tokenization. 
            Sequences longer than this will be truncated, sequences shorter will be padded.

    Returns:
        input_ids(obj:`list[int]`): The list of token ids.
        token_type_ids(obj: `list[int]`): List of sequence pair mask. 
    
Builds model inputs from a sequence or a pair of sequence for sequence classification tasks
by concatenating and adding special tokens. And creates a mask from the two sequences passed
to be used in a sequence-pair classification task.







If `token_ids_1` is `None`, this method only returns the first portion of the mask (0s).
Builds model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens . And creates a mask from the two sequences passed to be used in a sequence - pair classification task . If ` token_ids_1 ` is ` None ` this method only returns the first portion of the mask ( 0s ) .
def convert_example(example, tokenizer, max_seq_length=512, is_test=False):
    tokens = example["tokens"]
    encoded_inputs = tokenizer(
        tokens,
        return_length=True,
        is_split_into_words=True,
        max_seq_len=max_seq_length)
    input_ids = np.array(encoded_inputs["input_ids"], dtype="int64")
    token_type_ids = np.array(encoded_inputs["token_type_ids"], dtype="int64")
    seq_len = np.array(encoded_inputs["seq_len"], dtype="int64")
    return input_ids, token_type_ids, seq_len
def convert_example ( example , tokenizer , max_seq_length = 512 , is_test = False ) : tokens = example [ "tokens" ] encoded_inputs = tokenizer ( tokens , return_length = True , is_split_into_words = True , max_seq_len = max_seq_length ) input_ids = np . array ( encoded_inputs [ "input_ids" ] , dtype = "int64" ) token_type_ids = np . array ( encoded_inputs [ "token_type_ids" ] , dtype = "int64" ) seq_len = np . array ( encoded_inputs [ "seq_len" ] , dtype = "int64" ) return input_ids , token_type_ids , seq_len
Builds model inputs from a sequence or a pair of sequence for sequence classification tasks
by concatenating and adding special tokens.
Builds model inputs from a sequence or a pair of sequence for sequence classification tasks by concatenating and adding special tokens .
"""
    Builds model inputs from a sequence or a pair of sequence for sequence classification tasks
    by concatenating and adding special tokens. And creates a mask from the two sequences passed 
    to be used in a sequence-pair classification task.
        
    A skep_ernie_1.0_large_ch/skep_ernie_2.0_large_en sequence has the following format:
    ::
        - single sequence: ``[CLS] X [SEP]``
        - pair of sequences: ``[CLS] A [SEP] B [SEP]``

    A skep_ernie_1.0_large_ch/skep_ernie_2.0_large_en sequence pair mask has the following format:
    ::

        0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1
        | first sequence    | second sequence |

    If `token_ids_1` is `None`, this method only returns the first portion of the mask (0s).

    Args:
        example(obj:`list[str]`): List of input data, containing text and label if it have label.
        tokenizer(obj:`PretrainedTokenizer`): This tokenizer inherits from :class:`~paddlenlp.transformers.PretrainedTokenizer` 
            which contains most of the methods. Users should refer to the superclass for more information regarding methods.
        max_seq_len(obj:`int`): The maximum total input sequence length after tokenization. 
            Sequences longer than this will be truncated, sequences shorter will be padded.

    Returns:
        input_ids(obj:`list[int]`): The list of token ids.
        token_type_ids(obj: `list[int]`): List of sequence pair mask. 
    """
`list[int]`): The list of token ids.
token_type_ids(obj: `list[int]`): List of sequence pair mask.
` list [ int ] ` ) : The list of token ids . token_type_ids ( obj : ` list [ int ] ` ) : List of sequence pair mask .
input_ids(obj
example
tokenizer
max_seq_length
is_test
example(obj
`list[str]`): List of input data, containing text and label if it have label.
` list [ str ] ` ) : List of input data containing text and label if it have label .
tokenizer(obj
`PretrainedTokenizer`): This tokenizer inherits from :class:`~paddlenlp.transformers.PretrainedTokenizer`
which contains most of the methods. Users should refer to the superclass for more information regarding methods.
` PretrainedTokenizer ` ) : This tokenizer inherits from : class : ` ~paddlenlp . transformers . PretrainedTokenizer ` which contains most of the methods . Users should refer to the superclass for more information regarding methods .
max_seq_len(obj
`int`): The maximum total input sequence length after tokenization.
Sequences longer than this will be truncated, sequences shorter will be padded.
` int ` ) : The maximum total input sequence length after tokenization . Sequences longer than this will be truncated sequences shorter will be padded .