Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

ParlAI super command w/ script registry #2859

Merged
merged 32 commits into from
Jul 21, 2020
Merged

ParlAI super command w/ script registry #2859

merged 32 commits into from
Jul 21, 2020

Conversation

stephenroller
Copy link
Contributor

Patch description
This is a remake of #2772 to get around the fact that I was tempted to approve my own PR.

This PR remakes the parlai super command. Overall it contains:

  • The script registry, allowing scripts to be defined within user modules
  • This includes support for aliases and marking
  • The parlai super command now reads the script registry in order to provide a list of commands.
  • Support for bash arg completion (see screenshot)
  • Replacement of --show-advanced-args with --helpall, which is implemented more cleanly
  • Minor updates to scripts in a few places (add descriptions, etc)
  • Updated information in quickstart
  • A lot of obtuse argparse hacking to make the behavior really nice

Some other related changes:

Testing steps
SOOOOO much manual testing. CI.

One sad thing: bash completion is a bit slow, because it depends on importing pytorch. Can't get around that, sadly.

Screenshots & Logs

$ parlai help
usage: parlai [-h] [--helpall] COMMAND ...

       _
      /")
     //)
  ==//'=== ParlAI
   /

optional arguments:
  -h, --help               show this help message and exit
  --helpall                show all commands, including advanced ones.

Commands:

  display_data (dd)        Display data from a task
  display_model (dm)       Display model predictions.
  eval_model (em, eval)    Evaluate a model
  train_model (tm, train)  Train a model
  interactive (i)          Interactive chat with a model on the command line
  safe_interactive         Like interactive, but adds a safety filter
  self_chat                Generate self-chats of a model

$ parlai helpall
usage: parlai [-h] [--helpall] COMMAND ...

       _
      /")
     //)
  ==//'=== ParlAI
   /

optional arguments:
  -h, --help                        show this help message and exit
  --helpall                         show all commands, including advanced ones.

Commands:

  help (h)                          List the main commands
  helpall                           List all commands, including advanced ones.
  build_candidates                  Build the candidate responses for a retrieval model
  build_dict                        Build a dictionary.
  convert_to_fasttext               Convert data for ingestion in fastText
  convert_to_parlai                 Dump a task to a standardized format
  convo_render                      Render data as HTML
  data_stats                        Compute data statistics
  detect_offensive                  Check task for offensive language
  display_data (dd)                 Display data from a task
  display_model (dm)                Display model predictions.
  eval_model (em, eval)             Evaluate a model
  train_model (tm, train)           Train a model
  eval_wordstat                     Compute statistics from model predictions
  extract_image_feature             Load/extract image features
  interactive (i)                   Interactive chat with a model on the command line
  interactive_web (iweb)            Interactive chat with a model in a web browser
  multiprocessing_train (mp_train)  Train a model
  party (parrot)                    Throw a party!
  profile_interactive               Interactive chat with a model
  profile_train                     cProfile a training run
  safe_interactive                  Like interactive, but adds a safety filter
  self_chat                         Generate self-chats of a model
  verify_data                       Check tasks for common errors

$ parlai dd -t convai2
17:53:56 | creating task(s): convai2
17:53:56 | loading fbdialog data: /private/home/roller/working/parlai/data/ConvAI2/train_self_original.txt
- - - NEW EPISODE: convai2 - - -
your persona: i like to remodel homes.
your persona: i like to go hunting.
your persona: i like to shoot a bow.
your persona: my favorite holiday is halloween.
hi , how are you doing ? i'm getting ready to do some cheetah chasing to stay in shape .
   you must be very fast . hunting is one of my favorite hobbies .
i am ! for my hobby i like to do canning or some whittling .
   i also remodel homes when i am not out bow hunting .
that's neat . when i was in high school i placed 6th in 100m dash !
   that's awesome . do you have a favorite season or time of year ?
i do not . but i do have a favorite meat since that is all i eat exclusively .
   what is your favorite meat to eat ?
i would have to say its prime rib . do you have any favorite foods ?
   i like chicken or macaroni and cheese .
do you have anything planned for today ? i think i am going to do some canning .
   i am going to watch football . what are you canning ?
i think i will can some jam . do you also play footfall for fun ?
   if i have time outside of hunting and remodeling homes . which is not much !
- - - NEW EPISODE: convai2 - - -
your persona: my mom is my best friend.
your persona: i have four sisters.
your persona: i believe that mermaids are real.
your persona: i love iced tea.
hi , how are you doing today ?
   i am spending time with my 4 sisters what are you up to
wow , four sisters . just watching game of thrones .
   that is a good show i watch that while drinking iced tea
i agree . what do you do for a living ?
   i'm a researcher i'm researching the fact that mermaids are real
17:53:58 | loaded 17878 episodes with a total of 131438 examples

Example of arg completion
Note that it even works with model or task level args! OMG!

image

Copy link
Contributor

@emilydinan emilydinan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i really like the aliases

from parlai.utils.strings import colorize

logo = ""
logo += colorize(' _', 'red') + "\n"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is so extra

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obama

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seriously, gotta procrastinate on PSC one way or another.

@stephenroller stephenroller merged commit d2ed272 into master Jul 21, 2020
@stephenroller stephenroller deleted the argcomproller branch July 21, 2020 18:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants