Downloads · 30 days
173
0% of all-time downloads
uw-hai/polyjuice
polyjuice is a text generation model from uw-hai. Use it when you need the model to write or continue text. It is set up for transformers.
This is a ported version of Polyjuice, the general-purpose counterfactual generator. For more code release, please refer to this github page.
Downloads · 30 days
173
0% of all-time downloads
All-time downloads
187K
Public
Repo size
2 GB
Likes
4
Public
Click a slice to open those files.
.bin510 MB · 51%
From the Hugging Face model README
This is a ported version of Polyjuice, the general-purpose counterfactual generator. For more code release, please refer to this github page.
from transformers import AutoTokenizer, AutoModelWithLMHead
from transformers import pipeline, AutoTokenizer, AutoModelForCausalLM
model_path = "uw-hai/polyjuice"
generator = pipeline("text-generation",
model=AutoModelForCausalLM.from_pretrained(model_path),
tokenizer=AutoTokenizer.from_pretrained(model_path),
framework="pt", device=0 if is_cuda else -1)
prompt_text = "A dog is embraced by the woman. <|perturb|> [negation] A dog is [BLANK] the woman."
generator(prompt_text, num_beams=3, num_return_sequences=3)
@inproceedings{polyjuice:acl21,
title = "{P}olyjuice: Generating Counterfactuals for Explaining, Evaluating, and Improving Models",
author = "Tongshuang Wu and Marco Tulio Ribeiro and Jeffrey Heer and Daniel S. Weld",
booktitle = "Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics",
year = "2021",
publisher = "Association for Computational Linguistics"