This package evaluates the robustness of NLP (classification) models from the perspective of behavioral tests and adversarial examples, utilizing CheckList and TextAttack
Most dependencies are listed in the requirement file.
- language-tool-python requires Java 8
- tokenizer: a tokenizer that tokenizes the sentences and turns tokens into word indices
- model: a model that takes tokenized sentences and produces class probabilities
- data: an iterable of sentence label pairs
- config file (YAML) : a config file in YAML format that describes the tests to run the attack method to use
A report summarizing test results and adversarial examples.
Refer to the test case test_report
in tests/test_report.py for an example of how to use this package.
To start, define a NLPReport by
from nlptest.nlptest.nlp_report import NLPReport
and provide inputs as arguments
report = NLPReport(dataset=dataset, model=model, tokenizer=tokenizer,
config_file=current_path / "config_test.yaml")
Results can be inspected in the test_result
attribute
report.test_result
Currently implemented output formats include:
- HTML:
report.html
- JSON:
report.json
- dictionary:
report.dict
Refer to tests/config_test.yaml
and nlpteste/nlptest/
for examples of test configuration.
- git clone
- cd into nlp_test
docker build -f ./docker/Dockerfile --tag nlp_test:0.0.1 --network=host .