readme: ---
  license: gpl-3.0
  tags:
  - conversational
  - gpt2
  language: 
  - en
  datasets:
  - wikipedia
  widget:
  - text: "Where are you from?"
    example_title: "Basic question 1"
  ---
  
  # DialoGPT small base model (uncased)
  
  Pretrained model on English language using a masked language modeling (MLM) objective. 
  
  ## Model description
  
  BERT is a transformers model pretrained on a large corpus of English data in a self-supervised fashion. This means it
  was pretrained on the raw texts only, with no humans labelling them in any way (which is why it can use lots of
  publicly available data) with an automatic process to generate inputs and labels from those texts. More precisely, it
  was pretrained with two objectives:
  
  - Masked language modeling (MLM): taking a sentence, the model randomly masks 15% of the words in the input then run
    the entire masked sentence through the model and has to predict the masked words. This is different from traditional
    recurrent neural networks (RNNs) that usually see the words one after the other, or from autoregressive models like
    GPT which internally mask the future tokens. It allows the model to learn a bidirectional representation of the
    sentence.
  - Next sentence prediction (NSP): the models concatenates two masked sentences as inputs during pretraining. Sometimes
    they correspond to sentences that were next to each other in the original text, sometimes not. The model then has to
    predict if the two sentences were following each other or not.
  
  This way, the model learns an inner representation of the English language that can then be used to extract features
  useful for downstream tasks: if you have a dataset of labeled sentences for instance, you can train a standard
  classifier using the features produced by the BERT model as inputs.
  
  ### How to use
  
  You can use this model directly with a pipeline for masked language modeling:
  
  ```python
  import torch
  from transformers import AutoModelWithLMHead, AutoTokenizer
  tokenizer = AutoTokenizer.from_pretrained("erikycd/chatbot_hadita")
  model = AutoModelWithLMHead.from_pretrained("erikycd/chatbot_hadita") 
  exit_commands = ('bye', 'quit')
  text = ''
  while text not in exit_commands:
      text = input('User: ')
      input_ids = tokenizer.encode(text + tokenizer.eos_token, return_tensors = "pt")
      bot_input_ids = torch.cat([input_ids])
      chat_history_ids = model.generate(            
        bot_input_ids,
        max_length = 30,
        do_sample = True,
        top_p = 0.95,
        top_k = 0,
        temperature = 0.75,
        pad_token_id = tokenizer.eos_token_id
      )
      output = tokenizer.decode(chat_history_ids[:, bot_input_ids.shape[-1]:][0], skip_special_tokens = True)
      print('Chatbot: ', output)
  ```
  
  
  