nazneen commited on
Commit
cb76d50
1 Parent(s): aec0591

error-analysis

Browse files
Files changed (5) hide show
  1. LICENSE +201 -0
  2. README.md +1 -13
  3. amazon_polarity.test.parquet +3 -0
  4. app.py +247 -0
  5. requirements.txt +313 -0
LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
README.md CHANGED
@@ -1,13 +1 @@
1
- ---
2
- title: Error Analysis
3
- emoji: 🔥
4
- colorFrom: green
5
- colorTo: red
6
- sdk: streamlit
7
- sdk_version: 1.2.0
8
- app_file: app.py
9
- pinned: false
10
- license: apache-2.0
11
- ---
12
-
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
 
1
+ # error-analysis
 
 
 
 
 
 
 
 
 
 
 
 
amazon_polarity.test.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1e57ae9ce39c5251e432b4a6dce31915782276b98a7751281eb66b8cff3b46b6
3
+ size 5864011
app.py ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### LIBRARIES ###
2
+ # # Data
3
+ from matplotlib.pyplot import legend
4
+ import numpy as np
5
+ import pandas as pd
6
+ import torch
7
+ import json
8
+ from tqdm import tqdm
9
+ from math import floor
10
+ from datasets import load_dataset
11
+ from collections import defaultdict
12
+ from transformers import AutoTokenizer
13
+
14
+ # Analysis
15
+ # from gensim.models.doc2vec import Doc2Vec
16
+ # from sklearn.metrics import accuracy_score, f1_score, precision_score, recall_score
17
+ # import nltk
18
+ # nltk.download('punkt') #make sure that punkt is downloaded
19
+
20
+ # App & Visualization
21
+ import streamlit as st
22
+ import st_aggrid
23
+ import altair as alt
24
+ import plotly.graph_objects as go
25
+ from streamlit_vega_lite import altair_component
26
+
27
+ # utils
28
+ from random import sample
29
+ # from PIL import Image
30
+
31
+
32
+ def down_samp(embedding):
33
+ """Down sample a data frame for altiar visualization """
34
+ # total number of positive and negative sentiments in the class
35
+ #embedding = embedding.groupby('slice').apply(lambda x: x.sample(frac=0.3))
36
+ total_size = embedding.groupby(['slice','label'], as_index=False).count()
37
+
38
+ user_data = 0
39
+ # if 'Your Sentences' in str(total_size['slice']):
40
+ # tmp = embedding.groupby(['slice'], as_index=False).count()
41
+ # val = int(tmp[tmp['slice'] == "Your Sentences"]['source'])
42
+ # user_data = val
43
+
44
+ max_sample = total_size.groupby('slice').max()['content']
45
+
46
+ # # down sample to meeting altair's max values
47
+ # # but keep the proportional representation of groups
48
+ down_samp = 1/(sum(max_sample.astype(float))/(1000-user_data))
49
+
50
+ max_samp = max_sample.apply(lambda x: floor(x*down_samp)).astype(int).to_dict()
51
+ max_samp['Your Sentences'] = user_data
52
+
53
+ # # sample down for each group in the data frame
54
+ embedding = embedding.groupby('slice').apply(lambda x: x.sample(n=max_samp.get(x.name))).reset_index(drop=True)
55
+
56
+ # # order the embedding
57
+ return(embedding)
58
+
59
+
60
+ def data_comparison(df):
61
+ # set up a dropdown select bindinf
62
+ # input_dropdown = alt.binding_select(options=['Negative Sentiment','Positive Sentiment'])
63
+ selection = alt.selection_multi(fields=['slice','label'])
64
+ color = alt.condition(alt.datum.slice == 'high-loss', alt.value("orange"), alt.value("steelblue"))
65
+ # color = alt.condition(selection,
66
+ # alt.Color('slice:Q', legend=None),
67
+ # # scale = alt.Scale(domain = pop_domain,range=color_range)),
68
+ # alt.value('lightgray'))
69
+ opacity = alt.condition(selection, alt.value(0.7), alt.value(0.25))
70
+
71
+ # basic chart
72
+ scatter = alt.Chart(df).mark_point(size=100, filled=True).encode(
73
+ x=alt.X('x', axis=None),
74
+ y=alt.Y('y', axis=None),
75
+ color=color,
76
+ shape=alt.Shape('label', scale=alt.Scale(range=['circle', 'diamond'])),
77
+ tooltip=['slice','content','label','pred'],
78
+ opacity=opacity
79
+ ).properties(
80
+ width=1500,
81
+ height=1000
82
+ ).interactive()
83
+
84
+ legend = alt.Chart(df).mark_point().encode(
85
+ y=alt.Y('slice:N', axis=alt.Axis(orient='right'), title=""),
86
+ x=alt.X("label"),
87
+ shape=alt.Shape('label', scale=alt.Scale(
88
+ range=['circle', 'diamond']), legend=None),
89
+ color=color
90
+ ).add_selection(
91
+ selection
92
+ )
93
+
94
+ layered = scatter |legend
95
+
96
+ layered = layered.configure_axis(
97
+ grid=False
98
+ ).configure_view(
99
+ strokeOpacity=0
100
+ )
101
+
102
+ return layered
103
+
104
+
105
+ def quant_panel(embedding_df):
106
+ """ Quantitative Panel Layout"""
107
+
108
+ all_metrics = {}
109
+ # st.warning("**Data Comparison**")
110
+
111
+ # with st.expander("how to read this chart:"):
112
+ # st.markdown("* each **point** is a single sentence")
113
+ # st.markdown("* the **position** of each dot is determined mathematically based upon an analysis of the words in a sentence. The **closer** two points on the visualization the **more similar** the sentences are. The **further apart ** two points on the visualization the **more different** the sentences are")
114
+ # st.markdown(
115
+ # " * the **shape** of each point reflects whether it a positive (diamond) or negative sentiment (circle)")
116
+ # st.markdown("* the **color** of each point is the ")
117
+ st.altair_chart(data_comparison(down_samp(embedding_df)))
118
+
119
+ def frequent_tokens(data, tokenizer, loss_quantile=0.95, top_k=200, smoothing=0.005):
120
+ unique_tokens = []
121
+ tokens = []
122
+ for row in tqdm(data['content']):
123
+ tokenized = tokenizer(row,padding=True, return_tensors='pt')
124
+ tokens.append(tokenized['input_ids'].flatten())
125
+ unique_tokens.append(torch.unique(tokenized['input_ids']))
126
+ losses = data['loss'].astype(float)
127
+ high_loss = losses.quantile(loss_quantile)
128
+ loss_weights = (losses > high_loss)
129
+ loss_weights = loss_weights / loss_weights.sum()
130
+ token_frequencies = defaultdict(float)
131
+ token_frequencies_error = defaultdict(float)
132
+
133
+ weights_uniform = np.full_like(loss_weights, 1 / len(loss_weights))
134
+
135
+ num_examples = len(data)
136
+ for i in tqdm(range(num_examples)):
137
+ for token in unique_tokens[i]:
138
+ token_frequencies[token.item()] += weights_uniform[i]
139
+ token_frequencies_error[token.item()] += loss_weights[i]
140
+
141
+ token_lrs = {k: (smoothing+token_frequencies_error[k]) / (smoothing+token_frequencies[k]) for k in token_frequencies}
142
+ tokens_sorted = list(map(lambda x: x[0], sorted(token_lrs.items(), key=lambda x: x[1])[::-1]))
143
+
144
+ top_tokens = []
145
+ for i, (token) in enumerate(tokens_sorted[:top_k]):
146
+ top_tokens.append(['%10s' % (tokenizer.decode(token)), '%.4f' % (token_frequencies[token]), '%.4f' % (
147
+ token_frequencies_error[token]), '%4.2f' % (token_lrs[token])])
148
+ return pd.DataFrame(top_tokens, columns=['Token', 'Freq', 'Freq error slice', 'lrs'])
149
+
150
+
151
+ @st.cache(ttl=600)
152
+ def get_data(spotlight, emb):
153
+ preds = spotlight.outputs.numpy()
154
+ losses = spotlight.losses.numpy()
155
+ embeddings = pd.DataFrame(emb, columns=['x', 'y'])
156
+ num_examples = len(losses)
157
+ # dataset_labels = [dataset[i]['label'] for i in range(num_examples)]
158
+ return pd.concat([pd.DataFrame(np.transpose(np.vstack([dataset[:num_examples]['content'],
159
+ dataset[:num_examples]['label'], preds, losses])), columns=['content', 'label', 'pred', 'loss']), embeddings], axis=1)
160
+
161
+
162
+ def topic_distribution(weights, smoothing=0.01):
163
+ topic_frequencies = defaultdict(float)
164
+ topic_frequencies_spotlight = defaultdict(float)
165
+ weights_uniform = np.full_like(weights, 1 / len(weights))
166
+ num_examples = len(weights)
167
+ for i in range(num_examples):
168
+ example = dataset[i]
169
+ category = example['title']
170
+ topic_frequencies[category] += weights_uniform[i]
171
+ topic_frequencies_spotlight[category] += weights[i]
172
+
173
+ topic_ratios = {c: (smoothing + topic_frequencies_spotlight[c]) / (
174
+ smoothing + topic_frequencies[c]) for c in topic_frequencies}
175
+
176
+ categories_sorted = map(lambda x: x[0], sorted(
177
+ topic_ratios.items(), key=lambda x: x[1], reverse=True))
178
+
179
+ topic_distr = []
180
+ for category in categories_sorted:
181
+ topic_distr.append(['%.3f' % topic_frequencies[category], '%.3f' %
182
+ topic_frequencies_spotlight[category], '%.2f' % topic_ratios[category], '%s' % category])
183
+
184
+ return pd.DataFrame(topic_distr, columns=['Overall frequency', 'Error frequency', 'Ratio', 'Category'])
185
+ # for category in categories_sorted:
186
+ # return(topic_frequencies[category], topic_frequencies_spotlight[category], topic_ratios[category], category)
187
+
188
+
189
+ if __name__ == "__main__":
190
+ ### STREAMLIT APP CONGFIG ###
191
+ st.set_page_config(layout="wide", page_title="Error Slice Analysis")
192
+ lcol, rcol = st.columns([3, 2])
193
+ # ******* loading the mode and the data
194
+ dataset = st.sidebar.selectbox(
195
+ "Dataset",
196
+ ["amazon_polarity", "squad", "movielens", "waterbirds"],
197
+ index=0
198
+ )
199
+
200
+ tokenizer = AutoTokenizer.from_pretrained(
201
+ "distilbert-base-uncased-finetuned-sst-2-english")
202
+
203
+ model = st.sidebar.selectbox(
204
+ "Model",
205
+ ["distilbert-base-uncased-finetuned-sst-2-english",
206
+ "distilbert-base-uncased-finetuned-sst-2-english"],
207
+ index=0
208
+ )
209
+
210
+ loss_quantile = st.sidebar.selectbox(
211
+ "Loss Quantile",
212
+ [0.98, 0.95, 0.9, 0.8, 0.75],
213
+ index = 1
214
+ )
215
+ ### LOAD DATA AND SESSION VARIABLES ###
216
+ data_df = pd.read_parquet('amazon_polarity.test.parquet')
217
+ embedding_umap = data_df[['x','y']]
218
+ if "user_data" not in st.session_state:
219
+ st.session_state["user_data"] = data_df
220
+ if "selected_slice" not in st.session_state:
221
+ st.session_state["selected_slice"] = None
222
+ if "embedding" not in st.session_state:
223
+ st.session_state["embedding"] = embedding_umap
224
+
225
+ with lcol:
226
+ st.title('Error Slices')
227
+ dataframe = data_df[['content', 'label', 'pred', 'loss']].sort_values(
228
+ by=['loss'], ascending=False)
229
+ table_html = dataframe.to_html(
230
+ columns=['content', 'label', 'pred', 'loss'], max_rows=100)
231
+ # table_html = table_html.replace("<th>", '<th align="left">') # left-align the headers
232
+ st.write(dataframe)
233
+ # st_aggrid.AgGrid(dataframe)
234
+ # table_html = dataframe.to_html(columns=['content', 'label', 'pred', 'loss'], max_rows=100)
235
+ # table_html = table_html.replace("<th>", '<th align="left">') # left-align the headers
236
+ # st.write(table_html)
237
+
238
+ with rcol:
239
+ st.title('Word Distribution in Error Slice')
240
+ commontokens = frequent_tokens(data_df, tokenizer, loss_quantile=loss_quantile)
241
+ st.write(commontokens)
242
+ data_df['loss'] = data_df['loss'].astype(float)
243
+ losses = data_df['loss']
244
+ high_loss = losses.quantile(loss_quantile)
245
+ data_df['slice'] = 'high-loss'
246
+ data_df['slice'] = data_df['slice'].where(data_df['loss'] > high_loss, 'low-loss')
247
+ quant_panel(data_df)
requirements.txt ADDED
@@ -0,0 +1,313 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file may be used to create an environment using:
2
+ # $ conda create --name <env> --file <this file>
3
+ # platform: osx-arm64
4
+ abseil-cpp=20210324.2=hbdafb3b_0
5
+ aiohttp=3.8.1=py39hb18efdd_1
6
+ aiosignal=1.2.0=pyhd8ed1ab_0
7
+ altair=4.2.0=pyhd8ed1ab_1
8
+ appnope=0.1.3=pyhd8ed1ab_0
9
+ argh=0.26.2=pyh9f0ad1d_1002
10
+ argon2-cffi=21.3.0=pyhd8ed1ab_0
11
+ argon2-cffi-bindings=21.2.0=py39h5161555_1
12
+ arrow-cpp=6.0.1=py39h71c7f51_5_cpu
13
+ astor=0.8.1=pyh9f0ad1d_0
14
+ asttokens=2.0.5=pyhd8ed1ab_0
15
+ async-timeout=4.0.2=pyhd8ed1ab_0
16
+ attrs=21.4.0=pyhd8ed1ab_0
17
+ autopep8=1.6.0=pyhd3eb1b0_0
18
+ aws-c-auth=0.6.8=h77ca94e_1
19
+ aws-c-cal=0.5.12=hc1327b6_7
20
+ aws-c-common=0.6.17=h3422bc3_0
21
+ aws-c-compression=0.2.14=haaffe3e_7
22
+ aws-c-event-stream=0.2.7=hd0ff547_32
23
+ aws-c-http=0.6.10=h53b0524_3
24
+ aws-c-io=0.10.14=h3e85fa9_1
25
+ aws-c-mqtt=0.7.10=hd8b1cef_0
26
+ aws-c-s3=0.1.29=h6db2689_0
27
+ aws-c-sdkutils=0.1.1=haaffe3e_4
28
+ aws-checksums=0.1.12=haaffe3e_6
29
+ aws-crt-cpp=0.17.10=h5d9c0f4_5
30
+ aws-sdk-cpp=1.9.160=he5b1d48_0
31
+ backcall=0.2.0=pyh9f0ad1d_0
32
+ backports=1.0=py_2
33
+ backports.functools_lru_cache=1.6.4=pyhd8ed1ab_0
34
+ base58=2.1.1=pyhd8ed1ab_0
35
+ beautifulsoup4=4.10.0=pyha770c72_0
36
+ blas=2.114=openblas
37
+ blas-devel=3.9.0=14_osxarm64_openblas
38
+ bleach=4.1.0=pyhd8ed1ab_0
39
+ blinker=1.4=pypi_0
40
+ blosc=1.21.0=h9f76cd9_0
41
+ bokeh=2.4.2=py39hca03da5_0
42
+ boto3=1.22.0=pyhd8ed1ab_0
43
+ botocore=1.25.0=pyhd8ed1ab_0
44
+ bottleneck=1.3.4=py39heec5a64_0
45
+ brotli=1.0.7=hc377ac9_0
46
+ brotlipy=0.7.0=py39hb18efdd_1004
47
+ brunsli=0.1=hc377ac9_1
48
+ bzip2=1.0.8=h3422bc3_4
49
+ c-ares=1.18.1=h3422bc3_0
50
+ c-blosc2=2.0.4=h0095615_1
51
+ ca-certificates=2021.10.8=h4653dfc_0
52
+ cachetools=5.0.0=pyhd8ed1ab_0
53
+ certifi=2021.10.8=py39h2804cbe_2
54
+ cffi=1.15.0=py39h52b1de0_0
55
+ cfitsio=4.0.0=h99351b2_0
56
+ charls=2.2.0=hc377ac9_0
57
+ charset-normalizer=2.0.12=pyhd8ed1ab_0
58
+ click=8.0.4=py39h2804cbe_0
59
+ cloudpickle=2.0.0=pyhd3eb1b0_0
60
+ colorama=0.4.4=pyh9f0ad1d_0
61
+ colorcet=2.0.6=pyhd3eb1b0_0
62
+ cryptography=36.0.2=py39hbe5e4b8_1
63
+ cycler=0.11.0=pyhd3eb1b0_0
64
+ cytoolz=0.11.0=py39h1a28f6b_0
65
+ dask=2022.2.1=pyhd3eb1b0_0
66
+ dask-core=2022.2.1=pyhd3eb1b0_0
67
+ dataclasses=0.8=pyhc8e2a94_3
68
+ datasets=2.0.0=py_0
69
+ datashader=0.13.0=pyhd3eb1b0_1
70
+ datashape=0.5.4=py39hca03da5_1
71
+ debugpy=1.5.1=py39hfb83b0d_0
72
+ decorator=5.1.1=pyhd8ed1ab_0
73
+ defusedxml=0.7.1=pyhd8ed1ab_0
74
+ dill=0.3.4=pyhd8ed1ab_0
75
+ distributed=2022.2.1=pyhd3eb1b0_0
76
+ entrypoints=0.4=pyhd8ed1ab_0
77
+ executing=0.8.3=pyhd8ed1ab_0
78
+ filelock=3.6.0=pyhd8ed1ab_0
79
+ flit-core=3.7.1=pyhd8ed1ab_0
80
+ fonttools=4.31.2=pypi_0
81
+ freetype=2.11.0=h1192e45_0
82
+ frozenlist=1.3.0=py39hb18efdd_1
83
+ fsspec=2022.3.0=pyhd8ed1ab_0
84
+ future=0.18.2=py39hca03da5_1
85
+ fuzzywuzzy=0.18.0=pypi_0
86
+ gflags=2.2.2=hc88da5d_1004
87
+ gh=2.7.0=h75b854d_0
88
+ giflib=5.2.1=h1a28f6b_0
89
+ gitdb=4.0.9=pyhd8ed1ab_0
90
+ gitpython=3.1.27=pyhd8ed1ab_0
91
+ glog=0.5.0=h5c6a83d_0
92
+ grpc-cpp=1.42.0=hedfbb7c_1
93
+ heapdict=1.0.1=pyhd3eb1b0_0
94
+ holoviews=1.14.8=pyhd3eb1b0_0
95
+ htmlmin=0.1.12=pypi_0
96
+ huggingface_hub=0.5.1=py_0
97
+ idna=3.3=pyhd8ed1ab_0
98
+ imagecodecs=2021.11.20=py39hcb02aed_1
99
+ imagehash=4.2.1=pypi_0
100
+ imageio=2.9.0=pyhd3eb1b0_0
101
+ importlib-metadata=4.11.3=py39h2804cbe_1
102
+ importlib_metadata=4.11.3=hd8ed1ab_1
103
+ importlib_resources=5.6.0=pyhd8ed1ab_0
104
+ ipykernel=6.12.1=py39h32adebf_0
105
+ ipython=8.2.0=py39h2804cbe_0
106
+ ipython-genutils=0.2.0=pypi_0
107
+ ipython_genutils=0.2.0=py_1
108
+ ipywidgets=7.7.0=pyhd8ed1ab_0
109
+ jbig=2.1=h1a28f6b_0
110
+ jedi=0.18.1=py39h2804cbe_1
111
+ jinja2=3.1.1=pyhd8ed1ab_0
112
+ jmespath=1.0.0=pyhd8ed1ab_0
113
+ joblib=1.0.1=pypi_0
114
+ jpeg=9d=h1a28f6b_0
115
+ jsonschema=4.4.0=pyhd8ed1ab_0
116
+ jupyter=1.0.0=pypi_0
117
+ jupyter-console=6.4.3=pypi_0
118
+ jupyter_client=7.2.1=pyhd8ed1ab_0
119
+ jupyter_core=4.9.2=py39h2804cbe_0
120
+ jupyterlab_pygments=0.1.2=pyh9f0ad1d_0
121
+ jupyterlab_widgets=1.1.0=pyhd8ed1ab_0
122
+ jxrlib=1.1=h1a28f6b_2
123
+ kaleido=0.2.1=pypi_0
124
+ kiwisolver=1.4.2=pypi_0
125
+ krb5=1.19.3=hf9b2bbe_0
126
+ lcms2=2.12=hba8e193_0
127
+ lerc=3.0=hc377ac9_0
128
+ libaec=1.0.6=hbdafb3b_0
129
+ libblas=3.9.0=14_osxarm64_openblas
130
+ libbrotlicommon=1.0.9=h1c322ee_7
131
+ libbrotlidec=1.0.9=h1c322ee_7
132
+ libbrotlienc=1.0.9=h1c322ee_7
133
+ libcblas=3.9.0=14_osxarm64_openblas
134
+ libcurl=7.82.0=hb0e6552_0
135
+ libcxx=13.0.1=h6a5c8ee_0
136
+ libdeflate=1.8=h1a28f6b_5
137
+ libedit=3.1.20191231=hc8eb9b7_2
138
+ libev=4.33=h642e427_1
139
+ libevent=2.1.10=hbae9a57_4
140
+ libffi=3.4.2=h3422bc3_5
141
+ libgfortran=5.0.0.dev0=11_0_1_hf114ba7_23
142
+ libgfortran5=11.0.1.dev0=hf114ba7_23
143
+ liblapack=3.9.0=14_osxarm64_openblas
144
+ liblapacke=3.9.0=14_osxarm64_openblas
145
+ libllvm11=11.1.0=h93073aa_3
146
+ libnghttp2=1.47.0=he723fca_0
147
+ libopenblas=0.3.20=openmp_h2209c59_0
148
+ libpng=1.6.37=hb8d0fd4_0
149
+ libprotobuf=3.19.1=h98b2900_0
150
+ libsodium=1.0.18=h27ca646_1
151
+ libssh2=1.10.0=hb80f160_2
152
+ libthrift=0.15.0=h28a9c34_1
153
+ libtiff=4.3.0=h74060c4_2
154
+ libutf8proc=2.7.0=h3422bc3_0
155
+ libwebp=1.2.2=h68602c7_0
156
+ libwebp-base=1.2.2=h1a28f6b_0
157
+ libzlib=1.2.11=h90dfc92_1014
158
+ libzopfli=1.0.3=hc377ac9_0
159
+ llvm-openmp=13.0.1=h455960f_1
160
+ llvmlite=0.38.0=py39hd599773_1
161
+ locket=0.2.1=py39hca03da5_2
162
+ lz4-c=1.9.3=hbdafb3b_1
163
+ markdown=3.3.4=py39hca03da5_0
164
+ markupsafe=2.0.1=pypi_0
165
+ matplotlib=3.5.1=py39hca03da5_1
166
+ matplotlib-base=3.5.1=py39hc377ac9_1
167
+ matplotlib-inline=0.1.3=pyhd8ed1ab_0
168
+ missingno=0.5.1=pypi_0
169
+ mistune=0.8.4=py39h5161555_1005
170
+ msgpack-python=1.0.2=py39h525c30c_1
171
+ multidict=6.0.2=py39hb18efdd_1
172
+ multimethod=1.7=pypi_0
173
+ multipledispatch=0.6.0=py39hca03da5_0
174
+ multiprocess=0.70.12.2=py39hb18efdd_2
175
+ munkres=1.1.4=py_0
176
+ nbclient=0.5.13=pyhd8ed1ab_0
177
+ nbconvert=6.4.5=pyhd8ed1ab_2
178
+ nbconvert-core=6.4.5=pyhd8ed1ab_2
179
+ nbconvert-pandoc=6.4.5=pyhd8ed1ab_2
180
+ nbformat=5.3.0=pyhd8ed1ab_0
181
+ ncurses=6.3=hc470f4d_0
182
+ nest-asyncio=1.5.5=pyhd8ed1ab_0
183
+ networkx=2.7.1=pyhd3eb1b0_0
184
+ ninja=1.10.2=py39h525c30c_3
185
+ notebook=6.4.10=pyha770c72_0
186
+ numba=0.55.1=py39hb1c450a_0
187
+ numexpr=2.8.1=py39h144ceef_0
188
+ numpy=1.21.5=py39h25ab29e_1
189
+ numpy-base=1.21.5=py39h974a1f5_1
190
+ openblas=0.3.20=openmp_h745f6c2_0
191
+ openjpeg=2.4.0=h062765e_1
192
+ openssl=1.1.1n=h90dfc92_0
193
+ orc=1.7.1=hcb6706d_1
194
+ packaging=21.3=pyhd8ed1ab_0
195
+ pandas=1.4.1=py39hc377ac9_1
196
+ pandas-profiling=3.1.0=pypi_0
197
+ pandoc=2.12=hca03da5_0
198
+ pandocfilters=1.5.0=pyhd8ed1ab_0
199
+ panel=0.12.6=pyhd3eb1b0_0
200
+ param=1.12.0=pyhd3eb1b0_0
201
+ parquet-cpp=1.5.1=2
202
+ parso=0.8.3=pyhd8ed1ab_0
203
+ partd=1.2.0=pyhd3eb1b0_1
204
+ pexpect=4.8.0=pyh9f0ad1d_2
205
+ phik=0.12.2=pypi_0
206
+ pickleshare=0.7.5=py_1003
207
+ pillow=9.1.0=pypi_0
208
+ pip=22.0.4=pyhd8ed1ab_0
209
+ plotly=5.7.0=py_0
210
+ progressbar=2.5=pypi_0
211
+ prometheus_client=0.14.0=pyhd8ed1ab_0
212
+ prompt-toolkit=3.0.29=pyha770c72_0
213
+ protobuf=3.20.0=pypi_0
214
+ psutil=5.9.0=py39hb18efdd_1
215
+ ptyprocess=0.7.0=pyhd3deb0d_0
216
+ pure_eval=0.2.2=pyhd8ed1ab_0
217
+ pyahocorasick=1.4.4=pypi_0
218
+ pyarrow=6.0.1=py39hd3b58d7_5_cpu
219
+ pyasn1=0.4.8=pypi_0
220
+ pycodestyle=2.8.0=pyhd3eb1b0_0
221
+ pycparser=2.21=pyhd8ed1ab_0
222
+ pyct=0.4.6=py39hca03da5_0
223
+ pydantic=1.9.0=pypi_0
224
+ pydeck=0.7.1=pyh6c4a22f_0
225
+ pygments=2.11.2=pyhd8ed1ab_0
226
+ pympler=1.0.1=pypi_0
227
+ pynndescent=0.5.6=pyh6c4a22f_0
228
+ pyopenssl=22.0.0=pyhd8ed1ab_0
229
+ pyparsing=3.0.7=pyhd8ed1ab_0
230
+ pyrsistent=0.18.1=py39hb18efdd_1
231
+ pysocks=1.7.1=py39h2804cbe_5
232
+ python=3.9.12=hfc7342c_1_cpython
233
+ python-dateutil=2.8.2=pyhd8ed1ab_0
234
+ python-dotenv=0.19.2=pypi_0
235
+ python-fastjsonschema=2.15.3=pyhd8ed1ab_0
236
+ python-tzdata=2022.1=pyhd8ed1ab_0
237
+ python-xxhash=3.0.0=py39hb18efdd_0
238
+ python_abi=3.9=1_cp39
239
+ pytorch=1.10.2=cpu_py39h23cb94c_0
240
+ pytz=2022.1=pyhd8ed1ab_0
241
+ pytz-deprecation-shim=0.1.0.post0=py39h2804cbe_1
242
+ pyviz_comms=2.0.2=pyhd3eb1b0_0
243
+ pywavelets=1.3.0=py39h1a28f6b_0
244
+ pyyaml=6.0=py39hb18efdd_4
245
+ pyzmq=22.3.0=py39h7a4232c_2
246
+ qtconsole=5.3.0=pypi_0
247
+ qtpy=2.0.1=pypi_0
248
+ re2=2021.11.01=hbdafb3b_0
249
+ readline=8.1=hedafd6a_0
250
+ regex=2022.3.15=py39hb18efdd_1
251
+ requests=2.27.1=pyhd8ed1ab_0
252
+ s3transfer=0.5.2=pyhd8ed1ab_0
253
+ sacremoses=0.0.49=pyhd8ed1ab_0
254
+ scikit-image=0.19.2=py39h9197a36_0
255
+ scikit-learn=1.0.2=py39hef7049f_0
256
+ scipy=1.8.0=py39h5060c3b_1
257
+ seaborn=0.11.2=pypi_0
258
+ semver=2.13.0=pyh9f0ad1d_0
259
+ send2trash=1.8.0=pyhd8ed1ab_0
260
+ setuptools=62.0.0=py39h2804cbe_0
261
+ simplejson=3.17.6=pypi_0
262
+ six=1.16.0=pyh6c4a22f_0
263
+ smmap=5.0.0=pypi_0
264
+ snappy=1.1.8=hc88da5d_3
265
+ sortedcontainers=2.4.0=pyhd3eb1b0_0
266
+ soupsieve=2.3.2=pypi_0
267
+ sqlite=3.37.1=h7e3ccbd_0
268
+ stack_data=0.2.0=pyhd8ed1ab_0
269
+ streamlit=1.8.1=pyhd8ed1ab_0
270
+ streamlit-aggrid=0.2.3.post2=pypi_0
271
+ streamlit-vega-lite=0.1.0=pypi_0
272
+ tangled-up-in-unicode=0.1.0=pypi_0
273
+ tbb=2021.5.0=h3e96240_1
274
+ tblib=1.7.0=pyhd3eb1b0_0
275
+ tenacity=8.0.1=py39hca03da5_0
276
+ tensorboard-plugin-wit=1.8.1=pypi_0
277
+ terminado=0.13.3=py39h2804cbe_1
278
+ testpath=0.6.0=pyhd8ed1ab_0
279
+ threadpoolctl=3.1.0=pyh8a188c0_0
280
+ tifffile=2021.7.2=pyhd3eb1b0_2
281
+ tk=8.6.12=he1e0b03_0
282
+ tokenizers=0.11.6=pypi_0
283
+ toml=0.10.2=pyhd3eb1b0_0
284
+ toolz=0.11.2=pyhd8ed1ab_0
285
+ torchvision=0.2.2=py_3
286
+ tornado=6.1=py39hb18efdd_3
287
+ tqdm=4.64.0=pyhd8ed1ab_0
288
+ traitlets=5.1.1=pyhd8ed1ab_0
289
+ transformers=4.18.0=pypi_0
290
+ typing-extensions=4.1.1=hd8ed1ab_0
291
+ typing_extensions=4.1.1=pyha770c72_0
292
+ tzdata=2022a=h191b570_0
293
+ tzlocal=4.2=py39h2804cbe_0
294
+ umap-learn=0.5.3=py39h2804cbe_0
295
+ urllib3=1.26.9=pyhd8ed1ab_0
296
+ validators=0.18.2=pyhd3deb0d_0
297
+ visions=0.7.4=pypi_0
298
+ watchdog=2.1.7=py39hb18efdd_1
299
+ wcwidth=0.2.5=pyh9f0ad1d_2
300
+ webencodings=0.5.1=pypi_0
301
+ wheel=0.37.1=pyhd8ed1ab_0
302
+ widgetsnbextension=3.6.0=py39h2804cbe_0
303
+ xarray=0.20.1=pyhd3eb1b0_1
304
+ xxhash=0.8.0=h27ca646_3
305
+ xz=5.2.5=h642e427_1
306
+ yaml=0.2.5=h3422bc3_2
307
+ yarl=1.7.2=py39hb18efdd_2
308
+ zeromq=4.3.4=hbdafb3b_1
309
+ zfp=0.5.5=hc377ac9_6
310
+ zict=2.0.0=pyhd3eb1b0_0
311
+ zipp=3.8.0=pyhd8ed1ab_0
312
+ zlib=1.2.11=h90dfc92_1014
313
+ zstd=1.5.2=h861e0a7_0