-
Notifications
You must be signed in to change notification settings - Fork 3
/
app.py
779 lines (656 loc) · 29.1 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
# Some code here has been modified from:
# https://huggingface.co/spaces/huggingface/text-data-filtering
# --------------------------------------------------------
import copy
import math
import os
import sys
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import plotly.express as px
import streamlit as st
import yaml
from loguru import logger
from data_modori.analysis.diversity_analysis import (DiversityAnalysis,
get_diversity)
from data_modori.config import init_configs
from data_modori.core import Analyser, Executor
from data_modori.ops.base_op import OPERATORS
from data_modori.utils.constant import Fields, StatsKeys
from data_modori.utils.logger_utils import get_log_file_path
from data_modori.utils.model_utils import MODEL_ZOO, prepare_model
@st.cache_data
def convert_to_csv(df):
# IMPORTANT: Cache the conversion to prevent computation on every rerun
return df.to_csv().encode('utf_8_sig')
@st.cache_data
def convert_to_jsonl(df):
# IMPORTANT: Cache the conversion to prevent computation on every rerun
return df.to_json(orient='records', lines=True,
force_ascii=False).encode('utf_8_sig')
@st.cache_data
def get_diversity_model(lang):
if lang == 'ko':
model_key = prepare_model(lang, 'spacy_ko')
else:
model_key = prepare_model(lang, 'spacy')
diversity_model = MODEL_ZOO.get(model_key)
return diversity_model
@st.cache_data
def postproc_diversity(dataframe, **kwargs):
df = get_diversity(dataframe, **kwargs)
return df
def read_log_file():
log_f_path = get_log_file_path()
if log_f_path is None or not os.path.exists(log_f_path):
return ''
sys.stdout.flush()
with open(log_f_path, 'r') as f:
return f.read()
def pretty_out(d):
res = ''
process = ''
op_names = set(OPERATORS.modules.keys())
for key, value in d.items():
if key == 'process':
process = yaml.dump(value,
allow_unicode=True,
default_flow_style=False)
elif key == 'config' or key.split('.')[0] in op_names:
continue
else:
res += f'{key}:\n \t {value}\n'
res += 'process:\n' + \
'\n'.join(['\t' + line for line in process.splitlines()])
return res
def parse_cfg():
cfg_file = st.session_state.input_cfg_file
cfg_cmd = st.session_state.input_cfg_cmd
cfg_f_name = 'null'
del_cfg_file = False
if cfg_file is not None:
cfg_f_name = cfg_file.name
file_contents = cfg_file.getvalue()
with open(cfg_f_name, 'wb') as f:
f.write(file_contents)
cfg_cmd = f'--config {cfg_f_name}'
del_cfg_file = True
args_in_cmd = cfg_cmd.split()
if len(args_in_cmd) >= 2 and args_in_cmd[0] == '--config':
cfg_f_name = args_in_cmd[1]
else:
st.warning('Please specify a config command or upload a config file.')
st.stop()
if not os.path.exists(cfg_f_name):
st.warning('do not parse'
f'config file does not exist with cfg_f_name={cfg_f_name}')
st.stop()
with open(cfg_f_name, 'r') as cfg_f:
specified_cfg = yaml.safe_load(cfg_f)
try:
parsed_cfg = init_configs(args=args_in_cmd)
st.session_state.cfg = parsed_cfg
if isinstance(parsed_cfg.text_keys, list):
text_key = parsed_cfg.text_keys[0]
else:
text_key = parsed_cfg.text_keys
st.session_state.text_key = text_key
if del_cfg_file:
os.remove(cfg_f_name)
return pretty_out(parsed_cfg), pretty_out(specified_cfg), parsed_cfg
except Exception as e:
return str(e), pretty_out(specified_cfg), None
def analyze_and_show_res():
images_ori = []
cfg = st.session_state.get('cfg', parse_cfg()[2])
if cfg is None:
raise ValueError('you have not specify valid cfg')
# force generating separate figures
cfg['save_stats_in_one_file'] = True
logger.info('=========Stage 1: analyze original data=========')
analyzer = Analyser(cfg)
dataset = analyzer.run()
overall_file = os.path.join(analyzer.analysis_path, 'overall.csv')
analysis_res_ori = pd.DataFrame()
if os.path.exists(overall_file):
analysis_res_ori = pd.read_csv(overall_file)
if os.path.exists(analyzer.analysis_path):
for f_path in os.listdir(analyzer.analysis_path):
if '.png' in f_path and 'all-stats' in f_path:
images_ori.append(os.path.join(analyzer.analysis_path, f_path))
st.session_state.dataset = dataset
st.session_state.original_overall = analysis_res_ori
st.session_state.original_imgs = images_ori
def process_and_show_res():
images_processed = []
cfg = st.session_state.get('cfg', parse_cfg()[2])
if cfg is None:
raise ValueError('you have not specify valid cfg')
# force generating separate figures
cfg['save_stats_in_one_file'] = True
logger.info('=========Stage 2: process original data=========')
executor = Executor(cfg)
dataset = executor.run()
logger.info('=========Stage 3: analyze the processed data==========')
analysis_res_processed = pd.DataFrame()
try:
cfg_for_processed_data = copy.deepcopy(cfg)
cfg_for_processed_data.dataset_path = cfg.export_path
cfg_for_processed_data.export_path = os.path.dirname(
cfg.export_path) + '_processed/data.jsonl'
analyzer = Analyser(cfg_for_processed_data)
analyzer.analysis_path = os.path.dirname(
cfg_for_processed_data.export_path) + '/analysis'
analyzer.run()
overall_file = os.path.join(analyzer.analysis_path, 'overall.csv')
if os.path.exists(overall_file):
analysis_res_processed = pd.read_csv(overall_file)
if os.path.exists(analyzer.analysis_path):
for f_path in os.listdir(analyzer.analysis_path):
if '.png' in f_path and 'all-stats' in f_path:
images_processed.append(
os.path.join(analyzer.analysis_path, f_path))
except Exception as e:
st.warning(f'Something error with {str(e)}')
logger.info('=========Stage 4: Render the analysis results==========')
st.session_state.dataset = dataset
st.session_state.processed_overall = analysis_res_processed
st.session_state.processed_imgs = images_processed
def get_min_max_step(data):
max_value = np.max(data)
if max_value > 2.0:
min_value = 0
max_value = int(max_value + 1)
step = 1
else:
min_value = 0.0
max_value = max(1.0, max_value)
step = 0.01
return min_value, max_value, step
op_stats_dict = {
'alphanumeric_filter':
[StatsKeys.alpha_token_ratio, StatsKeys.alnum_ratio],
'average_line_length_filter': [StatsKeys.avg_line_length],
'character_repetition_filter': [StatsKeys.char_rep_ratio],
'flagged_words_filter': [StatsKeys.flagged_words_ratio],
'language_id_score_filter': [StatsKeys.lang, StatsKeys.lang_score],
'maximum_line_length_filter': [StatsKeys.max_line_length],
'perplexity_filter': [StatsKeys.perplexity],
'special_characters_filter': [StatsKeys.special_char_ratio],
'stopwords_filter': [StatsKeys.stopwords_ratio],
'text_length_filter': [StatsKeys.text_len],
'token_num_filter': [StatsKeys.num_token],
'words_num_filter': [StatsKeys.num_words],
'word_repetition_filter': [StatsKeys.word_rep_ratio],
}
class Visualize:
@staticmethod
def filter_dataset(dataset):
if Fields.stats not in dataset.features:
return
text_key = st.session_state.get('text_key', 'text')
text = dataset[text_key]
stats = pd.DataFrame(dataset[Fields.stats])
stats[text_key] = text
non_num_list = [StatsKeys.lang]
min_cutoff_list = [
StatsKeys.lang_score,
StatsKeys.stopwords_ratio,
]
max_cutoff_list = [
StatsKeys.flagged_words_ratio,
StatsKeys.perplexity,
]
mask_list = [text_key]
cfg = st.session_state.get('cfg', None)
if cfg is None:
return
def set_sliders(total_stats, ordered):
stats = copy.deepcopy(total_stats)
conds = list()
index = 1
for op_cfg in cfg.process:
op_name = list(op_cfg.keys())[0]
op_stats = op_stats_dict.get(op_name, [])
cutoff_ratio = None
with st.sidebar.expander(f'{index} {op_name}'):
for column_name in op_stats:
if column_name not in stats:
continue
data = stats[column_name]
if column_name in non_num_list:
options = ['all'] + list(set(data))
label = f'Which {column_name} would \
you like to keep?'
selected = st.selectbox(
label=label,
options=options,
)
if selected == 'all':
cond = [True] * len(data)
else:
cond = data == selected
Visualize.display_discarded_ratio(
cond, column_name)
elif column_name in min_cutoff_list:
label = f'If the {column_name} of a document \
is lower than this number, \
the document is removed.'
low, high, step = get_min_max_step(data)
cutoff_ratio = st.slider(label,
low,
high,
low,
step=step)
cond = data >= cutoff_ratio
Visualize.display_discarded_ratio(
cond, column_name)
elif column_name in max_cutoff_list:
label = f'If the {column_name} of a document \
is higher than this number, \
the document is removed.'
low, high, step = get_min_max_step(data)
cutoff_ratio = st.slider(label,
low,
high,
high,
step=step)
cond = data <= cutoff_ratio
Visualize.display_discarded_ratio(
cond, column_name)
elif column_name not in mask_list:
# lower
label = f'If the {column_name} of a document \
is lower than this number, \
the document is removed.'
low, high, step = get_min_max_step(data)
cutoff_ratio_l = st.slider(label,
low,
high,
low,
step=step)
cond_l = data >= cutoff_ratio_l
Visualize.display_discarded_ratio(
cond_l, column_name)
# higher
label = f'If the {column_name} of a document \
is higher than this number, \
the document is removed.'
cutoff_ratio_h = st.slider(label,
low,
high,
high,
step=step)
cond_h = data <= cutoff_ratio_h
Visualize.display_discarded_ratio(
cond_h, column_name)
cond = [
low & high
for low, high in zip(cond_l, cond_h)
]
cutoff_ratio = (cutoff_ratio_l, cutoff_ratio_h)
if column_name not in mask_list:
Visualize.draw_hist(data, cutoff_ratio)
conds.append({
(' '.join([str(index), op_name]), column_name):
cond
})
if ordered:
stats = stats.loc[cond]
index += 1
return conds, stats
st.sidebar.subheader('Parameters of filter ops')
ordered = st.sidebar.checkbox('Process by op order')
conds, filtered_stats = set_sliders(stats, ordered)
st.subheader('How many samples do you want to show?')
show_num = st.number_input(
label='How many samples do you want to show?',
value=5,
label_visibility='hidden')
if ordered:
all_conds = [
True if i in filtered_stats.index else False
for i in range(len(stats))
]
else:
all_conds = np.all([list(cond.values())[0] for cond in conds],
axis=0)
ds = pd.DataFrame(dataset)
Visualize.display_dataset(ds, all_conds, show_num, 'Retained sampels',
'docs')
st.download_button('Download Retained data as JSONL',
data=convert_to_jsonl(ds.loc[all_conds]),
file_name='retained.jsonl')
Visualize.display_dataset(ds, np.invert(all_conds), show_num,
'Discarded sampels', 'docs')
st.download_button('Download Discarded data as JSONL',
data=convert_to_jsonl(ds.loc[np.invert(all_conds)]),
file_name='discarded.jsonl')
display_discarded_details = st.checkbox(
'Display discarded documents by filter details')
show_stats = copy.deepcopy(stats)
bar_labels = []
bar_sizes = []
for item in conds:
for op_key, cond in item.items():
op_name, column_name = op_key
if column_name not in mask_list:
sub_stats = show_stats[[column_name, text_key]]
if display_discarded_details:
Visualize.display_dataset(
sub_stats,
np.invert(cond) if len(cond) > 0 else [],
show_num,
# f'Discarded documents for the filter on \
f'{op_name} {column_name} filtered ',
'docs',
)
before_filtered_num = len(show_stats.index)
if ordered:
show_stats = show_stats.loc[cond]
retained = np.sum(1 * cond)
filtered = before_filtered_num - len(show_stats.index)
else:
retained = np.sum(1 * cond)
filtered = before_filtered_num - retained
bar_sizes.append(retained)
bar_sizes.append(filtered)
bar_labels.append(f'{op_name}\n{column_name}')
bar_title = 'Effect of Filter OPs'
Visualize.draw_stack_bar(bar_sizes, bar_labels, len(stats.index),
bar_title)
@staticmethod
def diversity():
with st.expander('Diversity for CFT dataset', expanded=False):
dataset = st.session_state.get('dataset', None)
cfg = st.session_state.get('cfg', parse_cfg()[2])
text_key = st.session_state.get('text_key', 'text')
if dataset:
col1, col2, col3, col4 = st.columns(4)
with col1:
label = 'Which language of your dataset'
options = ['en', 'ko']
lang_select = st.selectbox(
label=label,
options=options,
)
with col2:
top_k_verbs = st.number_input(
'Set the top_k nums of verbs', value=20)
with col3:
top_k_nouns = st.number_input(
'Set the top_k nums of nouns', value=4)
with col4:
threshold = st.slider('Count threshold',
min_value=0,
value=0,
max_value=100,
step=1)
diversity_btn = st.button('Analyse_diversity',
use_container_width=True)
output_path = os.path.join(os.path.dirname(cfg.export_path),
'analysis')
raw_df = None
if diversity_btn:
try:
diversity_analysis = DiversityAnalysis(
dataset, output_path)
with st.spinner('Wait for analyze diversity...'):
raw_df = diversity_analysis.compute(
lang_or_model=get_diversity_model(lang_select),
column_name=text_key)
st.session_state[f'diversity{lang_select}'] = raw_df
except Exception as e:
st.warning(f'Error {str(e)} in {lang_select}')
else:
raw_df = st.session_state.get(f'diversity{lang_select}',
None)
if raw_df is not None:
df = postproc_diversity(raw_df,
top_k_verbs=top_k_verbs,
top_k_nouns=top_k_nouns)
df = df[df['count'] >= threshold]
Visualize.draw_sunburst(df,
path=['verb', 'noun'],
values='count')
st.download_button(
label='Download diversity data as CSV',
data=convert_to_csv(df),
file_name='diversity.csv',
mime='text/csv',
)
else:
st.warning('Please analyze original data first')
@staticmethod
def draw_sunburst(df, path, values):
fig = px.sunburst(df, path=path, values=values)
fig.update_layout(margin=dict(l=0, r=0, t=0, b=0),
font_family='Times New Roman',
font=dict(size=40))
st.plotly_chart(fig, use_container_width=True)
@staticmethod
def draw_stack_bar(bar_sizes, bar_labels, total_num, title=''):
filtered_size = [
k / total_num * 100 for i, k in enumerate(bar_sizes[::-1])
if i % 2 == 0
]
retain_size = [
k / total_num * 100 for i, k in enumerate(bar_sizes[::-1])
if i % 2 != 0
]
plt.clf()
plt.title(title)
bar_labels = bar_labels[::-1]
# retained
r_bars = plt.barh(bar_labels,
retain_size,
label='Retained',
height=0.5,
color='limegreen')
# filtered
f_bars = plt.barh(bar_labels,
filtered_size,
label='Filtered',
left=retain_size,
height=0.5,
color='orangered')
for idx, bar in enumerate(r_bars):
width = bar.get_width()
plt.text(bar.get_x() + width / 2,
bar.get_y() + bar.get_height() / 2,
f'{retain_size[idx]:.2f}%',
ha='center',
va='center')
for idx, bar in enumerate(f_bars):
width = bar.get_width()
plt.text(bar.get_x() + width / 2,
bar.get_y() + bar.get_height() / 2,
f'{filtered_size[idx]:.2f}%',
ha='center',
va='center')
plt.legend()
plt.gcf()
st.pyplot(plt, use_container_width=True)
@staticmethod
def draw_pie(bar_labels, big_sizes, small_labels, bar_sizes):
plt.clf()
# filter op circle
plt.pie(big_sizes, labels=bar_labels, startangle=90, frame=True)
# retained and filtered circle
plt.pie(bar_sizes,
labels=small_labels,
radius=0.7,
rotatelabels=True,
startangle=90,
labeldistance=0.7)
centre_circle = plt.Circle((0, 0), 0.4, color='white', linewidth=0)
fig = plt.gcf()
fig.gca().add_artist(centre_circle)
plt.axis('equal')
plt.tight_layout()
st.pyplot(plt, use_container_width=True)
@staticmethod
def display_discarded_ratio(cond, key):
if len(cond) > 0:
st.caption(
f':red[{(len(cond) - np.sum(1*cond)) / len(cond) * 100:.2f}%] \
of the total (:red[{len(cond)}]) is discarded with {key}.')
else:
st.caption(f':red[{0:.2f}%] \
of the total (:red[0]) is discarded with {key}.')
@staticmethod
def display_dataset(dataframe, cond, show_num, desp, type, all=True):
examples = dataframe.loc[cond]
if all or len(examples) > 0:
st.subheader(
f'{desp}: :red[{len(examples)}] of '
f'{len(dataframe.index)} {type} '
f'(:red[{len(examples)/len(dataframe.index) * 100:.2f}%])')
# st.markdown('Click on a column to sort by it, \
# place the cursor on the text to display it.')
st.dataframe(examples[:show_num], use_container_width=True)
@staticmethod
def draw_hist(data, cutoff=None):
fig, ax = plt.subplots()
data_num = len(data)
if data_num >= 100:
rec_bins = int(math.sqrt(len(data)))
else:
rec_bins = 50
if data_num > 0:
ax.hist(data, bins=rec_bins, density=True)
if hasattr(data, 'name'):
ax.set_title(data.name)
if isinstance(cutoff, (float, int)):
ax.axvline(x=cutoff, color='r', linestyle='dashed')
elif isinstance(cutoff, tuple) and len(cutoff) == 2:
ax.axvline(x=cutoff[0], color='r', linestyle='dashed')
ax.axvline(x=cutoff[1], color='r', linestyle='dashed')
st.pyplot(fig)
@staticmethod
def setup():
st.set_page_config(
page_title='Data-Modori',
page_icon='🐦',
layout='wide',
# initial_sidebar_state="expanded",
)
readme_link = 'https://github.com/teamreboott/data-modori'
st.markdown(
'<div align = "center"> <font size = "70"> Data-Modori 🐦 \
</font> </div>',
unsafe_allow_html=True,
)
st.markdown(
f'<div align = "center"> A Data Processing System for \
Large Language Models powered by TEAMREBOOTT Inc. [<a href={readme_link}>page</a>]</div>',
unsafe_allow_html=True,
)
@staticmethod
def parser():
with st.expander('Configuration', expanded=True):
st.markdown('Please specify the configuration via '
'(i) specifying the configuration file path with commands or '
'(ii) uploading the configuration file.')
col1, col2 = st.columns(2)
with col1:
example_cfg_f = os.path.abspath(
os.path.join(os.path.dirname(__file__),
'./configs/ko_process.yaml'))
st.text_area(label='💻 Input Config Commands',
key='input_cfg_cmd',
value=f'--config {example_cfg_f}')
example_my_cmd = '--dataset_path ' \
'./demos/data/demo-dataset.jsonl ' \
'--export_path '\
'./outputs/demo/demo-processed.jsonl'
with col2:
st.file_uploader(label='📁 Input Config File',
key='input_cfg_file',
type=['yaml'])
btn_show_cfg = st.button('1. Parse Cfg', use_container_width=True)
if btn_show_cfg:
text1, text2, cfg = parse_cfg()
st.session_state.cfg_text1 = text1
st.session_state.cfg_text2 = text2
else:
text1 = st.session_state.get('cfg_text1', '')
text2 = st.session_state.get('cfg_text2', '')
col3, col4 = st.columns(2)
with col3:
st.text_area(label='Parsed Cfg (in memory)', value=text1)
with col4:
st.text_area(label='Specified Cfg (in yaml file)', value=text2)
@staticmethod
def analyze_process():
start_btn = st.button(
'2. Start to analyze original data (per filter op)',
use_container_width=True)
start_btn_process = st.button('3. Start to process data',
use_container_width=True)
# with st.expander('Log', expanded=False):
# logs = st.Textbox(show_label=False)
# demo.load(read_log_file, inputs=None, outputs=logs, every=1)
with st.expander('Data Analysis Results', expanded=False):
if start_btn:
with st.spinner('Wait for analyze...'):
analyze_and_show_res()
if start_btn_process:
with st.spinner('Wait for process...'):
process_and_show_res()
original_overall = st.session_state.get('original_overall', None)
original_imgs = st.session_state.get('original_imgs', [])
processed_overall = st.session_state.get('processed_overall', None)
processed_imgs = st.session_state.get('processed_imgs', [])
col1, col2 = st.columns(2)
with col1:
st.caption('Original Data')
st.dataframe(original_overall, use_container_width=True)
for img in original_imgs:
st.image(img, output_format='png')
with col2:
st.caption('Processed Data')
st.dataframe(processed_overall, use_container_width=True)
for img in processed_imgs:
st.image(img, output_format='png')
@staticmethod
def filter():
with st.expander('Effect of Filter OPs', expanded=False):
dataset = st.session_state.get('dataset', None)
if dataset:
Visualize.filter_dataset(dataset)
else:
st.warning('Please analyze original data first')
@staticmethod
def auxiliary():
st.markdown('[WIP] Auxiliary Models on Processed Data')
col1, col2 = st.columns(2)
with col1:
with st.expander('Quality Scorer', expanded=False):
wiki_socre_btn = st.button('Run Wiki-score classifier',
use_container_width=True)
if wiki_socre_btn:
st.warning('No support for now')
wikibook_score_btn = st.button('Run WikiBook-score classifier',
use_container_width=True)
if wikibook_score_btn:
st.warning('No support for now')
with col2:
with st.expander('[WIP] Proxy LM Models Training', expanded=False):
st.file_uploader(label='LM Training Cfg File', type=['yaml'])
st.button('Train proxy model')
st.markdown('[Training Monitoring](http://'
'8.130.26.137:8083/dail/'
'llama-re-2nd?workspace=user-dail)')
@staticmethod
def visualize():
Visualize.setup()
Visualize.parser()
Visualize.analyze_process()
Visualize.filter()
Visualize.diversity()
def main():
Visualize.visualize()
if __name__ == '__main__':
main()