qinghuazhou commited on
Commit
93cfb54
·
1 Parent(s): ce3bcf8

updated demo

Browse files
Files changed (1) hide show
  1. app.py +30 -29
app.py CHANGED
@@ -11,22 +11,22 @@ from util import utils
11
 
12
  ## UTILITY FUNCTIONS ################################################
13
 
14
- # @spaces.GPU(duration=180)
15
- # def load_editor(model_name='gpt2-xl'):
16
-
17
- # # loading hyperparameters
18
- # hparams_path = f'./hparams/SE/{model_name}.json'
19
- # hparams = utils.loadjson(hparams_path)
20
-
21
- # editor = editors.StealthEditor(
22
- # model_name=model_name,
23
- # hparams = hparams,
24
- # layer = 13,
25
- # cache_path='/data/cache/',
26
- # edit_mode='in-place',
27
- # verbose=True
28
- # )
29
- # return editor
30
 
31
  @spaces.GPU
32
  def return_generate(prompt):
@@ -142,27 +142,28 @@ def insert_examples1():
142
 
143
  ## MAIN GUI #######################################################
144
 
145
- # load editor (a medium model for the demo)
146
- model_name='llama-3-8b'
147
 
148
- # loading hyperparameters
149
- hparams = utils.loadjson(f'./hparams/SE/{model_name}.json')
150
 
151
- editor = editors.StealthEditor(
152
- model_name=model_name,
153
- hparams = hparams,
154
- layer = 13,
155
- cache_path='/data/cache/',
156
- edit_mode='in-place',
157
- verbose=True
158
- )
 
159
 
160
  with gr.Blocks(theme=gr.themes.Soft(text_size="sm")) as demo:
161
 
162
 
163
  gr.Markdown(
164
  """
165
- # Stealth edits for provably fixing or attacking large language models
166
 
167
  Here in this demo, you will be able to test out stealth edits and attacks from the paper [***"Stealth edits for provably fixing or attacking large language models"***](https://arxiv.org/abs/2406.12670v1) on the `llama-3-8b` model. For more detailed experiments, please refer to our [paper](https://arxiv.org/abs/2406.12670v1) and our [source code](https://github.com/qinghua-zhou/stealth-edits).
168
 
 
11
 
12
  ## UTILITY FUNCTIONS ################################################
13
 
14
+ @spaces.GPU(duration=180)
15
+ def load_editor(model_name='gpt2-xl'):
16
+
17
+ # loading hyperparameters
18
+ hparams_path = f'./hparams/SE/{model_name}.json'
19
+ hparams = utils.loadjson(hparams_path)
20
+
21
+ editor = editors.StealthEditor(
22
+ model_name=model_name,
23
+ hparams = hparams,
24
+ layer = 13,
25
+ cache_path='/data/cache/',
26
+ edit_mode='in-place',
27
+ verbose=True
28
+ )
29
+ return editor
30
 
31
  @spaces.GPU
32
  def return_generate(prompt):
 
142
 
143
  ## MAIN GUI #######################################################
144
 
145
+ # # load editor (a medium model for the demo)
146
+ # model_name='llama-3-8b'
147
 
148
+ # # loading hyperparameters
149
+ # hparams = utils.loadjson(f'./hparams/SE/{model_name}.json')
150
 
151
+ # editor = editors.StealthEditor(
152
+ # model_name=model_name,
153
+ # hparams = hparams,
154
+ # layer = 13,
155
+ # cache_path='/data/cache/',
156
+ # edit_mode='in-place',
157
+ # verbose=True
158
+ # )
159
+ editor = load_editor(model_name='llama-3-8b')
160
 
161
  with gr.Blocks(theme=gr.themes.Soft(text_size="sm")) as demo:
162
 
163
 
164
  gr.Markdown(
165
  """
166
+ # Stealth edeits for provably fixing or attacking large language models
167
 
168
  Here in this demo, you will be able to test out stealth edits and attacks from the paper [***"Stealth edits for provably fixing or attacking large language models"***](https://arxiv.org/abs/2406.12670v1) on the `llama-3-8b` model. For more detailed experiments, please refer to our [paper](https://arxiv.org/abs/2406.12670v1) and our [source code](https://github.com/qinghua-zhou/stealth-edits).
169