Coder Social home page Coder Social logo

teamproject's Introduction

ATOMIC data generation

The original COMET code creates dynamic strings based on configs, for all output filenames. We override this with simplified filenames.

First, to create a dataset, set the output path like DATASET_PICKLE="data/atomic/processed/generation/pathcomet_1.pickle".

We will pass this filename as arg to all the scripts, which will override the default filename handler.

Random paths without any restrictions

To create a dataset which consists of random walks sampled from a knowledge graph, run the following command. The knowledge graph is generated by merging the triples provided in the ATOMIC dataset, with additional Inverse relations, into a single graph.

An example path would be: Subject, Relation, Object, InverseRelation, Subject, Relation -> Object

You can set --n_train, --n_dev, --n_test, to set the number of examples in each split, and set --n_per_node and --max_path_len to control the parameters of the path sampling.

python scripts/data/make_atomic_data_loader.py --pickled_data "$DATASET_PICKLE" --n_train 100000 --n_dev 5000 --n_test 5000 --n_per_node 3 --max_path_len 10

Original COMET format data

The original COMET data has the form s, r -> o. We provide the option to generate this format with the --comet flag. The other args are ignored and the entire ATOMIC dataset will be generated.

python scripts/data/make_atomic_data_loader.py --pickled_data "$DATASET_PICKLE" --comet

Path COMET format data

We provide the option to sample a single path and prepend it to the s,r of the original COMET data, yielding the form, path, s, r -> o. Use the --pathcomet flag. The other args are ignored and the entire ATOMIC dataset will be generated.

python scripts/data/make_atomic_data_loader.py --pickled_data "$DATASET_PICKLE" --pathcomet

ATOMIC Training

Like COMET, the training script finetunes a pre-trained GPT2 model. Set a unique experiment ID with EXPERIMENT_NAME="myexp0 " and run the following commands.

Train a language model on knowledge graph random walks

python src/main.py --experiment_type atomic --experiment_num 0 --pickled_data "$DATASET_PICKLE" --save_path "$EXPERIMENT_NAME"

Incorporate COMET objective into training or evaluation

If you created a dataset with the --comet or --pathcomet flag, you can apply the COMET objective in the training, evaluation, or both.

python src/main.py --experiment_type atomic --experiment_num 0 --pickled_data "$DATASET_PICKLE" --save_path "$EXPERIMENT_NAME" --train_comet_loss
python src/main.py --experiment_type atomic --experiment_num 0 --pickled_data "$DATASET_PICKLE" --save_path "$EXPERIMENT_NAME" --eval_comet_loss
python src/main.py --experiment_type atomic --experiment_num 0 --pickled_data "$DATASET_PICKLE" --save_path "$EXPERIMENT_NAME" --train_comet_loss --eval_comet_loss

The train_comet_loss flag applies the COMET objective to training, instead of the default language modeling objective, by masking out the loss on all tokens other than the tokens of final object in the training example. The eval_comet_loss flag applies the same idea to evaluation.

So the first line in the above commands will train the model on the COMET objective and select the best model on LM perplexity. The second line will train the model on the LM objective and select the best model based on COMET objective. The third line is equivalent (the implementation details differ) to the original COMET model.

teamproject's People

Contributors

mnskim avatar

Watchers

 avatar

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.