davidm commited on
Commit
dfbe641
1 Parent(s): aa4e0dd

initial commit

Browse files
Files changed (5) hide show
  1. Dockerfile +9 -0
  2. __init__.py +0 -0
  3. app.py +41 -0
  4. requirements.txt +7 -0
  5. setup.py +24 -0
Dockerfile ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9-slim-buster
2
+ COPY . /app
3
+ WORKDIR /app
4
+ RUN pip install --upgrade pip
5
+ RUN pip install numpy==1.24.3
6
+ RUN pip install -r requirements.txt
7
+ EXPOSE 8501
8
+ ENTRYPOINT ["streamlit","run"]
9
+ CMD ["app.py"]
__init__.py ADDED
File without changes
app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import requests
3
+ import streamlit as st
4
+
5
+ def main():
6
+ st.title("Scientific Question Generation")
7
+
8
+ API_URL = "https://api-inference.huggingface.co/models/dhmeltzer/bart-large_askscience-qg"
9
+ headers = {"Authorization": "Bearer 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"}
10
+
11
+ def query(payload):
12
+ response = requests.post(API_URL,
13
+ headers=headers,
14
+ json=payload)
15
+ return response.json()
16
+
17
+ # User search
18
+ user_input = st.text_area("Question Generator",
19
+ """Black holes are the most \
20
+ gravitationally dense objects in the universe.""")
21
+
22
+ # Filters
23
+ st.sidebar.markdown("**Filters**")
24
+
25
+ temperature = st.sidebar.slider("Temperature", 0.0, 1.0, 0.0,.1)
26
+ num_results = st.sidebar.slider("Number of search results", 1, 50, 1)
27
+
28
+ vector = query([user_input])
29
+
30
+ if user_input:
31
+
32
+ output = query({
33
+ "inputs": user_input,
34
+ "temperature":temperature,
35
+ "wait_for_model":True})
36
+
37
+ st.write(output)
38
+
39
+
40
+ if __name__ == "__main__":
41
+ main()
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ datasets
2
+ torch==1.13
3
+ transformers==4.29.0
4
+ faiss-cpu
5
+ folium
6
+ streamlit==1.14.0
7
+ -e .
setup.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from setuptools import setup
2
+
3
+ common_kwargs = dict(
4
+ version="0.1.0",
5
+ license="MIT",
6
+ author="David Meltzer",
7
+ author_email="[email protected]",
8
+ classifiers=[
9
+ "Intended Audience :: Developers",
10
+ "Intended Audience :: Science/Research",
11
+ "License :: OSI Approved :: MIT License",
12
+ "Natural Language :: English",
13
+ "Operating System :: OS Independent",
14
+ "Programming Language :: Python :: 3.9",
15
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
16
+ ],
17
+ python_requires=">=3.9",
18
+ include_package_data=False,
19
+ )
20
+
21
+ setup(
22
+ name="asks_qg",
23
+ **common_kwargs
24
+ )