tongshuangwu
commited on
Commit
·
6f13dd0
1
Parent(s):
79a9c91
update readme
Browse files
README.md
CHANGED
@@ -3,7 +3,7 @@ language: "en"
|
|
3 |
tags:
|
4 |
- counterfactual generation
|
5 |
widget:
|
6 |
-
- text: "
|
7 |
---
|
8 |
|
9 |
# Polyjuice
|
@@ -17,11 +17,12 @@ This is a ported version of [Polyjuice](https://homes.cs.washington.edu/~wtshuan
|
|
17 |
```python
|
18 |
from transformers import AutoTokenizer, AutoModelWithLMHead
|
19 |
|
20 |
-
tokenizer = AutoTokenizer.from_pretrained("uw-hai/
|
21 |
-
model = AutoModelWithLMHead.from_pretrained("uw-hai/
|
22 |
|
23 |
|
24 |
-
prompt_text = "
|
|
|
25 |
perturb_tok, end_tok = "<|perturb|>", "<|endoftext|>"
|
26 |
encoded_prompt = tokenizer.encode(prompt_text, add_special_tokens=False, return_tensors="pt")
|
27 |
input_ids = encoded_prompt
|
|
|
3 |
tags:
|
4 |
- counterfactual generation
|
5 |
widget:
|
6 |
+
- text: "A dog is embraced by the woman. <perturb> [negation] A dog is [BLANK] the woman."
|
7 |
---
|
8 |
|
9 |
# Polyjuice
|
|
|
17 |
```python
|
18 |
from transformers import AutoTokenizer, AutoModelWithLMHead
|
19 |
|
20 |
+
tokenizer = AutoTokenizer.from_pretrained("uw-hai/polyjuice")
|
21 |
+
model = AutoModelWithLMHead.from_pretrained("uw-hai/polyjuice")
|
22 |
|
23 |
|
24 |
+
prompt_text = "A dog is embraced by the woman. <perturb> [negation] A dog is [BLANK] the woman."
|
25 |
+
# or try: "A dog is embraced by the woman. <perturb> [restructure] A dog is [BLANK] the woman."
|
26 |
perturb_tok, end_tok = "<|perturb|>", "<|endoftext|>"
|
27 |
encoded_prompt = tokenizer.encode(prompt_text, add_special_tokens=False, return_tensors="pt")
|
28 |
input_ids = encoded_prompt
|