Martijn van Beers commited on
Commit
5a1ac3e
1 Parent(s): cd3f110

Put examples in an external file too

Browse files
Files changed (3) hide show
  1. app.py +4 -28
  2. examples.csv +7 -0
  3. requirements.txt +1 -1
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import sys
 
2
  import gradio
3
 
4
  sys.path.append("BERT_explainability")
@@ -283,33 +284,8 @@ lig = gradio.Interface(
283
  with open("description.md", "r") as fh:
284
  description = fh.read()
285
 
286
- iface = gradio.Parallel(hila, lig, title="RoBERTa Explainability", description=description,
287
- examples=[
288
- [
289
- "This movie was the best movie I have ever seen! some scenes were ridiculous, but acting was great",
290
- 8
291
- ],
292
- [
293
- "I really didn't like this movie. Some of the actors were good, but overall the movie was boring",
294
- 8
295
- ],
296
- [
297
- "If the acting had been better, this movie might have been pretty good.",
298
- 8
299
- ],
300
- [
301
- "If he had hated it, he would not have said that he loved it.",
302
- 8
303
- ],
304
- [
305
- "If he had hated it, he would not have said that he loved it.",
306
- 2
307
- ],
308
- [
309
- "Attribution methods are very interesting, but unfortunately do not work reliably out of the box.",
310
- 8
311
- ]
312
- ],
313
- )
314
 
315
  iface.launch()
 
1
  import sys
2
+ import pandas
3
  import gradio
4
 
5
  sys.path.append("BERT_explainability")
 
284
  with open("description.md", "r") as fh:
285
  description = fh.read()
286
 
287
+ examples = pandas.read_csv("examples.csv").to_numpy().tolist()
288
+
289
+ iface = gradio.Parallel(hila, lig, title="RoBERTa Explainability", description=description, examples=examples)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
 
291
  iface.launch()
examples.csv ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ sentence,layer
2
+ "This movie was the best movie I have ever seen! some scenes were ridiculous, but acting was great",8
3
+ "I really didn't like this movie. Some of the actors were good, but overall the movie was boring",8
4
+ "If the acting had been better, this movie might have been pretty good.",8
5
+ "If he had hated it, he would not have said that he loved it.",8
6
+ "If he had hated it, he would not have said that he loved it.",2
7
+ "Attribution methods are very interesting, but unfortunately do not work reliably out of the box.",8
requirements.txt CHANGED
@@ -1,4 +1,4 @@
1
  torch
2
  transformers==4.21.2
3
- captum
4
 
 
1
  torch
2
  transformers==4.21.2
3
+ pandas
4