dar-tau commited on
Commit
d3eb5d2
·
verified ·
1 Parent(s): 40068d7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -139,8 +139,11 @@ def run_interpretation(raw_original_prompt, raw_interpretation_prompt, max_new_t
139
 
140
  # try identifying important layers
141
  vectors_to_compare = interpreted_vectors # torch.tensor(global_state.sentence_transformer.encode(generation_texts))
 
 
 
142
  diff_score = F.normalize(vectors_to_compare, dim=-1).diff(dim=0).norm(dim=-1)
143
- important_idxs = 1 + diff_score.topk(k=int(np.ceil(0.2 * len(generation_texts)))).indices.cpu().numpy()
144
 
145
  # create GUI output
146
  print(f'{important_idxs=}')
 
139
 
140
  # try identifying important layers
141
  vectors_to_compare = interpreted_vectors # torch.tensor(global_state.sentence_transformer.encode(generation_texts))
142
+ # layers that are usually never important
143
+ avoid_first_exclusive, avoid_last = 3, 1
144
+ vectors_to_compare = vectors_to_compare[avoid_first_exclusive:-avoid_last]
145
  diff_score = F.normalize(vectors_to_compare, dim=-1).diff(dim=0).norm(dim=-1)
146
+ important_idxs = avoid_first_exclusive + diff_score.topk(k=int(np.ceil(0.1 * len(generation_texts)))).indices.cpu().numpy()
147
 
148
  # create GUI output
149
  print(f'{important_idxs=}')