Spaces:
Runtime error
Runtime error
Commit ·
88f59a8
1
Parent(s): d46a072
Upload 9 files
Browse files- MRPC_test.pkl +3 -0
- MRPC_train.pkl +3 -0
- SNLI_test.pkl +3 -0
- SNLI_train.pkl +3 -0
- SQuAD_train.pkl +3 -0
- SQuAD_validation.pkl +3 -0
- app.py +39 -0
- requirements.txt +4 -0
- secretlanguage.py +87 -0
MRPC_test.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:38636677a6596547dbe8131aa61cd65d61024a9c23a95b232bc5ea328d674918
|
| 3 |
+
size 154775393
|
MRPC_train.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b8f8b408096781dbcefa7836c235e9c2d9e7f13ff0b07f2d9310bcd5ad78c1ae
|
| 3 |
+
size 346722948
|
SNLI_test.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b7b0c2310bfeed95103a18b2959d1a223871875e4ac3fba0738c8976dc96fb05
|
| 3 |
+
size 160523041
|
SNLI_train.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:02366a41fdd982208483bbd81393977cd0e6f29d0759205682cf0d853a560838
|
| 3 |
+
size 157516248
|
SQuAD_train.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4489bfc24f9520e74f343b9b78cd6c3aeba3886db3a42ddc06ad7fba6dea08ca
|
| 3 |
+
size 93601430
|
SQuAD_validation.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b8d5ef288a9e557329c9efca6c9d9b949d5914123a6c2277cc590ca06d2fd603
|
| 3 |
+
size 75141994
|
app.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""This files enables serving Panel apps on Hugging Face Spaces"""
|
| 2 |
+
import os
|
| 3 |
+
from subprocess import Popen
|
| 4 |
+
|
| 5 |
+
# CONFIGURE YOUR SETTINGS HERE
|
| 6 |
+
|
| 7 |
+
# Space separated list of .py or .ipynb files to serve
|
| 8 |
+
APPS_TO_SERVE = "secretlanguage.py"
|
| 9 |
+
# Prefix of the index .py or .ipynb file. Must be in APPS_TO_SERVE too
|
| 10 |
+
INDEX_PAGE = "secretlanguage"
|
| 11 |
+
|
| 12 |
+
# NORMALLY NO NEED TO CHANGE THE BELOW
|
| 13 |
+
PORT = os.environ.get("PORT", "7860")
|
| 14 |
+
ADDRESS = "0.0.0.0"
|
| 15 |
+
command = [
|
| 16 |
+
"panel",
|
| 17 |
+
"serve",
|
| 18 |
+
*APPS_TO_SERVE.split(" "),
|
| 19 |
+
"--index",
|
| 20 |
+
INDEX_PAGE,
|
| 21 |
+
"--port",
|
| 22 |
+
PORT,
|
| 23 |
+
"--address",
|
| 24 |
+
ADDRESS,
|
| 25 |
+
"--allow-websocket-origin",
|
| 26 |
+
"localhost",
|
| 27 |
+
"--allow-websocket-origin",
|
| 28 |
+
"*.hf.space",
|
| 29 |
+
"--allow-websocket-origin",
|
| 30 |
+
"*.huggingface.co",
|
| 31 |
+
# "--log-level",
|
| 32 |
+
# "debug"
|
| 33 |
+
]
|
| 34 |
+
if os.name != "nt":
|
| 35 |
+
command = command + ["--num-procs", "4", "--num-threads", "4"]
|
| 36 |
+
|
| 37 |
+
print(" ".join(command))
|
| 38 |
+
worker = Popen(command)
|
| 39 |
+
worker.wait()
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
param
|
| 2 |
+
pickle
|
| 3 |
+
pandas
|
| 4 |
+
panel
|
secretlanguage.py
ADDED
|
@@ -0,0 +1,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)
|