Spaces:
Runtime error
Runtime error
Yacine Jernite
commited on
Commit
•
37b8c09
1
Parent(s):
ac6c40f
add GEM section
Browse files- datacards/gem.py +66 -3
- datacards/overview.py +5 -4
- datacards/streamlit_utils.py +21 -11
datacards/gem.py
CHANGED
@@ -4,10 +4,73 @@ from .streamlit_utils import (
|
|
4 |
make_text_input
|
5 |
)
|
6 |
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
def gem_page():
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
def gem_summary():
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
make_text_input
|
5 |
)
|
6 |
|
7 |
+
from .streamlit_utils import (
|
8 |
+
make_multiselect,
|
9 |
+
make_selectbox,
|
10 |
+
make_text_area,
|
11 |
+
make_text_input,
|
12 |
+
make_radio,
|
13 |
+
)
|
14 |
+
|
15 |
+
N_FIELDS_RATIONALE = 5
|
16 |
+
N_FIELDS_STARTING = 2
|
17 |
+
|
18 |
+
N_FIELDS = N_FIELDS_RATIONALE + \
|
19 |
+
N_FIELDS_STARTING
|
20 |
+
|
21 |
|
22 |
def gem_page():
|
23 |
+
st.session_state.card_dict["gem"] = st.session_state.card_dict.get("gem", {})
|
24 |
+
with st.expander("Rationale", expanded=False):
|
25 |
+
key_pref = ["gem", "rationale"]
|
26 |
+
st.session_state.card_dict["gem"]["rationale"] = st.session_state.card_dict["gem"].get("rationale", {})
|
27 |
+
make_text_area(
|
28 |
+
label="Contribution toward better generation evaluation",
|
29 |
+
key_list=key_pref + ["contribution"],
|
30 |
+
help="Describe briefly what makes this dataset an interesting target for NLG evaluations and why it is part of GEM",
|
31 |
+
)
|
32 |
+
make_radio(
|
33 |
+
label="Do other datasets for the high level task exist?",
|
34 |
+
options=["no", "yes"],
|
35 |
+
key_list=key_pref + ["sole-task-dataset"],
|
36 |
+
help="for example, is this the only summarization dataset proposed in GEM",
|
37 |
+
)
|
38 |
+
make_radio(
|
39 |
+
label="Does this dataset cover other languages than other datasets for the same task?",
|
40 |
+
options=["no", "yes"],
|
41 |
+
key_list=key_pref + ["sole-language-task-dataset"],
|
42 |
+
help="for example, is this the only summarization dataset proposed in GEM to have French text?",
|
43 |
+
)
|
44 |
+
make_text_area(
|
45 |
+
label="What else sets this dataset apart from other similar datasets in GEM?",
|
46 |
+
key_list=key_pref + ["distinction-description"],
|
47 |
+
help="Describe briefly for each similar dataset (same task/languages) what sets this one apart",
|
48 |
+
)
|
49 |
+
make_text_area(
|
50 |
+
label="What aspect of model ability can be measured with this dataset?",
|
51 |
+
key_list=key_pref + ["model-ability"],
|
52 |
+
help="What kind of abilities should a model exhibit that performs well on the task of this dataset (e.g., reasoning capability, morphological inflection)?",
|
53 |
+
)
|
54 |
+
with st.expander("Getting Started", expanded=False):
|
55 |
+
key_pref = ["gem", "starting"]
|
56 |
+
st.session_state.card_dict["gem"]["starting"] = st.session_state.card_dict["gem"].get("starting", {})
|
57 |
+
make_text_area(
|
58 |
+
label="Getting started with in-depth research on the task. Add relevant pointers to resources that researchers can consult when they want to get started digging deeper into the task.",
|
59 |
+
key_list=key_pref + ["research-pointers"],
|
60 |
+
help=" These can include blog posts, research papers, literature surveys, etc. You can also link to tutorials on the GEM website.",
|
61 |
+
)
|
62 |
+
make_text_area(
|
63 |
+
label="Technical terms used in this card and the dataset and their definitions",
|
64 |
+
key_list=key_pref + ["technical-terms"],
|
65 |
+
help="Provide a brief definition of technical terms that are unique to this dataset",
|
66 |
+
)
|
67 |
+
|
68 |
|
69 |
def gem_summary():
|
70 |
+
total_filled = sum([len(dct) for dct in st.session_state.card_dict.get('gem', {}).values()])
|
71 |
+
with st.expander(f"Dataset in GEM Completion - {total_filled} of {N_FIELDS}", expanded=False):
|
72 |
+
completion_markdown = ""
|
73 |
+
completion_markdown += f"- **Overall competion:**\n - {total_filled} of {N_FIELDS} fields\n"
|
74 |
+
completion_markdown += f"- **Sub-section - Rationale:**\n - {len(st.session_state.card_dict.get('gem', {}).get('rationale', {}))} of {N_FIELDS_RATIONALE} fields\n"
|
75 |
+
completion_markdown += f"- **Sub-section - Getting Started:**\n - {len(st.session_state.card_dict.get('gem', {}).get('starting', {}))} of {N_FIELDS_STARTING} fields\n"
|
76 |
+
st.markdown(completion_markdown)
|
datacards/overview.py
CHANGED
@@ -34,7 +34,7 @@ def overview_page():
|
|
34 |
st.session_state.card_dict["overview"] = st.session_state.card_dict.get("overview", {})
|
35 |
with st.expander("Where to find", expanded=False):
|
36 |
key_pref = ["overview", "where"]
|
37 |
-
st.session_state.card_dict["overview"]["where"] = st.session_state.card_dict.get("where", {})
|
38 |
make_text_input(
|
39 |
label="What is the webpage for the dataset (if it exists)?",
|
40 |
key_list=key_pref + ["website"],
|
@@ -83,7 +83,7 @@ def overview_page():
|
|
83 |
)
|
84 |
with st.expander("Languages and Intended Use", expanded=False):
|
85 |
key_pref = ["overview", "languages"]
|
86 |
-
st.session_state.card_dict["overview"]["languages"] = st.session_state.card_dict.get("languages", {})
|
87 |
make_radio(
|
88 |
label="Is the dataset multilingual?",
|
89 |
options=["no", "yes"],
|
@@ -184,9 +184,10 @@ def overview_page():
|
|
184 |
|
185 |
|
186 |
def overview_summary():
|
187 |
-
|
|
|
188 |
completion_markdown = ""
|
189 |
-
completion_markdown += f"- **Overall competion:**\n - {
|
190 |
completion_markdown += f"- **Sub-section - Where to find:**\n - {len(st.session_state.card_dict.get('overview', {}).get('where', {}))} of {N_FIELDS_WHERE} fields\n"
|
191 |
completion_markdown += f"- **Sub-section - Languages and Intended Use:**\n - {len(st.session_state.card_dict.get('overview', {}).get('languages', {}))} of {N_FIELDS_LANGUAGES} fields\n"
|
192 |
completion_markdown += f"- **Sub-section - Credit:**\n - {len(st.session_state.card_dict.get('overview', {}).get('credit', {}))} of {N_FIELDS_CREDIT} fields\n"
|
|
|
34 |
st.session_state.card_dict["overview"] = st.session_state.card_dict.get("overview", {})
|
35 |
with st.expander("Where to find", expanded=False):
|
36 |
key_pref = ["overview", "where"]
|
37 |
+
st.session_state.card_dict["overview"]["where"] = st.session_state.card_dict["overview"].get("where", {})
|
38 |
make_text_input(
|
39 |
label="What is the webpage for the dataset (if it exists)?",
|
40 |
key_list=key_pref + ["website"],
|
|
|
83 |
)
|
84 |
with st.expander("Languages and Intended Use", expanded=False):
|
85 |
key_pref = ["overview", "languages"]
|
86 |
+
st.session_state.card_dict["overview"]["languages"] = st.session_state.card_dict["overview"].get("languages", {})
|
87 |
make_radio(
|
88 |
label="Is the dataset multilingual?",
|
89 |
options=["no", "yes"],
|
|
|
184 |
|
185 |
|
186 |
def overview_summary():
|
187 |
+
total_filled = sum([len(dct) for dct in st.session_state.card_dict.get('overview', {}).values()])
|
188 |
+
with st.expander(f"Dataset Overview Completion - {total_filled} of {N_FIELDS}", expanded=False):
|
189 |
completion_markdown = ""
|
190 |
+
completion_markdown += f"- **Overall competion:**\n - {total_filled} of {N_FIELDS} fields\n"
|
191 |
completion_markdown += f"- **Sub-section - Where to find:**\n - {len(st.session_state.card_dict.get('overview', {}).get('where', {}))} of {N_FIELDS_WHERE} fields\n"
|
192 |
completion_markdown += f"- **Sub-section - Languages and Intended Use:**\n - {len(st.session_state.card_dict.get('overview', {}).get('languages', {}))} of {N_FIELDS_LANGUAGES} fields\n"
|
193 |
completion_markdown += f"- **Sub-section - Credit:**\n - {len(st.session_state.card_dict.get('overview', {}).get('credit', {}))} of {N_FIELDS_CREDIT} fields\n"
|
datacards/streamlit_utils.py
CHANGED
@@ -2,15 +2,20 @@ import streamlit as st
|
|
2 |
|
3 |
|
4 |
# Streamlit widgets with persistence
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
7 |
state_key = "_".join(key_list)
|
8 |
-
if st.session_state.save_state.get(state_key,
|
9 |
card_key = key_list[-1]
|
10 |
current_dict = st.session_state.card_dict
|
11 |
for key in key_list[:-1]:
|
12 |
current_dict = current_dict[key]
|
13 |
-
current_dict[card_key] = st.session_state.save_state
|
14 |
|
15 |
|
16 |
def make_multiselect(
|
@@ -27,13 +32,14 @@ def make_multiselect(
|
|
27 |
format_func=format_func,
|
28 |
key=key,
|
29 |
default=st.session_state.save_state.get(key, []),
|
|
|
30 |
help=help,
|
31 |
)
|
32 |
-
update_card_dict(key_list
|
33 |
return res
|
34 |
|
35 |
|
36 |
-
def make_selectbox(key_list, label, options, format_func=lambda x: x, help="", index=None
|
37 |
key = "_".join(key_list)
|
38 |
if key in st.session_state:
|
39 |
st.session_state.save_state[key] = st.session_state[key]
|
@@ -47,10 +53,10 @@ def make_selectbox(key_list, label, options, format_func=lambda x: x, help="", i
|
|
47 |
index=options.index(
|
48 |
st.session_state.save_state.get(key, options[0])
|
49 |
), # if st.session_state.save_state.get(key, options[0]) in options else 0,
|
|
|
50 |
help=help,
|
51 |
-
on_change=on_change,
|
52 |
)
|
53 |
-
update_card_dict(key_list,
|
54 |
return res
|
55 |
|
56 |
|
@@ -66,9 +72,10 @@ def make_radio(key_list, label, options, format_func=lambda x: x, help="", index
|
|
66 |
format_func=format_func,
|
67 |
key=key,
|
68 |
index=options.index(st.session_state.save_state.get(key, options[0])),
|
|
|
69 |
help=help,
|
70 |
)
|
71 |
-
update_card_dict(key_list)
|
72 |
return res
|
73 |
|
74 |
|
@@ -82,9 +89,10 @@ def make_text_input(key_list, label, help="", value=None):
|
|
82 |
label=label,
|
83 |
key=key,
|
84 |
value=st.session_state.save_state.get(key, ""),
|
|
|
85 |
help=help,
|
86 |
)
|
87 |
-
update_card_dict(key_list
|
88 |
return res
|
89 |
|
90 |
|
@@ -98,9 +106,10 @@ def make_text_area(key_list, label, help="", value=None):
|
|
98 |
label=label,
|
99 |
key=key,
|
100 |
value=st.session_state.save_state.get(key, ""),
|
|
|
101 |
help=help,
|
102 |
)
|
103 |
-
update_card_dict(key_list
|
104 |
return res
|
105 |
|
106 |
|
@@ -114,6 +123,7 @@ def make_checkbox(key_list, label, help="", value=None):
|
|
114 |
label=label,
|
115 |
key=key,
|
116 |
value=st.session_state.save_state.get(key, False),
|
|
|
117 |
help=help,
|
118 |
)
|
119 |
update_card_dict(key_list)
|
|
|
2 |
|
3 |
|
4 |
# Streamlit widgets with persistence
|
5 |
+
def is_filled(key_list):
|
6 |
+
state_filled_key = "_".join(key_list) + "_filled"
|
7 |
+
def on_change_action():
|
8 |
+
st.session_state.save_state[state_filled_key] = True
|
9 |
+
return on_change_action
|
10 |
+
|
11 |
+
def update_card_dict(key_list, use_default=None):
|
12 |
state_key = "_".join(key_list)
|
13 |
+
if st.session_state.save_state.get(state_key + "_filled", False) or use_default:
|
14 |
card_key = key_list[-1]
|
15 |
current_dict = st.session_state.card_dict
|
16 |
for key in key_list[:-1]:
|
17 |
current_dict = current_dict[key]
|
18 |
+
current_dict[card_key] = st.session_state.save_state.get(state_key, use_default)
|
19 |
|
20 |
|
21 |
def make_multiselect(
|
|
|
32 |
format_func=format_func,
|
33 |
key=key,
|
34 |
default=st.session_state.save_state.get(key, []),
|
35 |
+
on_change=is_filled(key_list),
|
36 |
help=help,
|
37 |
)
|
38 |
+
update_card_dict(key_list)
|
39 |
return res
|
40 |
|
41 |
|
42 |
+
def make_selectbox(key_list, label, options, format_func=lambda x: x, help="", index=None):
|
43 |
key = "_".join(key_list)
|
44 |
if key in st.session_state:
|
45 |
st.session_state.save_state[key] = st.session_state[key]
|
|
|
53 |
index=options.index(
|
54 |
st.session_state.save_state.get(key, options[0])
|
55 |
), # if st.session_state.save_state.get(key, options[0]) in options else 0,
|
56 |
+
on_change=is_filled(key_list),
|
57 |
help=help,
|
|
|
58 |
)
|
59 |
+
update_card_dict(key_list, use_default=st.session_state.save_state.get(key, options[0])) # use the default value even without interactions
|
60 |
return res
|
61 |
|
62 |
|
|
|
72 |
format_func=format_func,
|
73 |
key=key,
|
74 |
index=options.index(st.session_state.save_state.get(key, options[0])),
|
75 |
+
on_change=is_filled(key_list),
|
76 |
help=help,
|
77 |
)
|
78 |
+
update_card_dict(key_list, use_default=st.session_state.save_state.get(key, options[0])) # use the default value even without interactions
|
79 |
return res
|
80 |
|
81 |
|
|
|
89 |
label=label,
|
90 |
key=key,
|
91 |
value=st.session_state.save_state.get(key, ""),
|
92 |
+
on_change=is_filled(key_list),
|
93 |
help=help,
|
94 |
)
|
95 |
+
update_card_dict(key_list)
|
96 |
return res
|
97 |
|
98 |
|
|
|
106 |
label=label,
|
107 |
key=key,
|
108 |
value=st.session_state.save_state.get(key, ""),
|
109 |
+
on_change=is_filled(key_list),
|
110 |
help=help,
|
111 |
)
|
112 |
+
update_card_dict(key_list)
|
113 |
return res
|
114 |
|
115 |
|
|
|
123 |
label=label,
|
124 |
key=key,
|
125 |
value=st.session_state.save_state.get(key, False),
|
126 |
+
on_change=is_filled(key_list),
|
127 |
help=help,
|
128 |
)
|
129 |
update_card_dict(key_list)
|