text: 
  
  TITLE
  TorchScript warning
  
  COMMENTS
  4
  
  REACTIONS
  +1: 0
  -1: 0
  laugh: 0
  hooray: 0
  heart: 0
  rocket: 0
  eyes: 0
  
  BODY
  # 📚 Migration
  
  ## Information
  
  <!-- Important information -->
  
  Model I am using (**Bert**, XLNet ...):
  
  Language I am using the model on (English, **Chinese** ...):
  
  The problem arises when using:
  * [yes] the official example scripts: (give details below)
  * [ ] my own modified scripts: (give details below)
  
  The tasks I am working on is:
  * [yes] an official GLUE/SQUaD task: (give the name)
  * [ ] my own task or dataset: (give details below)
  
  ## Details
  when i use official script to create serializable and optimizable models from PyTorch, i meed these warnings.
  https://huggingface.co/transformers/torchscript.html
  
  I set torchscript=True, it seems doesn't work. And when i use torchscript in my model, the results seems different from the results before i serialize my model.
  
  
  > /opt/anaconda3/envs/py37/lib/python3.7/site-packages/transformers/models/bert/modeling_bert.py:955: TracerWarning: Converting a tensor to a Python index might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
    buffered_token_type_ids = self.embeddings.token_type_ids[:, :seq_length]
  /opt/anaconda3/envs/py37/lib/python3.7/site-packages/transformers/models/bert/modeling_bert.py:201: TracerWarning: Converting a tensor to a Python index might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
    position_ids = self.position_ids[:, past_key_values_length : seq_length + past_key_values_length]
  /opt/anaconda3/envs/py37/lib/python3.7/site-packages/transformers/modeling_utils.py:2169: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
    input_tensor.shape[chunk_dim] == tensor_shape for input_tensor in input_tensors
  
  
  
  
  ## Environment info
  <!-- You can run the command `python transformers-cli env` and copy-and-paste its output below.
       Don't forget to fill out the missing fields in that output! -->
   
  - `transformers` version:4.10.0
  - Platform:linux
  - Python version:3.7.11
  - PyTorch version (GPU?):1.7.1(cpu)
  - Using GPU in script?:No
  - Using distributed or parallel set-up in script?:No
  
  <!-- IMPORTANT: which version of the former library do you use? -->
  * `pytorch-transformers` or `pytorch-pretrained-bert` version (or branch):
  
  ## Checklist
  
  - [ yes] I have read the migration guide in the readme.
   ([pytorch-transformers](https://github.com/huggingface/transformers#migrating-from-pytorch-transformers-to-transformers);
    [pytorch-pretrained-bert](https://github.com/huggingface/transformers#migrating-from-pytorch-pretrained-bert-to-transformers))
  - [ yes] I checked if a related official extension example runs on my machine.
  
  
  