cakiki commited on
Commit
0b7159f
·
1 Parent(s): ec1fd1a

Upload with huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
.gitattributes CHANGED
@@ -1,34 +1,2 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tflite filter=lfs diff=lfs merge=lfs -text
29
- *.tgz filter=lfs diff=lfs merge=lfs -text
30
- *.wasm filter=lfs diff=lfs merge=lfs -text
31
- *.xz filter=lfs diff=lfs merge=lfs -text
32
- *.zip filter=lfs diff=lfs merge=lfs -text
33
- *.zst filter=lfs diff=lfs merge=lfs -text
34
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
1
+ index/**/* filter=lfs diff=lfs merge=lfs -text
2
+ data/data-00000-of-00001.arrow filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.md CHANGED
@@ -1,12 +1,13 @@
1
  ---
2
- title: Imdb Search Pagination
3
- emoji: 🔥
4
  colorFrom: blue
5
- colorTo: green
6
  sdk: gradio
7
- sdk_version: 3.18.0
8
  app_file: app.py
9
  pinned: false
 
10
  ---
11
 
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: IMDB search
3
+ emoji: 🐠
4
  colorFrom: blue
5
+ colorTo: blue
6
  sdk: gradio
7
+ sdk_version: 3.12.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-config-reference
app.py ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from datasets import load_from_disk
3
+ from pyserini.search.lucene import LuceneSearcher
4
+
5
+ searcher = LuceneSearcher("index")
6
+ ds = load_from_disk("data")
7
+ NUM_PAGES = 10 # STATIC. THIS CAN'T CHANGE BECAUSE GRADIO CAN'T DYNAMICALLY CREATE COMPONENTS.
8
+ RESULTS_PER_PAGE = 5
9
+
10
+ TEXT_FIELD = "text"
11
+ METADATA_FIELD = "docid"
12
+
13
+ def result_html(result, meta):
14
+ return (
15
+ f"<div style=\"color:#2a5cb3;font-weight: 500\"><u>{meta}</u></div><br>"
16
+ f"<div><details><summary>{result[:250]}...</summary><p>{result[250:]}</p></details></div><br><hr><br>"
17
+ )
18
+
19
+ def format_results(results):
20
+ return "\n".join([result_html(result, meta) for result,meta in zip(results[TEXT_FIELD], results[METADATA_FIELD])])
21
+
22
+ def page_0(query):
23
+ hits = searcher.search(query, k=NUM_PAGES*RESULTS_PER_PAGE)
24
+ ix = [int(hit.docid) for hit in hits]
25
+ results = ds.select(ix).shard(num_shards=NUM_PAGES, index=0, contiguous=True) # no need to shard. split ix in batches instead. (would make sense if results was cacheable)
26
+ results = format_results(results)
27
+ return results, [ix], gr.update(visible=True)
28
+
29
+ def page_i(i, ix):
30
+ ix = ix[0]
31
+ results = ds.select(ix).shard(num_shards=NUM_PAGES, index=i, contiguous=True)
32
+ results = format_results(results)
33
+ return results, [ix]
34
+
35
+ with gr.Blocks(css="#b {min-width:15px;background:transparent;border:white;box-shadow:none;}") as demo: #
36
+ with gr.Row():
37
+ gr.Markdown(value="""## <p style="text-align: center;"> IMDB search </p>""")
38
+ with gr.Row():
39
+ with gr.Column(scale=1):
40
+ result_list = gr.Dataframe(type="array", visible=False, col_count=1)
41
+ with gr.Column(scale=13):
42
+ query = gr.Textbox(lines=1, max_lines=1, placeholder="Search…", label="")
43
+ with gr.Column(scale=1):
44
+ with gr.Row(scale=1):
45
+ pass
46
+ with gr.Row(scale=1):
47
+ submit_btn = gr.Button("🔍", elem_id="b").style(full_width=False)
48
+ with gr.Row(scale=1):
49
+ pass
50
+
51
+ with gr.Row():
52
+ with gr.Column(scale=1):
53
+ pass
54
+ with gr.Column(scale=13):
55
+ c = gr.HTML(label="Results")
56
+ with gr.Row(visible=False) as pagination:
57
+ # left = gr.Button(value="◀", elem_id="b", visible=False).style(full_width=True)
58
+ page_1 = gr.Button(value="1", elem_id="b").style(full_width=True)
59
+ page_2 = gr.Button(value="2", elem_id="b").style(full_width=True)
60
+ page_3 = gr.Button(value="3", elem_id="b").style(full_width=True)
61
+ page_4 = gr.Button(value="4", elem_id="b").style(full_width=True)
62
+ page_5 = gr.Button(value="5", elem_id="b").style(full_width=True)
63
+ page_6 = gr.Button(value="6", elem_id="b").style(full_width=True)
64
+ page_7 = gr.Button(value="7", elem_id="b").style(full_width=True)
65
+ page_8 = gr.Button(value="8", elem_id="b").style(full_width=True)
66
+ page_9 = gr.Button(value="9", elem_id="b").style(full_width=True)
67
+ page_10 = gr.Button(value="10", elem_id="b").style(full_width=True)
68
+ # right = gr.Button(value="▶", elem_id="b", visible=False).style(full_width=True)
69
+ with gr.Column(scale=1):
70
+ pass
71
+ query.submit(fn=page_0, inputs=[query], outputs=[c, result_list, pagination])
72
+ submit_btn.click(page_0, inputs=[query], outputs=[c, result_list, pagination])
73
+ with gr.Box(visible=False):
74
+ nums = [gr.Number(i, visible=False, precision=0) for i in range(NUM_PAGES)]
75
+ page_1.click(fn=page_i, inputs=[nums[0], result_list], outputs=[c, result_list])
76
+ page_2.click(fn=page_i, inputs=[nums[1], result_list], outputs=[c, result_list])
77
+ page_3.click(fn=page_i, inputs=[nums[2], result_list], outputs=[c, result_list])
78
+ page_4.click(fn=page_i, inputs=[nums[3], result_list], outputs=[c, result_list])
79
+ page_5.click(fn=page_i, inputs=[nums[4], result_list], outputs=[c, result_list])
80
+ page_6.click(fn=page_i, inputs=[nums[5], result_list], outputs=[c, result_list])
81
+ page_7.click(fn=page_i, inputs=[nums[6], result_list], outputs=[c, result_list])
82
+ page_8.click(fn=page_i, inputs=[nums[7], result_list], outputs=[c, result_list])
83
+ page_9.click(fn=page_i, inputs=[nums[8], result_list], outputs=[c, result_list])
84
+ page_10.click(fn=page_i, inputs=[nums[9], result_list], outputs=[c, result_list])
85
+ demo.launch(enable_queue=True, debug=True)
data/.gitkeep ADDED
File without changes
data/data-00000-of-00001.arrow ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dbfaf51061c059feb91bd8f72f373869d655db66d82de94796c0b68ef8221921
3
+ size 33438680
data/dataset_info.json ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "builder_name": "imdb",
3
+ "citation": "@InProceedings{maas-EtAl:2011:ACL-HLT2011,\n author = {Maas, Andrew L. and Daly, Raymond E. and Pham, Peter T. and Huang, Dan and Ng, Andrew Y. and Potts, Christopher},\n title = {Learning Word Vectors for Sentiment Analysis},\n booktitle = {Proceedings of the 49th Annual Meeting of the Association for Computational Linguistics: Human Language Technologies},\n month = {June},\n year = {2011},\n address = {Portland, Oregon, USA},\n publisher = {Association for Computational Linguistics},\n pages = {142--150},\n url = {http://www.aclweb.org/anthology/P11-1015}\n}\n",
4
+ "config_name": "plain_text",
5
+ "dataset_size": 133190302,
6
+ "description": "Large Movie Review Dataset.\nThis is a dataset for binary sentiment classification containing substantially more data than previous benchmark datasets. We provide a set of 25,000 highly polar movie reviews for training, and 25,000 for testing. There is additional unlabeled data for use as well.",
7
+ "download_checksums": {
8
+ "http://ai.stanford.edu/~amaas/data/sentiment/aclImdb_v1.tar.gz": {
9
+ "num_bytes": 84125825,
10
+ "checksum": "c40f74a18d3b61f90feba1e17730e0d38e8b97c05fde7008942e91923d1658fe"
11
+ }
12
+ },
13
+ "download_size": 84125825,
14
+ "features": {
15
+ "text": {
16
+ "dtype": "string",
17
+ "_type": "Value"
18
+ },
19
+ "docid": {
20
+ "dtype": "int64",
21
+ "_type": "Value"
22
+ }
23
+ },
24
+ "homepage": "http://ai.stanford.edu/~amaas/data/sentiment/",
25
+ "license": "",
26
+ "size_in_bytes": 217316127,
27
+ "splits": {
28
+ "train": {
29
+ "name": "train",
30
+ "num_bytes": 33432823,
31
+ "num_examples": 25000,
32
+ "dataset_name": "imdb"
33
+ },
34
+ "test": {
35
+ "name": "test",
36
+ "num_bytes": 32650685,
37
+ "num_examples": 25000,
38
+ "dataset_name": "imdb"
39
+ },
40
+ "unsupervised": {
41
+ "name": "unsupervised",
42
+ "num_bytes": 67106794,
43
+ "num_examples": 50000,
44
+ "dataset_name": "imdb"
45
+ }
46
+ },
47
+ "task_templates": [],
48
+ "version": {
49
+ "version_str": "1.0.0",
50
+ "description": "",
51
+ "major": 1,
52
+ "minor": 0,
53
+ "patch": 0
54
+ }
55
+ }
data/state.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_data_files": [
3
+ {
4
+ "filename": "data-00000-of-00001.arrow"
5
+ }
6
+ ],
7
+ "_fingerprint": "1d74567875c58748",
8
+ "_format_columns": null,
9
+ "_format_kwargs": {},
10
+ "_format_type": null,
11
+ "_output_all_columns": false,
12
+ "_split": "train"
13
+ }
index/.gitkeep ADDED
File without changes
index/_0.fdm ADDED
Binary file (158 Bytes). View file
 
index/_0.fdt ADDED
Binary file (36.8 kB). View file
 
index/_0.fdx ADDED
Binary file (93 Bytes). View file
 
index/_0.fnm ADDED
Binary file (322 Bytes). View file
 
index/_0.nvd ADDED
Binary file (6.41 kB). View file
 
index/_0.nvm ADDED
Binary file (103 Bytes). View file
 
index/_0.si ADDED
Binary file (498 Bytes). View file
 
index/_0_Lucene90_0.doc ADDED
Binary file (951 kB). View file
 
index/_0_Lucene90_0.dvd ADDED
Binary file (38.7 kB). View file
 
index/_0_Lucene90_0.dvm ADDED
Binary file (171 Bytes). View file
 
index/_0_Lucene90_0.pos ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7dbe681b0efdc4898bbe577bbd385d79444e4292c27ee4e2969fd9cbcd353d14
3
+ size 1282325
index/_0_Lucene90_0.tim ADDED
Binary file (315 kB). View file
 
index/_0_Lucene90_0.tip ADDED
Binary file (8.64 kB). View file
 
index/_0_Lucene90_0.tmd ADDED
Binary file (257 Bytes). View file
 
index/_1.fdm ADDED
Binary file (158 Bytes). View file
 
index/_1.fdt ADDED
Binary file (36.7 kB). View file
 
index/_1.fdx ADDED
Binary file (93 Bytes). View file
 
index/_1.fnm ADDED
Binary file (322 Bytes). View file
 
index/_1.nvd ADDED
Binary file (6.43 kB). View file
 
index/_1.nvm ADDED
Binary file (103 Bytes). View file
 
index/_1.si ADDED
Binary file (498 Bytes). View file
 
index/_1_Lucene90_0.doc ADDED
Binary file (954 kB). View file
 
index/_1_Lucene90_0.dvd ADDED
Binary file (38.5 kB). View file
 
index/_1_Lucene90_0.dvm ADDED
Binary file (171 Bytes). View file
 
index/_1_Lucene90_0.pos ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dba719a2c87ca74bdc184de9bc594834e11a1c467d10f42c47466df685308ccb
3
+ size 1285669
index/_1_Lucene90_0.tim ADDED
Binary file (319 kB). View file
 
index/_1_Lucene90_0.tip ADDED
Binary file (8.6 kB). View file
 
index/_1_Lucene90_0.tmd ADDED
Binary file (260 Bytes). View file
 
index/_2.fdm ADDED
Binary file (158 Bytes). View file
 
index/_2.fdt ADDED
Binary file (35.6 kB). View file
 
index/_2.fdx ADDED
Binary file (78 Bytes). View file
 
index/_2.fnm ADDED
Binary file (322 Bytes). View file
 
index/_2.nvd ADDED
Binary file (6.16 kB). View file
 
index/_2.nvm ADDED
Binary file (103 Bytes). View file
 
index/_2.si ADDED
Binary file (498 Bytes). View file
 
index/_2_Lucene90_0.doc ADDED
Binary file (905 kB). View file
 
index/_2_Lucene90_0.dvd ADDED
Binary file (37 kB). View file
 
index/_2_Lucene90_0.dvm ADDED
Binary file (171 Bytes). View file
 
index/_2_Lucene90_0.pos ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d0e985ae3cba265a28c9e284ad3b8862d2611aa51b2447a14c9ad2053374fb47
3
+ size 1220422
index/_2_Lucene90_0.tim ADDED
Binary file (307 kB). View file
 
index/_2_Lucene90_0.tip ADDED
Binary file (8.26 kB). View file
 
index/_2_Lucene90_0.tmd ADDED
Binary file (260 Bytes). View file