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.2.dev1.tar.gz (42.1 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.2.dev1-py3-none-any.whl (66.6 kB view details)

Uploaded Python 3

File details

Details for the file syn_nli-0.0.2.dev1.tar.gz.

File metadata

  • Download URL: syn_nli-0.0.2.dev1.tar.gz
  • Upload date:
  • Size: 42.1 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.2.dev1.tar.gz
Algorithm Hash digest
SHA256 f7a7828ad36094ff43d06d4f7ef48d472885d2df421ba1e1cb6dbd54db2a6fb6
MD5 3dfde0529baf3646427619c6f3d9167d
BLAKE2b-256 4e8d43c56855a01b59b1ad15f2c6cc61bddd99f801266a6cab283ab66910e007

See more details on using hashes here.

File details

Details for the file syn_nli-0.0.2.dev1-py3-none-any.whl.

File metadata

  • Download URL: syn_nli-0.0.2.dev1-py3-none-any.whl
  • Upload date:
  • Size: 66.6 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.2.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 a32ab12dcb4aa442eb999fe85e18323447c0ef69878d0af5a31801f2b8a6b7ae
MD5 ce5611f6de422274d77112d0a4af5b09
BLAKE2b-256 846507788b60c5da51b15c61680b61b4cf538bae4779e88b3a26e59ab9698a65

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