Giter Club home page Giter Club logo

qanet-pytorch's Introduction

Introduction

A Pytorch implementation of QANet
This repository is based on NLPLearn/QANet and marquezo/qanet-impl

It can get em: 70.155 and f1: 79.432 peformance after 22 epochs(2730 batches per epoch) with EMA.

Requirements

Usage

Preprocess

$ mkdir data
$ python preprocess.py

Train

$ mkdir log
$ mkdir log/qanet
$ python train.py 'some description'

Evaluate

First set the log folder and epoch number in evaluate.py then execute the script.

$ python evaluate.py

Known issues

  • pickle.dump will get an "OSError: [Errno 22] Invalid argument" error on OS X when saving the "train context char" data, it's ok on Ubuntu 16.04.

qanet-pytorch's People

Contributors

hackiey avatar

Stargazers

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

Watchers

 avatar  avatar

qanet-pytorch's Issues

Add license

Hi, thanks for the implementation. Would you mind adding a license? Would love to try the model but right now it is not possible.

Performance and memory problem

I tested the performance of this implementation. What I get is:
With ema (26 epochs): EM: 77.16 F1: 66.43

My repository is in https://github.com/BangLiu/QANet-PyTorch,
and https://github.com/BangLiu/QANet-PyTorch/blob/master/model/QANet_hackiey.py this model file is directly merged from your repository. I don't know why I cannot reach F1 79 and EM 70 even with EMA, so I am still trying to find potential bugs in my code. It will be great if you can take a look at my repository and check the potential problem that caused the performance difference.

I also tried to set num_head = 8 for both model_encoder_n_heads and embed_encoder_n_heads. But I get out of memory problem.

That is all what I have found currently.

out of memory

when I run you code on 1080Ti 12G, about 20 steps,I meet out of memory
RuntimeError: cuda runtime error (2) : out of memory at /pytorch/aten/src/THC/generic/THCStorage.cu:58
do you meet this problem?

A possible bug in self_attention.py

Hi @hackiey,

Thanks for the code, I've successfully reproduced an em 67.515 results (w/o EMA)! But when I read the codes carefully, I noticed something might be wrong in self_attention.py,

heads = torch.zeros(self.n_heads, batch_size, l, self.value_dim, device=device)  # L30, creation
x = heads.view(batch_size, l, -1)  # L47,  resize

https://github.com/hackiey/QAnet-pytorch/blob/master/qanet/self_attention.py#L47

which I think should be

x = heads.permute(1, 2, 0, 3).contiguous().view(batch_size, l, -1)

Does this make sense to you? I've also tested the code with the proposed change, but the result seems not changing. Any idea how it happens?

how to use multiple GPUs

the constants.py file specifies cuda:0 as device when cuda is available, is there a way to use multiple GPUs by modifying the constants.py or other parts of the code?

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.