text: 
  
  TITLE
  Problem while using tokenizer.encode_plus for sentence pairs
  
  COMMENTS
  2
  
  REACTIONS
  +1: 0
  -1: 0
  laugh: 0
  hooray: 0
  heart: 0
  rocket: 0
  eyes: 0
  
  BODY
  # ❓ Questions & Help
  
  <!-- The GitHub issue tracker is primarly intended for bugs, feature requests,
       new models and benchmarks, and migration questions. For all other questions,
       we direct you to the Hugging Face forum: https://discuss.huggingface.co/ .
       You can also try Stack Overflow (SO) where a whole community of PyTorch and
       Tensorflow enthusiast can help you out. In this case, make sure to tag your
       question with the right deep learning framework as well as the
       huggingface-transformers tag: 
       https://stackoverflow.com/questions/tagged/huggingface-transformers 
       -->
  
  ## Details
  Hi, thanks for this great work.
  I was trying to use tokenizer.encode_plus to encode sentence pairs. The code looks like
  
  ```py
  training_encoded_dict = tokenizer.encode_plus(
              seq0,
              seq1,
              add_spicial_tokens = True,
              max_length = 256,
              truncation_strategy = 'only_second',
              pad_to_max_length = True,
              return_attention_mask = True,
              return_token_type_ids = True,
              return_tensors = 'pt',
  
          )
  ```
  
  However, the problem looks like
  ```
  ---------------------------------------------------------------------------
  AssertionError                            Traceback (most recent call last)
  <ipython-input-17-ae3ce93d62ba> in <module>()
       24             return_attention_mask = True,
       25             return_token_type_ids = True,
  ---> 26             return_tensors = 'pt',
       27 
       28         )
  
  2 frames
  /usr/local/lib/python3.6/dist-packages/transformers/tokenization_utils.py in truncate_sequences(self, ids, pair_ids, num_tokens_to_remove, truncation_strategy, stride)
     2068             ids = ids[:-num_tokens_to_remove]
     2069         elif truncation_strategy == "only_second":
  -> 2070             assert pair_ids is not None and len(pair_ids) > num_tokens_to_remove
     2071             window_len = min(len(pair_ids), stride + num_tokens_to_remove)
     2072             overflowing_tokens = pair_ids[-window_len:]
  
  AssertionError: 
  ```
  
  This issue doesn't occur while using truncation_strategy = 'longest_first', and it happens with other truncation_strategy such as 'only_second' and 'only_first'.
  I was wondering does anyone have the same issue or have any idea about how to fix it? Thanks a lot in advance.
  **A link to original question on the forum/Stack Overflow**: