d0rj commited on
Commit
9445c3c
·
1 Parent(s): a234c7d

feat, build: add dataset viewver example

Browse files
Files changed (2) hide show
  1. .gitignore +1 -0
  2. app.py +60 -0
.gitignore CHANGED
@@ -2,6 +2,7 @@ notebooks/
2
  tmp*
3
  *.jsonl
4
  *.json
 
5
 
6
  # Byte-compiled / optimized / DLL files
7
  __pycache__/
 
2
  tmp*
3
  *.jsonl
4
  *.json
5
+ .gradio/
6
 
7
  # Byte-compiled / optimized / DLL files
8
  __pycache__/
app.py CHANGED
@@ -1,9 +1,50 @@
1
  import gradio as gr
2
  from gradio_leaderboard import Leaderboard, SelectColumns, ColumnFilter
3
 
 
 
4
  from src.common.paths import DOCS_PATH, DATASET_NAME
5
 
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  with gr.Blocks(
8
  title="ROMB Leaderboard v1.0",
9
  theme=gr.themes.Ocean(
@@ -19,6 +60,25 @@ with gr.Blocks(
19
  gr.Markdown((DOCS_PATH / "evaluate.md").read_text())
20
  with gr.Tab("Submit"):
21
  gr.Markdown("In progress...")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
 
24
  if __name__ == "__main__":
 
1
  import gradio as gr
2
  from gradio_leaderboard import Leaderboard, SelectColumns, ColumnFilter
3
 
4
+ from src.common.data import load_dataset
5
+ from src.common.schema import DatasetSchema
6
  from src.common.paths import DOCS_PATH, DATASET_NAME
7
 
8
 
9
+ _dataset = load_dataset()
10
+
11
+
12
+ def show_dataset_example(id_: str) -> str:
13
+ example = _dataset[_dataset[DatasetSchema.id_] == id_].iloc[0]
14
+ text = f"""
15
+ ## Task
16
+
17
+ **{example[DatasetSchema.description]}**
18
+
19
+ {example[DatasetSchema.task_text]}
20
+
21
+ ### Answer type
22
+
23
+ ```python
24
+ {example[DatasetSchema.answer_type]}
25
+ ```
26
+
27
+ ({example[DatasetSchema.task_note]})
28
+
29
+ ## Answer
30
+
31
+ {example[DatasetSchema.answer_text]}
32
+
33
+ ### Correct answer
34
+
35
+ ```json
36
+ {example[DatasetSchema.correct_answer]}
37
+ ```
38
+
39
+ ### Answer check
40
+
41
+ {example[DatasetSchema.check_type]}
42
+ """.strip()
43
+ if example[DatasetSchema.check_function]:
44
+ text += f"\n\n#### Check function\n\n```python\n{example[DatasetSchema.check_function]}\n```"
45
+ return text
46
+
47
+
48
  with gr.Blocks(
49
  title="ROMB Leaderboard v1.0",
50
  theme=gr.themes.Ocean(
 
60
  gr.Markdown((DOCS_PATH / "evaluate.md").read_text())
61
  with gr.Tab("Submit"):
62
  gr.Markdown("In progress...")
63
+ with gr.Tab("Example"):
64
+ gr.Interface(
65
+ fn=show_dataset_example,
66
+ inputs=gr.Dropdown(
67
+ choices=list(_dataset[DatasetSchema.id_]),
68
+ value=0,
69
+ label="Example ID",
70
+ ),
71
+ outputs=gr.Markdown(label="Example"),
72
+ title="Show Dataset Example",
73
+ examples=[
74
+ [8],
75
+ [14],
76
+ [17],
77
+ [22],
78
+ [40],
79
+ [230],
80
+ ]
81
+ )
82
 
83
 
84
  if __name__ == "__main__":