Git Product home page Git Product logo

moral-choice-machine-v2's Introduction

Moral Choice Machine

Code repository for the Moral Choice Machine: ...

1. Structure

The code is structured in:

  • /data: pre-processing of the datasets
  • /mcm: the Moral Choice Machine bias calculation
  • /sentenceEmbedding: retraining of sentence Embeddings with the Universal Sentence Encoder

The retraining of the USE is based on the code: https://github.com/tensorflow/models/tree/master/research/skip_thoughts

2. Dependencies

tensorflow>=1.12.0
tensorflow_hub>=0.3.0
gensim>=3.8.1
nltk>=3.4.5
numpy>=1.17.2
scipy>=1.3.1
tqdm>=4.36.1
pandas>=0.25.1

3. Using the MCM interactive

To run the MCM based on the pre-trained USE embeddings (tensorflow hub):

python experiments/experiments_mcm.py --data <atomic/context> --model use_hub

4. Reproducing the results

To run the MCM based on the pre-trained USE embeddings (tensorflow hub):

python experiments/mcm_answering.py --model use_hub

5. Retraining the underlying embedding

1. Prepare the dataset
    python data/preprocessBooks.py --data_dir <source directory> --out_dir <destination directory>
2. Preprocess the data for the retraining
    python sentenceEmbedding/skip_thoughts/data/preprocess_dataset_use.py --input_dir <directory/to/dataset/folder/> --output_dir <directory/to/output/> --train_output_shards <number of shards> --num_validation_sentences <# of validation sentences> 
3. Run the retraining
    CUDA_VISIBLE_DEVICES=# python sentenceEmbedding/skip_thought/train_use.py --input_file_pattern <'/path/to/preprocessed/data/train-?????-of-12345'> --input_file_pattern_snli <'/path/to/preprocessed/snli/data/train-?????-of-12345'> --train_dir <output directory> --learning_weight_decoder <weight>

Using the retrained model:
python experiments/experiments_mcm.py --data <atomic/context> --model train_rc

6. Citing & Authors

If you find this repository helpful, feel free to cite our publication: TODO

moral-choice-machine-v2's People

Contributors

patrickschrml avatar cigdemturan 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.