Skip to content

Commit

Permalink
update tf>=2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutosh16399 committed Mar 25, 2021
1 parent bed6460 commit 0eee5bd
Show file tree
Hide file tree
Showing 30 changed files with 537 additions and 20,514 deletions.
4 changes: 1 addition & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
data/annotations.tsv filter=lfs diff=lfs merge=lfs -text
data/monument_300.zip filter=lfs diff=lfs merge=lfs -text
data/monument_600.zip filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
115 changes: 0 additions & 115 deletions .gitignore

This file was deleted.

3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

41 changes: 14 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@

[![Python 3.7](https://img.shields.io/badge/python-3.7-blue.svg)](https://www.python.org/downloads/release/python-370/)

A LSTM-based Machine Translation Approach for Question Answering over Knowledge Graphs.
A Attention-based Machine Translation Approach for Question Answering over Knowledge Graphs.(https://www.tensorflow.org/tutorials/text/nmt_with_attention)

![What does a NSpM do?](http://www.liberai.org/img/NSpM-image.png "What does a NSpM do?")

## Code

Install `git-lfs` in your machine, then fetch all files and submodules.

```bash
git lfs fetch
git lfs checkout
git submodule update --init
```
clone the repo

### Python setup

Expand All @@ -26,50 +20,43 @@ pip install -r requirements.txt

#### Pre-generated data

You can extract pre-generated data from `data/monument_300.zip` and `data/monument_600.zip` in folders having the respective names.
You can extract pre-generated data and model checkpoints from `data/art_30.zip` in folders having the respective names.

#### Manual Generation (Alternative to using pre-generated data)

The template used in the paper can be found in a file such as `annotations_monument.tsv`. `data/monument_300` will be the ID of the working dataset used throughout the tutorial. To generate the training data, launch the following command.
The template used in the paper can be found in a file such as `Annotations_F30_art.csv`. `data/art_30` will be the ID of the working dataset used throughout the tutorial. To generate the training data, launch the following command.

<!-- Made monument_300 directory in data directory due to absence of monument_300 folder in data directory -->
```bash
mkdir data/monument_300
python generator.py --templates data/annotations_monument.csv --output data/monument_300
mkdir data/art_30
python generator.py --templates data/Annotations_F30_art.csv --output data/art_30
```

Launch the command to build the vocabularies for the two languages (i.e., English and SPARQL) and split into train, dev, and test sets.
Launch the command if you want to build dataset seprately else it will internally be called while training.

```bash
./generate.sh data/monument_300
python data_gen.py --input data/art_30 --output data/art_30
```

### The Learner module

<!-- Just a simple note to go back to the initial directory.-->
Now go back to the initial directory and launch `train.sh` to train the model. The first parameter is the prefix of the data directory and the second parameter is the number of training epochs.
Now go back to the initial directory and launch `train.py` to train the model. Currently the epochs and batch_size is not parametrized for that you can change the epoch is train.py and batch size in data_gen.py (recommended batch size for large 64, medium 32 and small like art_30 is 16) also epochs varies with batch size for art 30 its 40.

```bash
./train.sh data/monument_300 12000
python train.py --input data/art_30 --output data/art_30
```

This command will create a model directory called `data/monument_300_model`.
This command will create a model checkpoints in `data/art_30`.

### The Interpreter module

Predict the SPARQL query for a given question with a given model.
Predict the SPARQL query for a given question it will store the detailed output in output_query.

```bash
./ask.sh data/monument_300 "where is edward vii monument located in?"
python translate.py --input data/art_30 --output data/art_30 --inputstr "yuncken freeman has architected in how many cities?"
```

### Unit tests

Tests can be run, but exclusively within the root directory.

```bash
py.test *.py
```

## Use cases & integrations

Expand Down Expand Up @@ -138,4 +125,4 @@ py.test *.py
* Follow the [project on ResearchGate](https://www.researchgate.net/project/Neural-SPARQL-Machines).
* Follow Liber AI Research on [Twitter](https://twitter.com/theLiberAI).

<p align="center"><img tooltip="Liber AI" src="http://www.liberai.org/img/Liber-AI-logo-name-200px.png" alt="Liber AI logo" border="0"></p>
<p align="center"><img tooltip="Liber AI" src="http://www.liberai.org/img/Liber-AI-logo-name-200px.png" alt="Liber AI logo" border="0"></p>
Binary file added __pycache__/generator_utils.cpython-37.pyc
Binary file not shown.
Loading

0 comments on commit 0eee5bd

Please sign in to comment.