A python package for attacking Russian NLP models
Project description
ru_attacker
This is a tool 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.ru_attacker.attacks import WordOrder
>>> word_order_attack = WordOrder()
Attack model and view results
>>> results = word_order_attack.attack(ruT5, data)
[Succeeded / Failed / Skipped / Total] 0 / 1 / 0 / 1:
entailment --> not_entailment
original premise: """Решение носит символический характер, так как взыскать компенсацию практически невозможно"", - отмечается в сообщении."
original hypothesis: Взыскать компенсацию не получится.
transformed: не компенсацию Взыскать получится .
Convert results to DataFrame
>>> dataframe = pd.DataFrame(results)
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.2.tar.gz
(10.3 kB
view hashes)
Built Distribution
Close
Hashes for ru_attacker-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 945b08e653207889ddb0adc3c3c3e61938cfb781f22d1e865e94a41fc91fb256 |
|
MD5 | ed7d54b666d7a790a0b9083fa6712bea |
|
BLAKE2b-256 | 6f83b3c5c338bc94025a9eb9cf3d1921acde92dc2238bd19d5342a3c521e9ace |