Code Monkey home page Code Monkey logo

scrambletests's Introduction

Evaluating compositionality in sentence embeddings

Codebase for Dasgupta et al. 2018, https://arxiv.org/abs/1802.04302

An updated version of this work is Dasgupta, Ishita, et al. "Analyzing machine-learned representations: A natural language case study." arXiv preprint arXiv:1909.05885 (2019). Linked here: https://arxiv.org/abs/1909.05885

Code to generate Compositional dataset based on comparisons, SNLI data analysis and scripts for augmented training is in the training-experiments branch.

Dataset used in the paper is here: https://github.com/ishita-dg/ScrambleTests/tree/training-experiment/testData/new

Code in main branch generates a smaller but more general dataset, sets up classifiers, downloads and tokenizes data.

Instructions

Getting data

In the Downloads folder, run: ./get_data.bash Requires 7za to unzip downloaded files, download and install from https://sourceforge.net/projects/p7zip/files/p7zip/ Path to sed tokenizer might need to be adjusted.

Run-through with toy

Run: python main.py, with toy = True. This should run through training the classifier and test code on toy data sets (provided).

Setting it False will run the true classifier and take a long time, and very high memory (~150+ GB) for InferSent embeddings.

GPU for classifier training

Set useCudaReg = True in main.py

Analysing tests

The logistic regression models (in ./models/) as well as their outputs on the true scramble-test results (in ./regout/) are provided. So you can run the analysis script directly.

In AnalyseTests.ipynb, setting Scram = True runs tests for Scramble test data, Scram = False runs it for te SNLI test and/or dev sets. Produces the plots (inline as well as in ./figures/), and displays high-margin BOW misclassifications (inline).

scrambletests's People

Contributors

demiguo avatar ishita-dg avatar stuhlmueller avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

scrambletests's Issues

Results in table 2 of the paper

Hi,

Are the scores from table 2 of the paper (Table 2: Performance on the Comparisons dataset.) from evaluating the model only on short splits (i.e. comp_ml_short, comp_not_short, comp_same_short)?

Or is it an average of both short and long splits? In the code is seems that it is only on the short.

Thanks

Exact datasets of published paper

Hi,
this is not really an issue but more of a clarification question on the data (so please feel free to move it somewhere more appropriate). Can you please tell me which of the datasets contained in the folder testData/true was used for the negation set reported in your paper? I am guessing that subjv_long and subjv_short were included but were also comp_not_long and comp_not_short included or were the latter two part of the "same" set?

Thanks in advance for your help
Katerina

Cannot run main.py script when training is ommited

Hi again,

I am trying to run the main.py script in order to test the trained classifier models (BOWLogReg and InferSentLogReg) on another test set of my own. Unfortunately, I dont have the possibility to retrain the classifiers on the SNLI data due to hardware restrictions and that is why I would like to use the trained models but on a different test set. For this purpose I commented out the "loading training data" and "Training classifiers" parts of the main.py, in order to use the trained models. I have kept the lists of "names" and "classifiers" and I have adjusted the path TEST_DATA_PATH to point to the directory where my test set is located. When I run the script, it successfully starts and prints

[nltk_data] Downloading package punkt to /home/kkalouli/nltk_data...
[nltk_data] Package punkt is already up-to-date!
Vocab size : 100000
Running tests for tasks: ['test']


Running tests for InferSentLogReg...


but soon after, it throws the error

/home/kkalouli/Documents/libraries/ScrambleTests/classifier.py:154: UserWarning: volatile was removed and now has no effect. Use with torch.no_grad(): instead.
Xbatch = Variable(devX[i:i + self.batch_size], volatile=True)
Traceback (most recent call last):
File "main.py", line 165, in
runAllTests(names, classifiers, model, tasks, outpaths, label2id)
File "main.py", line 125, in runAllTests
tF.runtests(name, classifier, model, tasks, outpaths, label2id)
File "/home/kkalouli/Documents/libraries/ScrambleTests/testFuncs.py", line 44, in runtests
labels, confs = predict(embedA, embedB, regressor)
File "/home/kkalouli/Documents/libraries/ScrambleTests/testFuncs.py", line 16, in predict
probs = reg.predict_proba(feats)
File "/home/kkalouli/Documents/libraries/ScrambleTests/classifier.py", line 156, in predict_proba
probas = self.model(Xbatch).data.cpu().numpy()
File "/home/kkalouli/Documents/virtEnv1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 489, in call
result = self.forward(*input, **kwargs)
File "/home/kkalouli/Documents/virtEnv1/lib/python3.6/site-packages/torch/nn/modules/container.py", line 92, in forward
input = module(input)
File "/home/kkalouli/Documents/virtEnv1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 484, in call
for hook in self._forward_pre_hooks.values():
File "/home/kkalouli/Documents/virtEnv1/lib/python3.6/site-packages/torch/nn/modules/module.py", line 535, in getattr
type(self).name, name))
AttributeError: 'Softmax' object has no attribute '_forward_pre_hooks'

Do you have any ideas what the reason for this error could be and how to fix it? A quick google search was not very helpful on that aspect. Any other solving ideas are also welcome.

Thanks a lot in advance!

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.