Code Monkey home page Code Monkey logo

readermodel's Introduction

Reader Model Instructions

Data can be found here

๐Ÿ’ฅ Installation

  1. Virtual env: conda env create -f environment.yml python=3.6

  2. Install the COMeT

    • Follow the instruction here.
    • There are some extra packages you need to install here.
    conda install -c pytorch pytorch
    pip install ftfy
    • First, download the pretrained models from here.

    • Then untar the file:

    tar -xvzf pretrained_models.tar.gz
    • Then run the following script to interactively generate arbitrary ATOMIC event effects:
      python scripts/interactive/atomic_single_example.py --model_file pretrained_models/atomic_pretrained_model.pickle
    • Some absolute paths have to be changed here.

    • How to use COMeT to convert sentence as knowledge graph?

    python KG_gen/KG_gen.py
  3. Install verbatlas SRL

    • The file is located at ./verbatlas/src
    • Installation follows here
  4. No need to prepare for verbnet parser. Location: ./semparse-core/

  5. Install allennlp and allennlp-model based on HERE.

  6. Install new comet-atomic 2020 HERE.

Possible Bugs!!!

  1. Pattern cannot used in python 3.7 Solution

  2. No module named '_ctypes'

sudo apt-get install libffi-dev
  1. When run SRL, get __init__() got an unexpected keyword argument 'max_n'
pip uninstall py-rouge
pip install py-rouge

Pipeline for RM in KG-gen

cd verbatlas/src&&gunicorn --workers 4 --bind 0.0.0.0:5000 wsgi:app
cd verbnet-approach/src&&python main.py --trainer_type KG_diff_file --topk 2 --story_length 3 --KG_use --remain_div
cd verbnet-approach/src&&python main.py --trainer_type KG_diff_step_file --topk 5 --story_length 10 --KG_use --remain_div --look_ahead 1 --seed 3

โฃ๏ธ KG / State Transition

Given a state, RM will output action space and then human choose an action, and RM will generate a new state. This is the code you need to run in the command line. However, there might need some modification for the absolute path. I have tried my best to convert all the absolute path to relative ones. Pls LMK if there still exist any absolute path. Thanks.

๐Ÿ’ฆ Functions

For generating action space and new state, the main file is here.

  • define_roles(): Find role/ character names in the sentence.
  • prepare_next_step(): Use the parser, construct or add nodes in KG
  • generate_actions(): Given the KG and then generate all the possible action space.
  • forward(): Different round will trigger different functions. It will be called in main.py and move one sentence forward.

๐Ÿคฉ Features (defined here)

  • trainer_type: QA or generation or KG or KG_diff or KG_diff_file, We are using KG_diff_file as default.
  • model_name_or_path: GPT-2's pretrained model path
  • mapping_file and verbnet_json: path of verbnet files.
  • target_path: path to save kg visualization
  • model_file: COMeT path
  • BART is used to fill in the verbs. The model is facebook/bart-large
  • GPT-2 finetuned on ROC is used to generate the sentence after we have verb and noun.
  • --KG_use: whether to use KG to update the game state
  • --topk: int, # of sentence for each round we remain.
  • --action_standard: Use verb or sentence as actions. Now we are using sentence as default.
  • --remain_div: half of the candidates have different prompts
  • --story_length: length of the generated story
  • --look_ahead: only apply to trainer_type=KG_diff_step_file or trainer_type=KG_diff_step, m_1 in the paper.

readermodel's People

Contributors

anonymous-guys avatar

Watchers

 avatar

Forkers

xiangyu-peng

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.