Spaces:
Runtime error
Runtime error
First attempt
Browse files- .gitignore +355 -0
- app.py +55 -0
- flask_app.py +54 -0
- generators/model.py +52 -0
- generators/title_to_abstract.py +5 -0
- generators/topic_to_abstract.py +6 -0
- requirements.txt +98 -0
- templates/Templates.py +64 -0
.gitignore
ADDED
@@ -0,0 +1,355 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
**/.idea
|
2 |
+
**/*key.json
|
3 |
+
**/.env
|
4 |
+
**/.pytest_cache/
|
5 |
+
**/__pycache__/
|
6 |
+
**/.coverage
|
7 |
+
**/.DS_Store
|
8 |
+
**/*.log
|
9 |
+
**/*.egg-info/
|
10 |
+
|
11 |
+
### Emacs ###
|
12 |
+
# -*- mode: gitignore; -*-
|
13 |
+
*~
|
14 |
+
\#*\#
|
15 |
+
/.emacs.desktop
|
16 |
+
/.emacs.desktop.lock
|
17 |
+
*.elc
|
18 |
+
auto-save-list
|
19 |
+
tramp
|
20 |
+
.\#*
|
21 |
+
|
22 |
+
# Org-mode
|
23 |
+
.org-id-locations
|
24 |
+
*_archive
|
25 |
+
|
26 |
+
# flymake-mode
|
27 |
+
*_flymake.*
|
28 |
+
|
29 |
+
# eshell files
|
30 |
+
/eshell/history
|
31 |
+
/eshell/lastdir
|
32 |
+
|
33 |
+
# elpa packages
|
34 |
+
/elpa/
|
35 |
+
|
36 |
+
# reftex files
|
37 |
+
*.rel
|
38 |
+
|
39 |
+
# AUCTeX auto folder
|
40 |
+
/auto/
|
41 |
+
|
42 |
+
# cask packages
|
43 |
+
.cask/
|
44 |
+
dist/
|
45 |
+
|
46 |
+
# Flycheck
|
47 |
+
flycheck_*.el
|
48 |
+
|
49 |
+
# server auth directory
|
50 |
+
/server/
|
51 |
+
|
52 |
+
# projectiles files
|
53 |
+
.projectile
|
54 |
+
|
55 |
+
# directory configuration
|
56 |
+
.dir-locals.el
|
57 |
+
|
58 |
+
# network security
|
59 |
+
/network-security.data
|
60 |
+
|
61 |
+
|
62 |
+
### Go ###
|
63 |
+
# Binaries for programs and plugins
|
64 |
+
*.exe
|
65 |
+
*.exe~
|
66 |
+
*.dll
|
67 |
+
*.so
|
68 |
+
*.dylib
|
69 |
+
|
70 |
+
# Test binary, built with `go test -c`
|
71 |
+
*.test
|
72 |
+
|
73 |
+
# Output of the go coverage tool, specifically when used with LiteIDE
|
74 |
+
*.out
|
75 |
+
|
76 |
+
# Dependency directories (remove the comment below to include it)
|
77 |
+
# vendor/
|
78 |
+
|
79 |
+
### Go Patch ###
|
80 |
+
/vendor/
|
81 |
+
/Godeps/
|
82 |
+
|
83 |
+
### JupyterNotebooks ###
|
84 |
+
# gitignore template for Jupyter Notebooks
|
85 |
+
# website: http://jupyter.org/
|
86 |
+
|
87 |
+
.ipynb_checkpoints
|
88 |
+
*/.ipynb_checkpoints/*
|
89 |
+
|
90 |
+
# IPython
|
91 |
+
profile_default/
|
92 |
+
ipython_config.py
|
93 |
+
|
94 |
+
# Remove previous ipynb_checkpoints
|
95 |
+
# git rm -r .ipynb_checkpoints/
|
96 |
+
|
97 |
+
### PyCharm ###
|
98 |
+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
99 |
+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
100 |
+
|
101 |
+
# User-specific stuff
|
102 |
+
.idea/**/workspace.xml
|
103 |
+
.idea/**/tasks.xml
|
104 |
+
.idea/**/usage.statistics.xml
|
105 |
+
.idea/**/dictionaries
|
106 |
+
.idea/**/shelf
|
107 |
+
|
108 |
+
# AWS User-specific
|
109 |
+
.idea/**/aws.xml
|
110 |
+
|
111 |
+
# Generated files
|
112 |
+
.idea/**/contentModel.xml
|
113 |
+
|
114 |
+
# Sensitive or high-churn files
|
115 |
+
.idea/**/dataSources/
|
116 |
+
.idea/**/dataSources.ids
|
117 |
+
.idea/**/dataSources.local.xml
|
118 |
+
.idea/**/sqlDataSources.xml
|
119 |
+
.idea/**/dynamic.xml
|
120 |
+
.idea/**/uiDesigner.xml
|
121 |
+
.idea/**/dbnavigator.xml
|
122 |
+
|
123 |
+
# Gradle
|
124 |
+
.idea/**/gradle.xml
|
125 |
+
.idea/**/libraries
|
126 |
+
|
127 |
+
# Gradle and Maven with auto-import
|
128 |
+
# When using Gradle or Maven with auto-import, you should exclude module files,
|
129 |
+
# since they will be recreated, and may cause churn. Uncomment if using
|
130 |
+
# auto-import.
|
131 |
+
# .idea/artifacts
|
132 |
+
# .idea/compiler.xml
|
133 |
+
# .idea/jarRepositories.xml
|
134 |
+
# .idea/modules.xml
|
135 |
+
# .idea/*.iml
|
136 |
+
# .idea/modules
|
137 |
+
# *.iml
|
138 |
+
# *.ipr
|
139 |
+
|
140 |
+
# CMake
|
141 |
+
cmake-build-*/
|
142 |
+
|
143 |
+
# Mongo Explorer plugin
|
144 |
+
.idea/**/mongoSettings.xml
|
145 |
+
|
146 |
+
# File-based project format
|
147 |
+
*.iws
|
148 |
+
|
149 |
+
# IntelliJ
|
150 |
+
out/
|
151 |
+
|
152 |
+
# mpeltonen/sbt-idea plugin
|
153 |
+
.idea_modules/
|
154 |
+
|
155 |
+
# JIRA plugin
|
156 |
+
atlassian-ide-plugin.xml
|
157 |
+
|
158 |
+
# Cursive Clojure plugin
|
159 |
+
.idea/replstate.xml
|
160 |
+
|
161 |
+
# Crashlytics plugin (for Android Studio and IntelliJ)
|
162 |
+
com_crashlytics_export_strings.xml
|
163 |
+
crashlytics.properties
|
164 |
+
crashlytics-build.properties
|
165 |
+
fabric.properties
|
166 |
+
|
167 |
+
# Editor-based Rest Client
|
168 |
+
.idea/httpRequests
|
169 |
+
|
170 |
+
# Android studio 3.1+ serialized cache file
|
171 |
+
.idea/caches/build_file_checksums.ser
|
172 |
+
|
173 |
+
### PyCharm Patch ###
|
174 |
+
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
|
175 |
+
|
176 |
+
# *.iml
|
177 |
+
# modules.xml
|
178 |
+
# .idea/misc.xml
|
179 |
+
# *.ipr
|
180 |
+
|
181 |
+
# Sonarlint plugin
|
182 |
+
# https://plugins.jetbrains.com/plugin/7973-sonarlint
|
183 |
+
.idea/**/sonarlint/
|
184 |
+
|
185 |
+
# SonarQube Plugin
|
186 |
+
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
|
187 |
+
.idea/**/sonarIssues.xml
|
188 |
+
|
189 |
+
# Markdown Navigator plugin
|
190 |
+
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
|
191 |
+
.idea/**/markdown-navigator.xml
|
192 |
+
.idea/**/markdown-navigator-enh.xml
|
193 |
+
.idea/**/markdown-navigator/
|
194 |
+
|
195 |
+
# Cache file creation bug
|
196 |
+
# See https://youtrack.jetbrains.com/issue/JBR-2257
|
197 |
+
.idea/$CACHE_FILE$
|
198 |
+
|
199 |
+
# CodeStream plugin
|
200 |
+
# https://plugins.jetbrains.com/plugin/12206-codestream
|
201 |
+
.idea/codestream.xml
|
202 |
+
|
203 |
+
### Python ###
|
204 |
+
# Byte-compiled / optimized / DLL files
|
205 |
+
__pycache__/
|
206 |
+
*.py[cod]
|
207 |
+
*$py.class
|
208 |
+
|
209 |
+
# C extensions
|
210 |
+
|
211 |
+
# Distribution / packaging
|
212 |
+
.Python
|
213 |
+
build/
|
214 |
+
develop-eggs/
|
215 |
+
downloads/
|
216 |
+
eggs/
|
217 |
+
.eggs/
|
218 |
+
lib/
|
219 |
+
lib64/
|
220 |
+
parts/
|
221 |
+
sdist/
|
222 |
+
var/
|
223 |
+
wheels/
|
224 |
+
share/python-wheels/
|
225 |
+
*.egg-info/
|
226 |
+
.installed.cfg
|
227 |
+
*.egg
|
228 |
+
MANIFEST
|
229 |
+
|
230 |
+
# PyInstaller
|
231 |
+
# Usually these files are written by a python script from a template
|
232 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
233 |
+
*.manifest
|
234 |
+
*.spec
|
235 |
+
|
236 |
+
# Installer logs
|
237 |
+
pip-log.txt
|
238 |
+
pip-delete-this-directory.txt
|
239 |
+
|
240 |
+
# Unit test / coverage reports
|
241 |
+
htmlcov/
|
242 |
+
.tox/
|
243 |
+
.nox/
|
244 |
+
.coverage
|
245 |
+
.coverage.*
|
246 |
+
.cache
|
247 |
+
nosetests.xml
|
248 |
+
coverage.xml
|
249 |
+
*.cover
|
250 |
+
*.py,cover
|
251 |
+
.hypothesis/
|
252 |
+
.pytest_cache/
|
253 |
+
cover/
|
254 |
+
|
255 |
+
# Translations
|
256 |
+
*.mo
|
257 |
+
*.pot
|
258 |
+
|
259 |
+
# Django stuff:
|
260 |
+
*.log
|
261 |
+
local_settings.py
|
262 |
+
db.sqlite3
|
263 |
+
db.sqlite3-journal
|
264 |
+
|
265 |
+
# Flask stuff:
|
266 |
+
instance/
|
267 |
+
.webassets-cache
|
268 |
+
|
269 |
+
# Scrapy stuff:
|
270 |
+
.scrapy
|
271 |
+
|
272 |
+
# Sphinx documentation
|
273 |
+
docs/_build/
|
274 |
+
|
275 |
+
# PyBuilder
|
276 |
+
.pybuilder/
|
277 |
+
target/
|
278 |
+
|
279 |
+
# Jupyter Notebook
|
280 |
+
|
281 |
+
# IPython
|
282 |
+
|
283 |
+
# pyenv
|
284 |
+
# For a library or package, you might want to ignore these files since the code is
|
285 |
+
# intended to run in multiple environments; otherwise, check them in:
|
286 |
+
# .python-version
|
287 |
+
|
288 |
+
# pipenv
|
289 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
290 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
291 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
292 |
+
# install all needed dependencies.
|
293 |
+
#Pipfile.lock
|
294 |
+
|
295 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
296 |
+
__pypackages__/
|
297 |
+
|
298 |
+
# Celery stuff
|
299 |
+
celerybeat-schedule
|
300 |
+
celerybeat.pid
|
301 |
+
|
302 |
+
# SageMath parsed files
|
303 |
+
*.sage.py
|
304 |
+
|
305 |
+
# Environments
|
306 |
+
.env
|
307 |
+
.venv
|
308 |
+
venv/
|
309 |
+
env/
|
310 |
+
venv/
|
311 |
+
ENV/
|
312 |
+
env.bak/
|
313 |
+
venv.bak/
|
314 |
+
|
315 |
+
# Spyder project settings
|
316 |
+
.spyderproject
|
317 |
+
.spyproject
|
318 |
+
|
319 |
+
# Rope project settings
|
320 |
+
.ropeproject
|
321 |
+
|
322 |
+
# mkdocs documentation
|
323 |
+
/site
|
324 |
+
|
325 |
+
# mypy
|
326 |
+
.mypy_cache/
|
327 |
+
.dmypy.json
|
328 |
+
dmypy.json
|
329 |
+
|
330 |
+
# Pyre type checker
|
331 |
+
.pyre/
|
332 |
+
|
333 |
+
# pytype static type analyzer
|
334 |
+
.pytype/
|
335 |
+
|
336 |
+
# Cython debug symbols
|
337 |
+
cython_debug/
|
338 |
+
|
339 |
+
### VisualStudioCode ###
|
340 |
+
.vscode/*
|
341 |
+
!.vscode/settings.json
|
342 |
+
!.vscode/tasks.json
|
343 |
+
!.vscode/launch.json
|
344 |
+
!.vscode/extensions.json
|
345 |
+
*.code-workspace
|
346 |
+
|
347 |
+
# Local History for Visual Studio Code
|
348 |
+
.history/
|
349 |
+
|
350 |
+
### VisualStudioCode Patch ###
|
351 |
+
# Ignore all local history of files
|
352 |
+
.history
|
353 |
+
.ionide
|
354 |
+
|
355 |
+
# End of https://www.toptal.com/developers/gitignore/api/emacs,python,jupyternotebooks,go,visualstudiocode,pycharm
|
app.py
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from templates.Templates import PromptTemplate
|
3 |
+
from generators.title_to_abstract import title_to_abstract_generator
|
4 |
+
from generators.topic_to_abstract import topic_to_abstract_generator
|
5 |
+
|
6 |
+
from flask_app import generate
|
7 |
+
|
8 |
+
|
9 |
+
prompt = PromptTemplate()
|
10 |
+
|
11 |
+
result_text = ""
|
12 |
+
|
13 |
+
st.title('Scientific Paper Abstract Writer')
|
14 |
+
|
15 |
+
|
16 |
+
col_1, col_2 = st.columns(2)
|
17 |
+
|
18 |
+
with col_1:
|
19 |
+
st.markdown(
|
20 |
+
"""
|
21 |
+
This is an **AI powered** tool that will help you write an abstract for your scientific paper.
|
22 |
+
|
23 |
+
There are two ways you can generate the abstract:
|
24 |
+
|
25 |
+
1. **Title to Abstract** - This will generate an abstract based on the title of your paper.
|
26 |
+
|
27 |
+
2. **Topic to Abstract** - This will generate an abstract based on the topic of your paper.
|
28 |
+
"""
|
29 |
+
)
|
30 |
+
with col_2:
|
31 |
+
option = st.radio('Please select one',
|
32 |
+
('Title to Abstract', 'Topic to Abstract'))
|
33 |
+
|
34 |
+
st.write('You selected:', option)
|
35 |
+
|
36 |
+
if option == 'Title to Abstract':
|
37 |
+
title = st.text_area(
|
38 |
+
'Please input the title of the paper. '
|
39 |
+
'Five or more words are suggested for best results. ')
|
40 |
+
if st.button('Generate'):
|
41 |
+
with st.spinner('Generating...'):
|
42 |
+
result = generate({'title': title}, 'title')
|
43 |
+
st.success('Generated abstract: ')
|
44 |
+
result_text = result['result']
|
45 |
+
else:
|
46 |
+
topic = st.text_area(
|
47 |
+
'Please input the topic of the paper. Example: Topic_1 , Topic_2, Topic_3 ')
|
48 |
+
list_topic = topic.split(',')
|
49 |
+
if st.button('Generate'):
|
50 |
+
with st.spinner('Generating...'):
|
51 |
+
result = generate({'topic': list_topic}, 'topic')
|
52 |
+
st.success('Generated abstract: ')
|
53 |
+
result_text = result['result']
|
54 |
+
|
55 |
+
st.write(result_text)
|
flask_app.py
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask, request
|
2 |
+
from generators.title_to_abstract import title_to_abstract_generator
|
3 |
+
from generators.topic_to_abstract import topic_to_abstract_generator
|
4 |
+
app = Flask(__name__)
|
5 |
+
max_length_char = 360
|
6 |
+
|
7 |
+
|
8 |
+
@app.route('/')
|
9 |
+
def rewriter():
|
10 |
+
data = request.get_json(silent=True)
|
11 |
+
if data is None:
|
12 |
+
return 'No data received'
|
13 |
+
else:
|
14 |
+
if data.get('title') is None and data.get('topic') is not None:
|
15 |
+
return generate(data, 'topic')
|
16 |
+
elif data.get('title') is not None:
|
17 |
+
return generate(data, 'title')
|
18 |
+
else:
|
19 |
+
return 'No data received'
|
20 |
+
|
21 |
+
|
22 |
+
def generate(data, value):
|
23 |
+
obj = abstract_generator_obj(value)
|
24 |
+
result = obj(template_generator(value, data[value]))
|
25 |
+
if len(result['result']) > 10:
|
26 |
+
return {"result": result['result']}
|
27 |
+
else:
|
28 |
+
result_re = obj(template_generator(value, data[value]))
|
29 |
+
while len(result_re['result']) < 5:
|
30 |
+
print(f"getting results again, {result_re}")
|
31 |
+
result_re = obj(template_generator(value, data[value]))
|
32 |
+
if len(result_re['result']) > 0:
|
33 |
+
return {"result": result_re['result']}
|
34 |
+
|
35 |
+
|
36 |
+
def abstract_generator_obj(value):
|
37 |
+
if value == 'title':
|
38 |
+
return title_to_abstract_generator
|
39 |
+
else:
|
40 |
+
return topic_to_abstract_generator
|
41 |
+
|
42 |
+
|
43 |
+
def template_generator(type, value):
|
44 |
+
if type == 'title':
|
45 |
+
return "title: " + value + "\n" + 'abstract: '
|
46 |
+
else:
|
47 |
+
keyword_str = "\n"
|
48 |
+
for k in value:
|
49 |
+
keyword_str = keyword_str + k + "\n"
|
50 |
+
return "topic: " + keyword_str + "\n" + 'abstract: '
|
51 |
+
|
52 |
+
|
53 |
+
if __name__ == '__main__':
|
54 |
+
app.run()
|
generators/model.py
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
from unittest import result
|
3 |
+
from templates.Templates import PromptTemplate
|
4 |
+
import openai
|
5 |
+
import os
|
6 |
+
import requests
|
7 |
+
|
8 |
+
prompt = PromptTemplate()
|
9 |
+
|
10 |
+
stop_words = ["###", "\n\n", "<br><br>", "The authors: "]
|
11 |
+
|
12 |
+
|
13 |
+
def model(type, template, seq_len=200):
|
14 |
+
train = ''
|
15 |
+
if type == 'title':
|
16 |
+
train = prompt.TITLE_TO_ABSTRACST
|
17 |
+
if type == 'topic':
|
18 |
+
train = prompt.TOPIC_TO_ABSTRACST
|
19 |
+
|
20 |
+
HF_URL = "https://api-inference.huggingface.co/models/bigscience/bloom"
|
21 |
+
HF_KEY = os.environ["HF_KEY"]
|
22 |
+
|
23 |
+
headers = {"Authorization": f"Bearer {HF_KEY}"}
|
24 |
+
|
25 |
+
print(f"Inside model {seq_len}")
|
26 |
+
|
27 |
+
payload = {
|
28 |
+
"inputs": train + template,
|
29 |
+
"parameters": {
|
30 |
+
"temperature": 0.9,
|
31 |
+
"max_new_tokens": seq_len,
|
32 |
+
"return_full_text": False,
|
33 |
+
"top_p": 0.8,
|
34 |
+
"frequency_penalty": 1.0,
|
35 |
+
"retention_penalty": 1.0,
|
36 |
+
},
|
37 |
+
"options": {
|
38 |
+
"use_cache": False
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
response = requests.post(HF_URL, json=payload, headers=headers)
|
43 |
+
response = response.json()
|
44 |
+
result = response[0]['generated_text']
|
45 |
+
# print("********", len(result), "********")
|
46 |
+
|
47 |
+
# print(result)
|
48 |
+
|
49 |
+
result = result.split("\n\n\n\n")[-1].strip().split("\n")[-1]
|
50 |
+
|
51 |
+
|
52 |
+
return {"result": result}
|
generators/title_to_abstract.py
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
from .model import model
|
3 |
+
|
4 |
+
def title_to_abstract_generator(template):
|
5 |
+
return model('title', template)
|
generators/topic_to_abstract.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
from .model import model
|
3 |
+
|
4 |
+
|
5 |
+
def topic_to_abstract_generator(template):
|
6 |
+
return model('topic', template)
|
requirements.txt
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
click
|
2 |
+
altair==4.1.0
|
3 |
+
argcomplete==1.12.3
|
4 |
+
argon2-cffi==21.1.0
|
5 |
+
astor==0.8.1
|
6 |
+
attrs==21.2.0
|
7 |
+
autopep8==1.5.7
|
8 |
+
backcall==0.2.0
|
9 |
+
backports.zoneinfo==0.2.1
|
10 |
+
base58==2.1.1
|
11 |
+
bleach==4.1.0
|
12 |
+
blinker==1.4
|
13 |
+
cachetools==4.2.4
|
14 |
+
certifi==2021.5.30
|
15 |
+
cffi==1.15.0
|
16 |
+
charset-normalizer==2.0.6
|
17 |
+
click==7.1.2
|
18 |
+
colorama==0.4.4
|
19 |
+
debugpy==1.5.1
|
20 |
+
decorator==5.1.0
|
21 |
+
defusedxml==0.7.1
|
22 |
+
entrypoints==0.3
|
23 |
+
et-xmlfile==1.1.0
|
24 |
+
Flask
|
25 |
+
gitdb==4.0.9
|
26 |
+
GitPython==3.1.24
|
27 |
+
idna==3.2
|
28 |
+
importlib-metadata
|
29 |
+
importlib-resources==5.4.0
|
30 |
+
ipykernel==6.5.0
|
31 |
+
ipython==7.29.0
|
32 |
+
ipython-genutils==0.2.0
|
33 |
+
ipywidgets==7.6.5
|
34 |
+
itsdangerous
|
35 |
+
jedi==0.18.0
|
36 |
+
Jinja2
|
37 |
+
jsonschema==4.2.1
|
38 |
+
jupyter-client==7.0.6
|
39 |
+
jupyter-core==4.9.1
|
40 |
+
jupyterlab-pygments==0.1.2
|
41 |
+
jupyterlab-widgets==1.0.2
|
42 |
+
MarkupSafe
|
43 |
+
matplotlib-inline==0.1.3
|
44 |
+
mistune==0.8.4
|
45 |
+
nbclient==0.5.8
|
46 |
+
nbconvert==6.3.0
|
47 |
+
nbformat==5.1.3
|
48 |
+
nest-asyncio==1.5.1
|
49 |
+
notebook==6.4.5
|
50 |
+
numpy==1.21.2
|
51 |
+
openai==0.10.5
|
52 |
+
openpyxl==3.0.9
|
53 |
+
packaging==21.2
|
54 |
+
pandas==1.3.3
|
55 |
+
pandas-stubs==1.2.0.19
|
56 |
+
pandocfilters==1.5.0
|
57 |
+
parso==0.8.2
|
58 |
+
pickleshare==0.7.5
|
59 |
+
Pillow==8.4.0
|
60 |
+
prometheus-client==0.12.0
|
61 |
+
prompt-toolkit==3.0.22
|
62 |
+
protobuf==3.19.1
|
63 |
+
pyarrow==6.0.0
|
64 |
+
pycodestyle==2.7.0
|
65 |
+
pycparser==2.21
|
66 |
+
pydeck==0.7.1
|
67 |
+
Pygments==2.10.0
|
68 |
+
Pympler==0.9
|
69 |
+
pyparsing==2.4.7
|
70 |
+
pyrsistent==0.18.0
|
71 |
+
python-dateutil==2.8.2
|
72 |
+
pytz==2021.3
|
73 |
+
pytz-deprecation-shim==0.1.0.post0
|
74 |
+
pyzmq==22.3.0
|
75 |
+
requests==2.26.0
|
76 |
+
Send2Trash==1.8.0
|
77 |
+
six==1.16.0
|
78 |
+
smmap==5.0.0
|
79 |
+
streamlit==1.2.0
|
80 |
+
terminado==0.12.1
|
81 |
+
testpath==0.5.0
|
82 |
+
toml==0.10.2
|
83 |
+
toolz==0.11.2
|
84 |
+
tornado==6.1
|
85 |
+
tqdm==4.62.3
|
86 |
+
traitlets==5.1.1
|
87 |
+
typing-extensions
|
88 |
+
tzdata==2021.5
|
89 |
+
tzlocal==4.1
|
90 |
+
urllib3==1.26.7
|
91 |
+
validators==0.18.2
|
92 |
+
watchdog==2.1.6
|
93 |
+
wcwidth==0.2.5
|
94 |
+
webencodings==0.5.1
|
95 |
+
Werkzeug
|
96 |
+
widgetsnbextension==3.5.2
|
97 |
+
zipp
|
98 |
+
gunicorn
|
templates/Templates.py
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
class PromptTemplate:
|
3 |
+
TOPIC_TO_ABSTRACST = '''
|
4 |
+
Write an abstract of a scientific paper based on these topics and keywords.
|
5 |
+
\n\n\n
|
6 |
+
###
|
7 |
+
\n\n\n
|
8 |
+
topics: \n
|
9 |
+
Recommender systems\n
|
10 |
+
Filtering\n
|
11 |
+
Electronic commerce\n
|
12 |
+
abstract: With the collaborative filtering techniques becoming more and more mature, recommender systems are widely used nowadays, especially in electronic commerce and social networks. However, the utilization of recommender systems in academic research itself has not received enough attention. A research paper recommender system would greatly help researchers to find the most desirable papers in their fields of endeavour. Due to the textual nature of papers, content information could be integrated into existed recommendation methods. In this paper, we proposed that by using topic model techniques to make topic analysis on research papers, we could introduce a thematic similarity measurement into a modified version of the item-based recommendation approach. This novel recommendation method could considerably alleviate the cold start problem in research paper recommendations. Our experiment result shows that our approach could recommend highly relevant research papers.
|
13 |
+
\n\n\n
|
14 |
+
###
|
15 |
+
\n\n\n
|
16 |
+
topics: \n
|
17 |
+
Corona\n
|
18 |
+
Loss measurement\n
|
19 |
+
Rain\n
|
20 |
+
abstract: Transmission line corona loss research is one of the critical technologies of 1000 kV UHV transmission and transformation engineering. Transmission line corona loss relates to many factors of climate, and rainfall rate affects corona loss distinctly very much. By means of UHV AC single circuit test line, corona loss monitoring and UHV corona cage conductor corona loss measurement, this paper researched the effect of rainfall rates on UHV AC single-circuit transmission line's corona loss. This paper applied a corona loss monitoring system to monitor corona loss of UHV single circuit test line and obtained corona loss monitoring data in light rain, moderate rain, and heavy rain conditions. Analyze corona loss test results. Corona loss values in light rain, moderate rain, and heavy rain conditions are obtained. The results show that rain has an obvious influence on corona loss of the line, at the beginning of rain, corona loss increases quickly, after rain, corona loss decreases with the drying of the conductor. The decay time is related to surface field strength, wind speed, air humidity, temperature and other factors. When the rainfall rate is low, corona loss increases fast with the increase of the rainfall rate. With the increase in the rainfall rate, corona loss grows slowly. When the rainfall rate increases to some level, corona loss stop growing.
|
21 |
+
\n\n\n
|
22 |
+
###
|
23 |
+
\n\n\n
|
24 |
+
topic: \n
|
25 |
+
Machine learning\n
|
26 |
+
Data models\n
|
27 |
+
Stock markets\n
|
28 |
+
Testing\n
|
29 |
+
Machine learning algorithms\n
|
30 |
+
abstract: In this paper, we provide a comparative analysis sheet of the main publicly-available benchmark data sets for stock markets statistical modelling statistical testing, providing a common language for people from different academic fields to discuss technical issues more conduct conductively. In order to more facilitate the exchange of research results of more people, this article will continue to keep up with time, and follow-up for a comprehensive study of the data model characteristics and data features of these data sets, providing a framework for statistical testing techniques and machine learning algorithms related activities of more practitioners.
|
31 |
+
\n\n\n
|
32 |
+
###
|
33 |
+
\n\n\n
|
34 |
+
topic: \n
|
35 |
+
Organizations\n
|
36 |
+
Business intelligence\n
|
37 |
+
Warehousing\n
|
38 |
+
Data mining\n
|
39 |
+
Decision making\n
|
40 |
+
Databases\n
|
41 |
+
Industries\n
|
42 |
+
abstract: We need an effective and reliable arrangement of data and, with the foundations of statistical and business intelligence, data mining and warehousing, companies with the increased amount of data will be able to decrease uncertainty and make the best decision. In this respect, our paper overviews the concept, technology and technology trends of business intelligence, data mining and warehouse from an aspect of the infrastructure feature of the industry, classified as production planning for improving operational efficiency. In order to evaluate the benefits of using business intelligence, this paper examine some enterprises utilizing data mining and business intelligence
|
43 |
+
\n\n\n
|
44 |
+
'''
|
45 |
+
|
46 |
+
TITLE_TO_ABSTRACST = '''
|
47 |
+
write an abstract of a scientific paper using the title of the paper
|
48 |
+
\n\n\n
|
49 |
+
###
|
50 |
+
\n\n\n
|
51 |
+
title: Research paper recommendation with topic analysis.
|
52 |
+
\n
|
53 |
+
abstract: With the collaborative filtering techniques becoming more and more mature, recommender systems are widely used nowadays, especially in electronic commerce and social networks. However, the utilization of recommender systems in academic research itself has not received enough attention. A research paper recommender system would greatly help researchers to find the most desirable papers in their fields of endeavour. Due to the textual nature of papers, content information could be integrated into existed recommendation methods. In this paper, we proposed that by using topic model techniques to make topic analysis on research papers, we could introduce a thematic similarity measurement into a modified version of the item-based recommendation approach. This novel recommendation method could considerably alleviate the cold start problem in research paper recommendations. Our experiment result shows that our approach could recommend highly relevant research papers.\n\n\n
|
54 |
+
###
|
55 |
+
\n\n\n
|
56 |
+
title: UHV AC corona loss measurement and analysis under the rain.\nabstract: Transmission line corona loss research is one of the critical technologies of 1000 kV UHV transmission and transformation engineering. Transmission line corona loss relates to many factors of climate, and rainfall rate affects corona loss distinctly very much. By means of UHV AC single circuit test line, corona loss monitoring and UHV corona cage conductor corona loss measurement, this paper researched the effect of rainfall rates on UHV AC single-circuit transmission lines corona loss. This paper applied a corona loss monitoring system to monitor corona loss of UHV single circuit test line and obtained corona loss monitoring data in light rain, moderate rain, and heavy rain conditions. Analyze corona loss test results. Corona loss values in light rain, moderate rain, and heavy rain conditions are obtained. The results show that rain has an obvious influence on corona loss of the line, at the beginning of rain, corona loss increases quickly, after rain, corona loss decreases with the drying of the conductor. The decay time is related to surface field strength, wind speed, air humidity, temperature and other factors. When the rainfall rate is low, corona loss increases fast with the increase of the rainfall rate. With the increase in the rainfall rate, corona loss grows slowly. When the rainfall rate increases to some level, corona loss stop growing.
|
57 |
+
\n\n\n
|
58 |
+
###
|
59 |
+
\n\n\n
|
60 |
+
title: Cingulate circuits are associated with escalation of heroin use and naloxone-induced increases in heroin self-administration
|
61 |
+
\n
|
62 |
+
abstract: Opioid use disorder (OUD) is defined as a compulsion to seek and take opioids, loss of control over intake and the development of a negative emotional state when access to opioids is denied. Using functional magnetic resonance imaging (fMRI) data in a rat model of OUD, we demonstrate that the escalation of heroin self-administration (SA) and the increased heroin SA following an injection of an opioid receptor antagonist (naloxone) are associated with changes in distinct brain circuits, centered on the cingulate cortex (Cg). Here, SA escalation score was negatively associated with changes in resting state functional connectivity (rsFC) between the Cg and the dorsal striatum. Conversely, increased heroin SA following naloxone injection, was associated with increased connectivity between the Cg and the extended amygdala and hypothalamus. Naloxone-induced increased SA was also positively associated with changes in the amplitude of low frequency fluctuations within the Cg, a measure of spontaneous neuronal activity. Characterizing the distinct brain circuit and behavior changes associated with different facets of addiction increases our understanding of OUD and may provide insight into addiction prevention and treatment.
|
63 |
+
\n\n\n
|
64 |
+
'''
|