Spaces:
Runtime error
Runtime error
Commit
•
3567c6f
1
Parent(s):
bfa9c36
fix: more minor fixes
Browse files- explanation/attention.py +1 -18
- main.py +1 -4
explanation/attention.py
CHANGED
@@ -30,24 +30,7 @@ def chat_explained(model, prompt):
|
|
30 |
model.TOKENIZER.convert_ids_to_tokens(decoder_input_ids[0])
|
31 |
)
|
32 |
|
33 |
-
|
34 |
-
if isinstance(model, godel):
|
35 |
-
print("attention.py: Model detected to be GODEL")
|
36 |
-
|
37 |
-
# get attention values for the input and output vectors
|
38 |
-
# using already generated input and output
|
39 |
-
attention_output = model.MODEL.generate(
|
40 |
-
input_ids=encoder_input_ids,
|
41 |
-
decoder_input_ids=decoder_input_ids,
|
42 |
-
output_attentions=True,
|
43 |
-
)
|
44 |
-
|
45 |
-
# averaging attention across layers
|
46 |
-
averaged_attention = fmt.avg_attention(attention_output)
|
47 |
-
|
48 |
-
# getting attention is model is mistral
|
49 |
-
else:
|
50 |
-
averaged_attention = fmt.avg_attention(decoder_input_ids)
|
51 |
|
52 |
# format response text for clean output
|
53 |
response_text = fmt.format_output_text(decoder_text)
|
|
|
30 |
model.TOKENIZER.convert_ids_to_tokens(decoder_input_ids[0])
|
31 |
)
|
32 |
|
33 |
+
averaged_attention = fmt.avg_attention(decoder_input_ids)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
# format response text for clean output
|
36 |
response_text = fmt.format_output_text(decoder_text)
|
main.py
CHANGED
@@ -110,10 +110,7 @@ with gr.Blocks(
|
|
110 |
label="System Prompt",
|
111 |
info="Set the models system prompt, dictating how it answers.",
|
112 |
# default system prompt is set to this in the backend
|
113 |
-
placeholder=""
|
114 |
-
You are a helpful, respectful and honest assistant. Always
|
115 |
-
answer as helpfully as possible, while being safe.
|
116 |
-
""",
|
117 |
)
|
118 |
# column that takes up 1/4 of the row
|
119 |
with gr.Column(scale=1):
|
|
|
110 |
label="System Prompt",
|
111 |
info="Set the models system prompt, dictating how it answers.",
|
112 |
# default system prompt is set to this in the backend
|
113 |
+
placeholder=("You are a helpful, respectful and honest assistant. Always answer as helpfully as possible, while being safe.",
|
|
|
|
|
|
|
114 |
)
|
115 |
# column that takes up 1/4 of the row
|
116 |
with gr.Column(scale=1):
|