Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update
Browse files- .gitignore +162 -0
- app.py +28 -3
- papers.py +32 -0
- requirements.txt +2 -1
.gitignore
ADDED
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.ragatouille/
|
2 |
+
|
3 |
+
# Byte-compiled / optimized / DLL files
|
4 |
+
__pycache__/
|
5 |
+
*.py[cod]
|
6 |
+
*$py.class
|
7 |
+
|
8 |
+
# C extensions
|
9 |
+
*.so
|
10 |
+
|
11 |
+
# Distribution / packaging
|
12 |
+
.Python
|
13 |
+
build/
|
14 |
+
develop-eggs/
|
15 |
+
dist/
|
16 |
+
downloads/
|
17 |
+
eggs/
|
18 |
+
.eggs/
|
19 |
+
lib/
|
20 |
+
lib64/
|
21 |
+
parts/
|
22 |
+
sdist/
|
23 |
+
var/
|
24 |
+
wheels/
|
25 |
+
share/python-wheels/
|
26 |
+
*.egg-info/
|
27 |
+
.installed.cfg
|
28 |
+
*.egg
|
29 |
+
MANIFEST
|
30 |
+
|
31 |
+
# PyInstaller
|
32 |
+
# Usually these files are written by a python script from a template
|
33 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
34 |
+
*.manifest
|
35 |
+
*.spec
|
36 |
+
|
37 |
+
# Installer logs
|
38 |
+
pip-log.txt
|
39 |
+
pip-delete-this-directory.txt
|
40 |
+
|
41 |
+
# Unit test / coverage reports
|
42 |
+
htmlcov/
|
43 |
+
.tox/
|
44 |
+
.nox/
|
45 |
+
.coverage
|
46 |
+
.coverage.*
|
47 |
+
.cache
|
48 |
+
nosetests.xml
|
49 |
+
coverage.xml
|
50 |
+
*.cover
|
51 |
+
*.py,cover
|
52 |
+
.hypothesis/
|
53 |
+
.pytest_cache/
|
54 |
+
cover/
|
55 |
+
|
56 |
+
# Translations
|
57 |
+
*.mo
|
58 |
+
*.pot
|
59 |
+
|
60 |
+
# Django stuff:
|
61 |
+
*.log
|
62 |
+
local_settings.py
|
63 |
+
db.sqlite3
|
64 |
+
db.sqlite3-journal
|
65 |
+
|
66 |
+
# Flask stuff:
|
67 |
+
instance/
|
68 |
+
.webassets-cache
|
69 |
+
|
70 |
+
# Scrapy stuff:
|
71 |
+
.scrapy
|
72 |
+
|
73 |
+
# Sphinx documentation
|
74 |
+
docs/_build/
|
75 |
+
|
76 |
+
# PyBuilder
|
77 |
+
.pybuilder/
|
78 |
+
target/
|
79 |
+
|
80 |
+
# Jupyter Notebook
|
81 |
+
.ipynb_checkpoints
|
82 |
+
|
83 |
+
# IPython
|
84 |
+
profile_default/
|
85 |
+
ipython_config.py
|
86 |
+
|
87 |
+
# pyenv
|
88 |
+
# For a library or package, you might want to ignore these files since the code is
|
89 |
+
# intended to run in multiple environments; otherwise, check them in:
|
90 |
+
# .python-version
|
91 |
+
|
92 |
+
# pipenv
|
93 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
94 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
95 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
96 |
+
# install all needed dependencies.
|
97 |
+
#Pipfile.lock
|
98 |
+
|
99 |
+
# poetry
|
100 |
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
101 |
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
102 |
+
# commonly ignored for libraries.
|
103 |
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
104 |
+
#poetry.lock
|
105 |
+
|
106 |
+
# pdm
|
107 |
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
108 |
+
#pdm.lock
|
109 |
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
110 |
+
# in version control.
|
111 |
+
# https://pdm.fming.dev/#use-with-ide
|
112 |
+
.pdm.toml
|
113 |
+
|
114 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
115 |
+
__pypackages__/
|
116 |
+
|
117 |
+
# Celery stuff
|
118 |
+
celerybeat-schedule
|
119 |
+
celerybeat.pid
|
120 |
+
|
121 |
+
# SageMath parsed files
|
122 |
+
*.sage.py
|
123 |
+
|
124 |
+
# Environments
|
125 |
+
.env
|
126 |
+
.venv
|
127 |
+
env/
|
128 |
+
venv/
|
129 |
+
ENV/
|
130 |
+
env.bak/
|
131 |
+
venv.bak/
|
132 |
+
|
133 |
+
# Spyder project settings
|
134 |
+
.spyderproject
|
135 |
+
.spyproject
|
136 |
+
|
137 |
+
# Rope project settings
|
138 |
+
.ropeproject
|
139 |
+
|
140 |
+
# mkdocs documentation
|
141 |
+
/site
|
142 |
+
|
143 |
+
# mypy
|
144 |
+
.mypy_cache/
|
145 |
+
.dmypy.json
|
146 |
+
dmypy.json
|
147 |
+
|
148 |
+
# Pyre type checker
|
149 |
+
.pyre/
|
150 |
+
|
151 |
+
# pytype static type analyzer
|
152 |
+
.pytype/
|
153 |
+
|
154 |
+
# Cython debug symbols
|
155 |
+
cython_debug/
|
156 |
+
|
157 |
+
# PyCharm
|
158 |
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
159 |
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
160 |
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
161 |
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
162 |
+
#.idea/
|
app.py
CHANGED
@@ -8,6 +8,14 @@ from papers import PaperList, get_df
|
|
8 |
|
9 |
DESCRIPTION = "# [Daily Papers](https://huggingface.co/papers)"
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
paper_list = PaperList(get_df())
|
12 |
|
13 |
|
@@ -18,10 +26,25 @@ def update_num_papers(df: pd.DataFrame) -> str:
|
|
18 |
with gr.Blocks(css="style.css") as demo:
|
19 |
gr.Markdown(DESCRIPTION)
|
20 |
with gr.Group():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
with gr.Row():
|
22 |
start_date = Calendar(label="Start date", type="datetime", value="2023-05-05")
|
23 |
end_date = Calendar(label="End date", type="datetime")
|
24 |
-
search_title = gr.Textbox(label="Search title")
|
25 |
|
26 |
num_papers = gr.Textbox(label="Number of papers", value=update_num_papers(paper_list.df_raw), interactive=False)
|
27 |
df = gr.Dataframe(
|
@@ -35,10 +58,12 @@ with gr.Blocks(css="style.css") as demo:
|
|
35 |
wrap=True,
|
36 |
)
|
37 |
|
|
|
|
|
38 |
gr.on(
|
39 |
-
triggers=[start_date.change, end_date.change, search_title.submit],
|
40 |
fn=paper_list.search,
|
41 |
-
inputs=[start_date, end_date, search_title],
|
42 |
outputs=df,
|
43 |
api_name=False,
|
44 |
).then(
|
|
|
8 |
|
9 |
DESCRIPTION = "# [Daily Papers](https://huggingface.co/papers)"
|
10 |
|
11 |
+
FOOT_NOTE = """\
|
12 |
+
Related useful Spaces:
|
13 |
+
- [Semantic Scholar Paper Recommender](https://huggingface.co/spaces/librarian-bots/recommend_similar_papers) by [davanstrien](https://huggingface.co/davanstrien)
|
14 |
+
- [ArXiv CS RAG](https://huggingface.co/spaces/bishmoy/Arxiv-CS-RAG) by [bishmoy](https://huggingface.co/bishmoy)
|
15 |
+
- [Paper Q&A](https://huggingface.co/spaces/chansung/paper_qa) by [chansung](https://huggingface.co/chansung)
|
16 |
+
"""
|
17 |
+
|
18 |
+
|
19 |
paper_list = PaperList(get_df())
|
20 |
|
21 |
|
|
|
26 |
with gr.Blocks(css="style.css") as demo:
|
27 |
gr.Markdown(DESCRIPTION)
|
28 |
with gr.Group():
|
29 |
+
search_title = gr.Textbox(label="Search title")
|
30 |
+
with gr.Row():
|
31 |
+
with gr.Column(scale=4):
|
32 |
+
search_abstract = gr.Textbox(
|
33 |
+
label="Search abstract",
|
34 |
+
info="The result may not be accurate as the abstract does not contain all the information.",
|
35 |
+
)
|
36 |
+
with gr.Column(scale=1):
|
37 |
+
max_num_to_retrieve = gr.Slider(
|
38 |
+
label="Max number to retrieve",
|
39 |
+
info="This is used only for search on abstracts.",
|
40 |
+
minimum=1,
|
41 |
+
maximum=len(paper_list.df_raw),
|
42 |
+
step=1,
|
43 |
+
value=100,
|
44 |
+
)
|
45 |
with gr.Row():
|
46 |
start_date = Calendar(label="Start date", type="datetime", value="2023-05-05")
|
47 |
end_date = Calendar(label="End date", type="datetime")
|
|
|
48 |
|
49 |
num_papers = gr.Textbox(label="Number of papers", value=update_num_papers(paper_list.df_raw), interactive=False)
|
50 |
df = gr.Dataframe(
|
|
|
58 |
wrap=True,
|
59 |
)
|
60 |
|
61 |
+
gr.Markdown(FOOT_NOTE)
|
62 |
+
|
63 |
gr.on(
|
64 |
+
triggers=[start_date.change, end_date.change, search_title.submit, search_abstract.submit],
|
65 |
fn=paper_list.search,
|
66 |
+
inputs=[start_date, end_date, search_title, search_abstract, max_num_to_retrieve],
|
67 |
outputs=df,
|
68 |
api_name=False,
|
69 |
).then(
|
papers.py
CHANGED
@@ -5,6 +5,20 @@ import operator
|
|
5 |
import datasets
|
6 |
import pandas as pd
|
7 |
import tqdm.auto
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
|
10 |
@dataclasses.dataclass(frozen=True)
|
@@ -92,6 +106,8 @@ class PaperList:
|
|
92 |
start_date: datetime.datetime,
|
93 |
end_date: datetime.datetime,
|
94 |
title_search_query: str,
|
|
|
|
|
95 |
) -> pd.DataFrame:
|
96 |
df = self.df_raw.copy()
|
97 |
df["date"] = pd.to_datetime(df["date"])
|
@@ -103,5 +119,21 @@ class PaperList:
|
|
103 |
# Filter by title
|
104 |
df = df[df["title"].str.contains(title_search_query, case=False)]
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
df_prettified = self._prettifier(df).loc[:, self.column_names]
|
107 |
return df_prettified
|
|
|
5 |
import datasets
|
6 |
import pandas as pd
|
7 |
import tqdm.auto
|
8 |
+
from huggingface_hub import HfApi
|
9 |
+
from ragatouille import RAGPretrainedModel
|
10 |
+
|
11 |
+
api = HfApi()
|
12 |
+
|
13 |
+
INDEX_DIR_PATH = ".ragatouille/colbert/indexes/daily-papers-abstract-index/"
|
14 |
+
api.snapshot_download(
|
15 |
+
repo_id="hysts-bot-data/daily-papers-abstract-index",
|
16 |
+
repo_type="dataset",
|
17 |
+
local_dir=INDEX_DIR_PATH,
|
18 |
+
)
|
19 |
+
ABSTRACT_RETRIEVER = RAGPretrainedModel.from_index(INDEX_DIR_PATH)
|
20 |
+
# Run once to initialize the retriever
|
21 |
+
ABSTRACT_RETRIEVER.search("LLM")
|
22 |
|
23 |
|
24 |
@dataclasses.dataclass(frozen=True)
|
|
|
106 |
start_date: datetime.datetime,
|
107 |
end_date: datetime.datetime,
|
108 |
title_search_query: str,
|
109 |
+
abstract_search_query: str,
|
110 |
+
max_num_to_retrieve: int,
|
111 |
) -> pd.DataFrame:
|
112 |
df = self.df_raw.copy()
|
113 |
df["date"] = pd.to_datetime(df["date"])
|
|
|
119 |
# Filter by title
|
120 |
df = df[df["title"].str.contains(title_search_query, case=False)]
|
121 |
|
122 |
+
# Filter by abstract
|
123 |
+
if abstract_search_query:
|
124 |
+
results = ABSTRACT_RETRIEVER.search(abstract_search_query, k=max_num_to_retrieve)
|
125 |
+
remaining_ids = set(df["arxiv_id"])
|
126 |
+
found_id_set = set()
|
127 |
+
found_ids = []
|
128 |
+
for x in results:
|
129 |
+
arxiv_id = x["document_id"]
|
130 |
+
if arxiv_id not in remaining_ids:
|
131 |
+
continue
|
132 |
+
if arxiv_id in found_id_set:
|
133 |
+
continue
|
134 |
+
found_id_set.add(arxiv_id)
|
135 |
+
found_ids.append(arxiv_id)
|
136 |
+
df = df[df["arxiv_id"].isin(found_ids)].set_index("arxiv_id").reindex(index=found_ids).reset_index()
|
137 |
+
|
138 |
df_prettified = self._prettifier(df).loc[:, self.column_names]
|
139 |
return df_prettified
|
requirements.txt
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
datasets==2.18.0
|
2 |
-
gradio==4.21.0
|
3 |
gradio_calendar==0.0.4
|
4 |
huggingface_hub==0.21.4
|
5 |
pandas==2.2.0
|
|
|
6 |
tqdm==4.66.2
|
|
|
1 |
datasets==2.18.0
|
2 |
+
#gradio==4.21.0
|
3 |
gradio_calendar==0.0.4
|
4 |
huggingface_hub==0.21.4
|
5 |
pandas==2.2.0
|
6 |
+
ragatouille==0.0.7.post10
|
7 |
tqdm==4.66.2
|