Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,9 +5,12 @@ import seaborn as sns
|
|
5 |
|
6 |
dataset = load_dataset('dar-tau/grammar-attention-maps-opt-350m')['train']
|
7 |
|
8 |
-
def
|
9 |
-
|
|
|
|
|
10 |
|
11 |
|
12 |
-
iface = gr.Interface(fn=
|
|
|
13 |
iface.launch()
|
|
|
5 |
|
6 |
dataset = load_dataset('dar-tau/grammar-attention-maps-opt-350m')['train']
|
7 |
|
8 |
+
def analyze_sentence(index):
|
9 |
+
row = dataset[index]
|
10 |
+
attn_maps = np.array(row['attention_maps']).reshape(*row['attention_maps_shape'])
|
11 |
+
return row['text'], sns.heatmap(attn_maps.sum(1).sum(0))
|
12 |
|
13 |
|
14 |
+
iface = gr.Interface(fn=analyze_sentence, inputs=[gr.Dropdown(choices=dataset['text'], type='index')],
|
15 |
+
outputs=[gr.Label(), gr.Plot(label="Plot")])
|
16 |
iface.launch()
|