Spaces:
Runtime error
Runtime error
anonymousauthors
commited on
Commit
•
0647140
1
Parent(s):
c3d93bc
Upload secretlanguage.py
Browse filesUpdate to dict, interface updates later
- secretlanguage.py +100 -16
secretlanguage.py
CHANGED
@@ -1,3 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import param
|
2 |
import panel as pn
|
3 |
pn.extension(sizing_mode="stretch_width")
|
@@ -35,22 +123,19 @@ if (document.readyState === "complete") {
|
|
35 |
|
36 |
# html = autompg.to_html(classes=['example', 'panel-df'])
|
37 |
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
-
class ReactiveTables(param.Parameterized):
|
40 |
-
dataset = param.ObjectSelector(default='SNLI (DistillBERT)', objects=['SNLI (DistillBERT)', 'MRPC (ALBERT)', 'SQuAD (Roberta)'])
|
41 |
-
split = param.ObjectSelector(default='train', objects=['train', 'validation or test'])
|
42 |
-
start = param.Integer(1)
|
43 |
-
stop = param.Integer(200)
|
44 |
|
45 |
-
|
|
|
46 |
def data(self):
|
47 |
-
|
48 |
-
if self.split != 'train':
|
49 |
-
_path = _path.replace('validation or test', 'validation' if 'SQuAD' in self.dataset else 'test')
|
50 |
-
dataframe = pickle.load(open(_path, 'rb'))
|
51 |
-
return dataframe
|
52 |
|
53 |
-
@param.depends('
|
54 |
def summary(self):
|
55 |
return self.data().describe()
|
56 |
|
@@ -58,9 +143,9 @@ class ReactiveTables(param.Parameterized):
|
|
58 |
# def table(self):
|
59 |
# return self.data()[self.start:self.stop]
|
60 |
|
61 |
-
@param.depends('
|
62 |
def table_ours(self):
|
63 |
-
return pn.pane.HTML(self.data()
|
64 |
sizing_mode='stretch_width')
|
65 |
|
66 |
|
@@ -78,10 +163,9 @@ class ReactiveTables(param.Parameterized):
|
|
78 |
|
79 |
component = ReactiveTables().panel()
|
80 |
|
81 |
-
# dash =
|
82 |
pn.template.FastListTemplate(site="ACL 23 Submission", title="Finding Secret Language of Language Models",
|
83 |
main=[
|
84 |
"This page presents some secret languages discovered by our proposed SecretFinding algorithm on three multi-sentence datasets. To ensure optimal performance of this webapp, we recommend presenting less than 2000 data at a time.",
|
85 |
component
|
86 |
]).servable()
|
87 |
-
|
|
|
1 |
+
# import param
|
2 |
+
# import panel as pn
|
3 |
+
# pn.extension(sizing_mode="stretch_width")
|
4 |
+
# import pickle
|
5 |
+
# import pandas as pd
|
6 |
+
|
7 |
+
# css = ['https://cdn.datatables.net/1.10.24/css/jquery.dataTables.min.css',
|
8 |
+
# # Below: Needed for export buttons
|
9 |
+
# 'https://cdn.datatables.net/buttons/1.7.0/css/buttons.dataTables.min.css'
|
10 |
+
# ]
|
11 |
+
# js = {
|
12 |
+
# '$': 'https://code.jquery.com/jquery-3.5.1.js',
|
13 |
+
# 'DataTable': 'https://cdn.datatables.net/1.10.24/js/jquery.dataTables.min.js',
|
14 |
+
# # Below: Needed for export buttons
|
15 |
+
# 'buttons': 'https://cdn.datatables.net/buttons/1.7.0/js/dataTables.buttons.min.js',
|
16 |
+
# 'jszip': 'https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js',
|
17 |
+
# 'pdfmake': 'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js',
|
18 |
+
# 'vfsfonts': 'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js',
|
19 |
+
# 'html5buttons': 'https://cdn.datatables.net/buttons/1.7.0/js/buttons.html5.min.js',
|
20 |
+
# }
|
21 |
+
|
22 |
+
# pn.extension(css_files=css, js_files=js)
|
23 |
+
|
24 |
+
# script = """
|
25 |
+
# <script>
|
26 |
+
# if (document.readyState === "complete") {
|
27 |
+
# $('.example').DataTable();
|
28 |
+
# } else {
|
29 |
+
# $(document).ready(function () {
|
30 |
+
# $('.example').DataTable();
|
31 |
+
# })
|
32 |
+
# }
|
33 |
+
# </script>
|
34 |
+
# """
|
35 |
+
|
36 |
+
# # html = autompg.to_html(classes=['example', 'panel-df'])
|
37 |
+
|
38 |
+
|
39 |
+
# class ReactiveTables(param.Parameterized):
|
40 |
+
# dataset = param.ObjectSelector(default='SNLI (DistillBERT)', objects=['SNLI (DistillBERT)', 'MRPC (ALBERT)', 'SQuAD (Roberta)'])
|
41 |
+
# split = param.ObjectSelector(default='train', objects=['train', 'validation or test'])
|
42 |
+
# start = param.Integer(1)
|
43 |
+
# stop = param.Integer(200)
|
44 |
+
|
45 |
+
# @param.depends('dataset', 'split')
|
46 |
+
# def data(self):
|
47 |
+
# _path = f'{self.dataset.split(" ")[0]}_{self.split}.pkl'
|
48 |
+
# if self.split != 'train':
|
49 |
+
# _path = _path.replace('validation or test', 'validation' if 'SQuAD' in self.dataset else 'test')
|
50 |
+
# dataframe = pickle.load(open(_path, 'rb'))
|
51 |
+
# return dataframe
|
52 |
+
|
53 |
+
# @param.depends('dataset', 'split', 'data')
|
54 |
+
# def summary(self):
|
55 |
+
# return self.data().describe()
|
56 |
+
|
57 |
+
# # @param.depends('data', 'stop')
|
58 |
+
# # def table(self):
|
59 |
+
# # return self.data()[self.start:self.stop]
|
60 |
+
|
61 |
+
# @param.depends('dataset', 'split', 'start', 'stop')
|
62 |
+
# def table_ours(self):
|
63 |
+
# return pn.pane.HTML(self.data()[self.start:self.stop + 1].to_html(classes=['example', 'panel-df']) + script,
|
64 |
+
# sizing_mode='stretch_width')
|
65 |
+
|
66 |
+
|
67 |
+
# def panel(self):
|
68 |
+
# return pn.Row(
|
69 |
+
# pn.Param(self, name="Settings", width=300, sizing_mode="fixed"),
|
70 |
+
# pn.Column(
|
71 |
+
# "## Description", self.summary,
|
72 |
+
# "## Table", self.table_ours,
|
73 |
+
# width=2000,
|
74 |
+
# # sizing_mode='stretch_height'
|
75 |
+
# )
|
76 |
+
# , sizing_mode="stretch_width"
|
77 |
+
# )
|
78 |
+
|
79 |
+
# component = ReactiveTables().panel()
|
80 |
+
|
81 |
+
# # dash =
|
82 |
+
# pn.template.FastListTemplate(site="ACL 23 Submission", title="Finding Secret Language of Language Models",
|
83 |
+
# main=[
|
84 |
+
# "This page presents some secret languages discovered by our proposed SecretFinding algorithm on three multi-sentence datasets. To ensure optimal performance of this webapp, we recommend presenting less than 2000 data at a time.",
|
85 |
+
# component
|
86 |
+
# ]).servable()
|
87 |
+
# # pn.serve(dash)
|
88 |
+
|
89 |
import param
|
90 |
import panel as pn
|
91 |
pn.extension(sizing_mode="stretch_width")
|
|
|
123 |
|
124 |
# html = autompg.to_html(classes=['example', 'panel-df'])
|
125 |
|
126 |
+
import pandas as pd
|
127 |
+
|
128 |
+
class ReactiveTables(param.Parameterized):
|
129 |
+
datas = pickle.load(open('all_secret_language.pkl', 'rb'))
|
130 |
+
name_ = param.String('deliberately')
|
131 |
|
|
|
|
|
|
|
|
|
|
|
132 |
|
133 |
+
|
134 |
+
@param.depends('name_')
|
135 |
def data(self):
|
136 |
+
return pd.DataFrame(self.datas[self.name_])
|
|
|
|
|
|
|
|
|
137 |
|
138 |
+
@param.depends('name_')
|
139 |
def summary(self):
|
140 |
return self.data().describe()
|
141 |
|
|
|
143 |
# def table(self):
|
144 |
# return self.data()[self.start:self.stop]
|
145 |
|
146 |
+
@param.depends('name_')
|
147 |
def table_ours(self):
|
148 |
+
return pn.pane.HTML(self.data().to_html(classes=['example', 'panel-df']) + script,
|
149 |
sizing_mode='stretch_width')
|
150 |
|
151 |
|
|
|
163 |
|
164 |
component = ReactiveTables().panel()
|
165 |
|
|
|
166 |
pn.template.FastListTemplate(site="ACL 23 Submission", title="Finding Secret Language of Language Models",
|
167 |
main=[
|
168 |
"This page presents some secret languages discovered by our proposed SecretFinding algorithm on three multi-sentence datasets. To ensure optimal performance of this webapp, we recommend presenting less than 2000 data at a time.",
|
169 |
component
|
170 |
]).servable()
|
171 |
+
|