Spaces:
Runtime error
Runtime error
anonymousauthors
commited on
Commit
β’
8a8c82c
1
Parent(s):
b53f7e8
Update pages/2_π_BlackBox_and_WhiteBox_Attacks.py
Browse files
pages/2_π_BlackBox_and_WhiteBox_Attacks.py
CHANGED
@@ -25,12 +25,12 @@ st.sidebar.markdown('`Input text`: a sentence or paragraph.')
|
|
25 |
st.sidebar.markdown('`Number of replacements`: the number of secret language samples.')
|
26 |
st.sidebar.markdown('`Steps for searching Secret Langauge`: the steps in the SecretFinding process.')
|
27 |
st.sidebar.markdown('#### Two methods')
|
28 |
-
st.sidebar.markdown('1. Searching secret languages based on models: this method calculates secret languages using [gpt2-medium](https://huggingface.co/gpt2-medium), [EleutherAI/gpt-neo-1.3B](https://huggingface.co/EleutherAI/gpt-neo-1.3B)') #, [EleutherAI/gpt-neo-2.7B](https://huggingface.co/EleutherAI/gpt-neo-2.7B), [EleutherAI/gpt-neox-20b](https://huggingface.co/EleutherAI/gpt-neox-20b), or [EleutherAI/gpt-j-6B](https://huggingface.co/EleutherAI/gpt-j-6B).')
|
29 |
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.')
|
30 |
|
31 |
st.sidebar.markdown('#### Return')
|
32 |
st.sidebar.markdown(
|
33 |
-
'To see whether the whitebox attack works on LLMs (gpt2
|
34 |
)
|
35 |
st.sidebar.markdown(
|
36 |
'To see whether the blackbox attack works on LLMs, we also add the response using [Codex](https://openai.com/blog/openai-codex/). '
|
@@ -264,8 +264,8 @@ title = st.text_area('Input text.', 'Which name is also used to describe the Ama
|
|
264 |
if option == 'Searching secret languages based on models':
|
265 |
model_choice = st.selectbox(
|
266 |
'Which model you would like to use?',
|
267 |
-
# ('gpt2
|
268 |
-
('gpt2-medium', "EleutherAI/gpt-neo-1.3B")
|
269 |
)
|
270 |
_cols = st.columns(2)
|
271 |
restarts = _cols[0].number_input('Number of replacements.', value=10, min_value=1, step=1, format='%d')
|
@@ -277,7 +277,7 @@ if button('Tokenize', key='tokenizer'):
|
|
277 |
if option == 'Searching secret languages based on models':
|
278 |
tokenizer = AutoTokenizer.from_pretrained(model_choice)
|
279 |
else:
|
280 |
-
tokenizer = AutoTokenizer.from_pretrained('gpt2
|
281 |
for key in st.session_state.keys():
|
282 |
if key not in ['tokenizer', 'start'] and 'tokenizer_' not in key:
|
283 |
del st.session_state[key]
|
@@ -318,7 +318,7 @@ if button('Tokenize', key='tokenizer'):
|
|
318 |
if not platform.system().lower() == 'darwin':
|
319 |
generator1 = pipeline('text-generation', model='EleutherAI/gpt-neo-1.3B')
|
320 |
with st.expander('**Original input text**: '+ title):
|
321 |
-
st.markdown(f'The response of gpt2
|
322 |
st.markdown('<blockquote>' + generator(title, max_length=256, num_return_sequences=1)[0]['generated_text'].replace(title, '', 1) + '</blockquote>', unsafe_allow_html=True)
|
323 |
if not platform.system().lower() == 'darwin':
|
324 |
st.markdown(f'The response of EleutherAI/gpt-neo-1.3B with the prompt :blue[{title}]')
|
@@ -363,7 +363,7 @@ if button('Tokenize', key='tokenizer'):
|
|
363 |
# st.markdown('<br>'.join(outputs), unsafe_allow_html=True)
|
364 |
for i in range(restarts):
|
365 |
with st.expander(outputs[i]):
|
366 |
-
st.markdown(f'The response of gpt2
|
367 |
st.markdown('<blockquote>' + generator(outputs[i], max_length=256, num_return_sequences=1)[0]['generated_text'].replace(title, '', 1) + '</blockquote>', unsafe_allow_html=True)
|
368 |
if not platform.system().lower() == 'darwin':
|
369 |
st.markdown(f'The response of EleutherAI/gpt-neo-1.3B with the prompt :blue[{outputs[i]}]')
|
|
|
25 |
st.sidebar.markdown('`Number of replacements`: the number of secret language samples.')
|
26 |
st.sidebar.markdown('`Steps for searching Secret Langauge`: the steps in the SecretFinding process.')
|
27 |
st.sidebar.markdown('#### Two methods')
|
28 |
+
st.sidebar.markdown('1. Searching secret languages based on models: this method calculates secret languages using [gpt2](https://huggingface.co/gpt2), [gpt-medium](https://huggingface.co/gpt2-medium), [EleutherAI/gpt-neo-1.3B](https://huggingface.co/EleutherAI/gpt-neo-1.3B)') #, [EleutherAI/gpt-neo-2.7B](https://huggingface.co/EleutherAI/gpt-neo-2.7B), [EleutherAI/gpt-neox-20b](https://huggingface.co/EleutherAI/gpt-neox-20b), or [EleutherAI/gpt-j-6B](https://huggingface.co/EleutherAI/gpt-j-6B).')
|
29 |
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.')
|
30 |
|
31 |
st.sidebar.markdown('#### Return')
|
32 |
st.sidebar.markdown(
|
33 |
+
'To see whether the whitebox attack works on LLMs (gpt2 and EleutherAI/gpt-neo-1.3B), we set random seeds to 0 and present the responses.'
|
34 |
)
|
35 |
st.sidebar.markdown(
|
36 |
'To see whether the blackbox attack works on LLMs, we also add the response using [Codex](https://openai.com/blog/openai-codex/). '
|
|
|
264 |
if option == 'Searching secret languages based on models':
|
265 |
model_choice = st.selectbox(
|
266 |
'Which model you would like to use?',
|
267 |
+
# ('gpt2', "EleutherAI/gpt-neo-1.3B", "EleutherAI/gpt-neo-2.7B", "EleutherAI/gpt-neox-20b", "EleutherAI/gpt-j-6B")
|
268 |
+
('gpt2', 'gpt-medium', "EleutherAI/gpt-neo-1.3B")
|
269 |
)
|
270 |
_cols = st.columns(2)
|
271 |
restarts = _cols[0].number_input('Number of replacements.', value=10, min_value=1, step=1, format='%d')
|
|
|
277 |
if option == 'Searching secret languages based on models':
|
278 |
tokenizer = AutoTokenizer.from_pretrained(model_choice)
|
279 |
else:
|
280 |
+
tokenizer = AutoTokenizer.from_pretrained('gpt2')
|
281 |
for key in st.session_state.keys():
|
282 |
if key not in ['tokenizer', 'start'] and 'tokenizer_' not in key:
|
283 |
del st.session_state[key]
|
|
|
318 |
if not platform.system().lower() == 'darwin':
|
319 |
generator1 = pipeline('text-generation', model='EleutherAI/gpt-neo-1.3B')
|
320 |
with st.expander('**Original input text**: '+ title):
|
321 |
+
st.markdown(f'The response of gpt2 with the prompt :blue[{title}]')
|
322 |
st.markdown('<blockquote>' + generator(title, max_length=256, num_return_sequences=1)[0]['generated_text'].replace(title, '', 1) + '</blockquote>', unsafe_allow_html=True)
|
323 |
if not platform.system().lower() == 'darwin':
|
324 |
st.markdown(f'The response of EleutherAI/gpt-neo-1.3B with the prompt :blue[{title}]')
|
|
|
363 |
# st.markdown('<br>'.join(outputs), unsafe_allow_html=True)
|
364 |
for i in range(restarts):
|
365 |
with st.expander(outputs[i]):
|
366 |
+
st.markdown(f'The response of gpt2 with the prompt :blue[{outputs[i]}]')
|
367 |
st.markdown('<blockquote>' + generator(outputs[i], max_length=256, num_return_sequences=1)[0]['generated_text'].replace(title, '', 1) + '</blockquote>', unsafe_allow_html=True)
|
368 |
if not platform.system().lower() == 'darwin':
|
369 |
st.markdown(f'The response of EleutherAI/gpt-neo-1.3B with the prompt :blue[{outputs[i]}]')
|