Update app.py
Browse files
app.py
CHANGED
@@ -140,8 +140,8 @@ def run_interpretation(raw_original_prompt, raw_interpretation_prompt, max_new_t
|
|
140 |
# try identifying important layers
|
141 |
vectors_to_compare = interpreted_vectors # torch.tensor(global_state.sentence_transformer.encode(generation_texts))
|
142 |
diff_score1 = F.normalize(vectors_to_compare, dim=-1).diff(dim=0).norm(dim=-1).cpu()
|
143 |
-
|
144 |
-
bags_of_words = [set(
|
145 |
diff_score2 = torch.tensor([
|
146 |
-len(bags_of_words[i+1] & bags_of_words[i]) / np.sqrt(len(bags_of_words[i+1]) * len(bags_of_words[i]))
|
147 |
for i in range(len(bags_of_words)-1)
|
|
|
140 |
# try identifying important layers
|
141 |
vectors_to_compare = interpreted_vectors # torch.tensor(global_state.sentence_transformer.encode(generation_texts))
|
142 |
diff_score1 = F.normalize(vectors_to_compare, dim=-1).diff(dim=0).norm(dim=-1).cpu()
|
143 |
+
tokenized_generations = [tokenizer.tokenize(text) for text in generation_texts]
|
144 |
+
bags_of_words = [set(tokens) | set([(tokens[i], tokens[i+1]) for i in range(len(tokens)-1)]) for tokens in tokenized_generations]
|
145 |
diff_score2 = torch.tensor([
|
146 |
-len(bags_of_words[i+1] & bags_of_words[i]) / np.sqrt(len(bags_of_words[i+1]) * len(bags_of_words[i]))
|
147 |
for i in range(len(bags_of_words)-1)
|