A python package for attacking Russian NLP models
Project description
Robustness Evaluation of Pre-trained Language Models in the Russian Language
This is a repo with experiments for Robustness Evaluation of Pre-trained Language Models in the Russian Language and a tool ru_attacker
for attacking Russian NLP models
Installation
pip install ru_attacker
Usage example
Set model
>>> from ru_attacker.models import RobertaModel
>>> roberta_checkpoints = "Roberta_checkpoints"
>>> ruRoberta = RobertaModel(roberta_checkpoints)
Set dataset
>>> from ru_attacker.models.set_dataset import get_data
>>> data_dir = "TERRa/val.jsonl"
>>> data = get_data(data_dir)
Set attack
>>> from ru_attacker.attacks import WordOrder
>>> word_order_attack = WordOrder()
Attack model and view results
>>> results = word_order_attack.attack(ruRoberta, data)
[Succeeded / Failed / Skipped / Total] 0 / 1 / 0 / 1:
entailment --> not_entailment
original premise: """Решение носит символический характер, так как взыскать компенсацию практически невозможно"", - отмечается в сообщении."
original hypothesis: Взыскать компенсацию не получится.
transformed: не компенсацию Взыскать получится .
Convert results to DataFrame
>>> import pandas as pd
>>> dataframe = pd.DataFrame(results)
Here is Tutorial
Experiments
All the data used in experiments and the results are in
data
folder (TERRa
and
results
correspondingly).
All experiments can be reproduced in Experiments.ipynb
.
Models checkpoints are available via:
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
ru_attacker-0.0.3.tar.gz
(11.2 kB
view hashes)
Built Distribution
Close
Hashes for ru_attacker-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79071b34b80af64b535a30a61b610a3605b902da5efca11b0901840be4d4a6a7 |
|
MD5 | 60793a6f22c74e27cf5d260dc57fd0d1 |
|
BLAKE2b-256 | 0ec3bd2b2b49d35363de7f69a735603536c3a39f74533369d5deebe43ee2aeb6 |