tongshuangwu commited on
Commit
d1d2d2e
1 Parent(s): 80dcf88
README.md ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: "en"
3
+ tags:
4
+ - counterfactual generation
5
+ widget:
6
+ - text: "It is great for kids. <perturb> [negation] It [BLANK] great for kids. [SEP]"
7
+ ---
8
+
9
+ # Erised
10
+
11
+ ## Model description
12
+
13
+ This is a ported version of [Erised](https://homes.cs.washington.edu/~wtshuang/static/papers/2021-arxiv-polyjuice.pdf), the general-purpose counterfactual generator.
14
+
15
+ #### How to use
16
+
17
+ ```python
18
+ from transformers import AutoTokenizer, AutoModelWithLMHead
19
+
20
+ tokenizer = AutoTokenizer.from_pretrained("uw-hai/jolyjuice")
21
+ model = AutoModelWithLMHead.from_pretrained("uw-hai/jolyjuice")
22
+
23
+
24
+ prompt_text = "It is great for kids. <perturb> [negation] It [BLANK] great for kids. [SEP]"
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
28
+ stop_token= '\n'
29
+ repetition_penalty=1
30
+ output_sequences = model.generate(
31
+ input_ids=input_ids,
32
+ max_length=100 + len(encoded_prompt[0]),
33
+ temperature=0.1,
34
+ num_beams=10,
35
+ num_return_sequences=3)
36
+
37
+ if len(output_sequences.shape) > 2:
38
+ output_sequences.squeeze_()
39
+
40
+ for generated_sequence_idx, generated_sequence in enumerate(output_sequences):
41
+ generated_sequence = generated_sequence.tolist()
42
+ # Decode text
43
+ text = tokenizer.decode(generated_sequence, clean_up_tokenization_spaces=True)
44
+ # Remove all text after the stop token
45
+ text = text[: text.find(stop_token) if stop_token and text.find(stop_token)>-1 else None]
46
+ text = text[: text.find(end_tok) if end_tok and text.find(end_tok)>-1 else None]
47
+ print(text)
48
+ ```
49
+
50
+ ### BibTeX entry and citation info
51
+
52
+ ```bibtex
53
+ @article{wu2021polyjuice,
54
+ title={Polyjuice: Automated, General-purpose Counterfactual Generation},
55
+ author = {Wu, Tongshuang and Ribeiro, Marco Tulio and Heer, Jeffrey and Weld Daniel S.},
56
+ journal={arXiv preprint},
57
+ year={2021}
58
+ }
59
+ ```
config.json ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "activation_function": "gelu_new",
3
+ "architectures": [
4
+ "GPT2LMHeadModel"
5
+ ],
6
+ "attn_pdrop": 0.1,
7
+ "bos_token_id": 50256,
8
+ "embd_pdrop": 0.1,
9
+ "eos_token_id": 50256,
10
+ "gradient_checkpointing": false,
11
+ "initializer_range": 0.02,
12
+ "layer_norm_epsilon": 1e-05,
13
+ "model_type": "gpt2",
14
+ "n_ctx": 1024,
15
+ "n_embd": 768,
16
+ "n_head": 12,
17
+ "n_inner": null,
18
+ "n_layer": 12,
19
+ "n_positions": 1024,
20
+ "resid_pdrop": 0.1,
21
+ "summary_activation": null,
22
+ "summary_first_dropout": 0.1,
23
+ "summary_proj_to_labels": true,
24
+ "summary_type": "cls_index",
25
+ "summary_use_proj": true,
26
+ "task_specific_params": {
27
+ "text-generation": {
28
+ "do_sample": true,
29
+ "max_length": 50
30
+ }
31
+ },
32
+ "vocab_size": 50257
33
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bf8ed7c2e3b26b8a4d53e59f814b9fa03ae06d552ef08fc5f3f3bea4667e0406
3
+ size 510408315
special_tokens_map.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"bos_token": {"content": "<|endoftext|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "eos_token": {"content": "<|endoftext|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "unk_token": {"content": "<|endoftext|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true, "__type": "AddedToken"}}
tokenizer_config.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"bos_token": {"content": "<|endoftext|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "eos_token": {"content": "<|endoftext|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "unk_token": {"content": "<|endoftext|>", "single_word": false, "lstrip": false, "rstrip": false, "normalized": true, "__type": "AddedToken"}, "model_max_length": 1024}
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:043dbd5dd0744b2a7a925444abcf14b69fc74480e21f2eb163d4deb3381eba98
3
+ size 1839
vocab.json ADDED
The diff for this file is too large to render. See raw diff