text: 
  
  TITLE
  Adding option to truncation from beginning instead of end, for both longest_first and longest_second
  
  COMMENTS
  6
  
  REACTIONS
  +1: 7
  -1: 0
  laugh: 0
  hooray: 0
  heart: 0
  rocket: 0
  eyes: 0
  
  BODY
  # 🚀 Feature request
  
  <!-- A clear and concise description of the feature proposal.
       Please provide a link to the paper and code in case they exist. -->
  
  The current [truncation strategies](https://huggingface.co/transformers/preprocessing.html#everything-you-always-wanted-to-know-about-padding-and-truncation) only provide truncation from end of the input sentence. This may be enough for most cases, but is not applicable for dialog tasks.
  
  Say, you are concatenating an input dialog context to BERT. If the input length > max_length (256/ 512), then the tokens are truncated from the ending i.e. the most recent utterances in the dialog.
  
  In some cases, you want the most recent utterances to be included in the input and if truncation needs to be done, then the oldest utterances be truncated i.e. truncation from the beginning.
  
  This can be done manually in own code base outside of Transformers library, but it's not ideal.
  
  Truncation outside of model will be done most likely on full words to truncate from beginning and fit them to model max length (say you truncate from beginning and reduce input to 254 words). But, these words will be converted to subwords when fed to BertTokenizer and the final input will be > 256, thus resulting in words being dropped from the last utterance again.
  
  To do this properly outside of the Transformers library, one would need to instantiate the same Tokenizer object, tokenize each input and then truncate from beginning, then convert ids back to tokens and then either reconstruct the input from the truncated tokenized version or skip the tokenizer call inside the Transformers library.
  
  ## Motivation
  
  <!-- Please outline the motivation for the proposal. Is your feature request
       related to a problem? e.g., I'm always frustrated when [...]. If this is related
       to another GitHub issue, please link here too. -->
  
  ## Your contribution
  
  <!-- Is there any way that you could help, e.g. by submitting a PR?
       Make sure to read the CONTRIBUTING.MD readme:
       https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md -->
  