Skip to main content

package for the paper Syntax Aware Natural Language Inference@<link>

Project description

SynNLI

Description

  • this repo uses allennlp as base repo

AllenNlp

  • a quick guide of mine can be found at the same folder
  • for insight, please visit allennlp document and github

Custom Classes and Operations

  • GraphPair2VecEncoder
    • 'gen', 'gmn'
  • Graph2GraphEncoder
    • known as graph convolution layer in pytorch_geometric
  • GraphPair2GraphPairEncoder
    • for graph matching in sparse batch
    • tf.dynamic_partition + normal attention
  • NodeUpdater
    • A wrapper over RNNs
  • Graph2VecEncoder
    • known as global pooling layer in pytorch_geometric
    • 'global_attention'
  • SynNLIModel(base=Model)
    • use Embedder to embed input
    • use GraphPair2VecEncoder to get compare vector for classifier to make final decision
  • tensor_op.py
    • batch conversion between normal model and graph model
      • sparse2dense
      • dense2sparse
  • SparseAdjacencyField
    • cooperate with pytorch_geometric to get sparce graph batch
    • see batch_tensors() and as_tensor() for the key of implementation
  • NLIGraphReader
    • read graph input (parsed by Stanza)
  • preprocess.py
    • see the Preprocess section for detail
  • configs
    • can be found in src/training
    • for allennlp train

Usage (Cur)

  • ./install_dependencies.sh
  • download NLI style data set to data
    • and specify path in jsonne
  • parse data (see Parse Data section)
    • and specify path in jsonnet
  • train model (see Training Area)
    • with jsonnet

Parse Data with Stanza

  • Stanza will be loaded in preprocess.py
    • the parser version is the one @ 2020/8/22
  • use preprocess.py
python preprocess.py -i <raw_data_path> \
 -o <target_path> \
 --files <file_names> \
 --force(if activated, force execution when <target_path exists>) \
 -m 10(if provided, maximum instances to process is set, this is mainly for testing)
# example
python preprocess.py -i ../data/anli_v1.0/R2/ \
 -o ../data/anli_v1.0_preprocessed/R2/ \
 --files dev.jsonl test.jsonl train.jsonl \
 --force \
 -m 10
  • if want to use allennlp (less recommended)
    • download allennlp dependency parser and SRL labeler from path

Training

  • refer to "the config.jsonnet"
allennlp train "./src_gmn/training_config.jsonnet" -s "./param/testv1"   --include-package "package_v1" --force

Future Supported Usage

  • pip install -r requirements
    • add configs folder for various config
  • note that should take lemmatized as node attr if use word level embedding(or + char embedding to ease)
  • root to spetial token
  • use MLP prjection

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

syn_nli-0.0.1.tar.gz (41.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

syn_nli-0.0.1-py3-none-any.whl (66.4 kB view details)

Uploaded Python 3

File details

Details for the file syn_nli-0.0.1.tar.gz.

File metadata

  • Download URL: syn_nli-0.0.1.tar.gz
  • Upload date:
  • Size: 41.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for syn_nli-0.0.1.tar.gz
Algorithm Hash digest
SHA256 edc115ec5b4ae8715c6f9304fa055926e45010eb04defd95fe3dca6183992eb3
MD5 b637abfffe072b7efa10f439ed9e7f8d
BLAKE2b-256 df702b2b520e0f16119219e32782ed31e21c99d9c6fbf174f881a51fcf55d7bc

See more details on using hashes here.

File details

Details for the file syn_nli-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: syn_nli-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 66.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for syn_nli-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 67c8d47ea21dfa60639f107c0bf9c9afcf39572b7bc598731cb7f85d58c1768f
MD5 2e0b31a9f3f845842910374f840d343c
BLAKE2b-256 e617a0c22952b2597344649cba20f1d200d312b6b723c0ecb72efc5c674bed37

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page