Code Monkey home page Code Monkey logo

nlp_qa_project's Introduction

Temporal Graph for Babi QA Tasks

Goal to solve several Facebook AI Research(FAIR)'s babi QA tasks using a novel approach based on temporal graph traversal.

The tasks are described in detail in the paper : Towards AI Complete Question Answering: A Set of Prerequisite Toy Tasks Artificial Tasks for AI Each task checks one skill that a reasoning system should have. Performing well on all of them is a pre-requisite for any system aiming at understanding language and able to reason.

Project Scope

To solve 3 of 20 QA tasks (https://github.com/facebook/bAbI-tasks)

# Task Class name
1 Basic factoid QA with single supporting fact WhereIsActor
2 Factoid QA with two supporting facts WhereIsObject
6 Yes/No questions IsActorThere

Basic factoid QA with single supporting fact Factoid QA with two supporting facts Yes/No questions

Temporal Graph

Project Overview

  1. Construction of temporal graph to represent the activities of actors in the story
  • Parse the input dataset-(facts of a task) to extract (timestamp, verb, pos, lemma) using Stanford CoreNLP Parser
  • Build the graph where Nodes represent subject & objects, Edges represent verb actions associating subject to object using python networkx module
  • Visualize graph using matplotlib.pyplot
  1. Answering questions by traversing graph.
  • Parse the questions to identify subject/object and locate the corresponding node in graph
  • Use Word Embedding and K-Means clustering on input dataset, to provide semantic heuristic to graph traversal algorithm in order to distingish verb actions which associate subject-object using gensim Clustered verb actions annotated into classes: attach, detach, transport
  • Traverse the graph to find the answers
  1. Interactive mode to provide text2speech feedback while parsing stories using espeak accompained with intuitive graphs which present the state of graph model

Project Pipeline : How To Guide

Project Structure

  1. src\ : source code
  2. tasks_1-20_v1-2\ : set of 20 tasks for testing text understanding and reasoning in the bAbI project
  1. input\
  • *_train.txt - tasks_1-20_v1-2/en-10k/ 10,000 training examples
  1. parsedInput\
  • *jl - Part of Speech and Facts/Question-Answer(Supporting Facts) identified
  1. models\ : word2vec binary model files using gensim
  2. clusters\ : clusters computed using k-means algorithm with best silhouette_score.
  3. annotatedClusters\ : annotated clusters with appropriate labels identifying (attach/detach/transport/person/location/misc)
  4. output\ :
  • *jl - predicted and actual answer with supportingFacts.

Setup

  1. Setup Stanford CoreNLP server
  2. Download and extract Core NLP Server http://stanfordnlp.github.io/CoreNLP/#download
  3. Start the server on Port 9000
    java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000 http://localhost:9000/
  4. Test Sample
  5. Python wrapper for Stanford CoreNLP : https://github.com/smilli/py-corenlp
  6. Espeak https://ports.macports.org/port/espeak-ng/, Python Espeak https://github.com/relsi/python-espeak
  7. GenSim : http://radimrehurek.com/gensim/install.html
  8. K-Means Clustering : http://scikit-learn.org/stable/install.html

Modules

Module Description
babiparser.py Parse the dataset to annotate POS using StanfordCoreNLP, identifying Facts/Question-Answer(Supporting Facts)
get_clusters.py Leverage parsed input to obtain word2vec embedding for facts, cluster the vectors using k-means clustering with k (having best silhouette_score)
annotate_clusters.py Annotate clusters with appropriate labels identifying (attach/detach/transport/person/location/misc)
babigraph.py Represents facts of story in temporal graph with Actors, Objects/Location as Nodes and relationship between them as edges labelled with timestamps using networkx. Parse the questions to identify the corresponding actor/object node in the graph. Leverage annotated cluster labels to filter candidate edges associated with the node and use the latest edge to answer the questions.
evaluate.py Computes No of Correct and Incorrect Predictions

nlp_qa_project's People

Contributors

adityardesai avatar raviraju avatar thammegowda avatar

Stargazers

 avatar  avatar  avatar

Watchers

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