Spaces:
Runtime error
Runtime error
anonymousauthors
commited on
Commit
β’
e5ee22e
1
Parent(s):
d0a7e03
Update pages/2_π_Blackbox_Attack.py
Browse files
pages/2_π_Blackbox_Attack.py
CHANGED
@@ -11,7 +11,14 @@ all_keys = [i.strip() for i in all_keys]
|
|
11 |
import torch
|
12 |
from copy import deepcopy
|
13 |
from time import time
|
|
|
14 |
st.title('Blackbox Attack')
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
def run(model, _bar_text=None, bar=None, text='Which name is also used to describe the Amazon rainforest in English?', loss_funt=torch.nn.MSELoss(), lr=1, noise_mask=[1,2], restarts=10, step=100, device = torch.device('cpu')):
|
16 |
subword_num = model.wte.weight.shape[0]
|
17 |
|
@@ -78,7 +85,7 @@ title = st.text_area('Input text.', 'Which name is also used to describe the Ama
|
|
78 |
if option == 'GPT-2 (Searching secret languages based on GPT-2)':
|
79 |
_cols = st.columns(2)
|
80 |
restarts = _cols[0].number_input('Number of replacements.', value=10, min_value=1, step=1, format='%d')
|
81 |
-
step = _cols[1].number_input('
|
82 |
else:
|
83 |
restarts = st.number_input('Number of replacements.', value=10, min_value=1, step=1, format='%d')
|
84 |
|
|
|
11 |
import torch
|
12 |
from copy import deepcopy
|
13 |
from time import time
|
14 |
+
|
15 |
st.title('Blackbox Attack')
|
16 |
+
st.sidebar.markdown('On this page, we offer a tool for generating replacement words using secret languages.')
|
17 |
+
|
18 |
+
st.sidebar.markdown('There are two methods for generating replacements.')
|
19 |
+
st.sidebar.markdown('1. GPT-2 (Searching secret languages based on GPT-2): this method calculates secret languages using [GPT-2](https://huggingface.co/gpt2) and requires input text, the number of replacements desired, and the steps. The number of replacements represents the number of sentences you want to generate, while steps refer to the steps in the SecretFinding process.')
|
20 |
+
st.sidebar.markdown('2. Use the secret language we found on ALBERT, DistillBERT, and Roberta: this method replaces words directly with the secret language dictionary derived from ALBERT, DistillBERT, and Roberta.')
|
21 |
+
|
22 |
def run(model, _bar_text=None, bar=None, text='Which name is also used to describe the Amazon rainforest in English?', loss_funt=torch.nn.MSELoss(), lr=1, noise_mask=[1,2], restarts=10, step=100, device = torch.device('cpu')):
|
23 |
subword_num = model.wte.weight.shape[0]
|
24 |
|
|
|
85 |
if option == 'GPT-2 (Searching secret languages based on GPT-2)':
|
86 |
_cols = st.columns(2)
|
87 |
restarts = _cols[0].number_input('Number of replacements.', value=10, min_value=1, step=1, format='%d')
|
88 |
+
step = _cols[1].number_input('Steps for searching Secret Langauge', value=100, min_value=1, step=1, format='%d')
|
89 |
else:
|
90 |
restarts = st.number_input('Number of replacements.', value=10, min_value=1, step=1, format='%d')
|
91 |
|