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.4.tar.gz (42.2 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.4-py3-none-any.whl (66.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: syn_nli-0.0.4.tar.gz
  • Upload date:
  • Size: 42.2 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.4.tar.gz
Algorithm Hash digest
SHA256 2706b84eb84b31ebce5d4058a2a62becb522a04932942a38c29ea8abce10fb83
MD5 0473ef9a79fd1d2ab9a71e131ca089e9
BLAKE2b-256 29cba39f99ade1f15786321fd8584c46687e24292ed1eff089a0a66bb41bf408

See more details on using hashes here.

File details

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

File metadata

  • Download URL: syn_nli-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 66.5 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e4fd1f9aa54c82f5e14a257634b100d9eee7608f3f785879da14be22b5504c69
MD5 a51f17b11bddf0548807a591adf42ef6
BLAKE2b-256 cfc6ceda3e4cd6f6dbf5686f7427c41ad8281a19974d2b81df1bb2ccd3f4793b

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