Spaces:
Sleeping
Sleeping
Upload 18 files
Browse files
app.py
CHANGED
@@ -195,7 +195,7 @@ with col1:
|
|
195 |
)
|
196 |
|
197 |
if decoder_model == "GPT-3.5 Turbo":
|
198 |
-
with
|
199 |
with st.form("gpt_form"):
|
200 |
openai_key = st.text_input(
|
201 |
"Enter OpenAI key",
|
@@ -208,23 +208,31 @@ if decoder_model == "GPT-3.5 Turbo":
|
|
208 |
openai.api_key = api_key
|
209 |
generated_text = gpt_turbo_model(edited_prompt)
|
210 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
if decoder_model == "Vicuna-7B":
|
212 |
with col2:
|
213 |
st.write("The Vicuna Model is running: ...")
|
214 |
st.write("The model takes 10-15 mins to generate the text.")
|
215 |
-
|
216 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
|
218 |
-
with col2:
|
219 |
-
st.subheader("Answer:")
|
220 |
-
regex_pattern_sentences = "(?<!\w\.\w.)(?<![A-Z][a-z]\.)(?<=\.|\?)\s"
|
221 |
-
generated_text_list = re.split(regex_pattern_sentences, generated_text)
|
222 |
-
for answer_text in generated_text_list:
|
223 |
-
answer_text = f"""{answer_text}"""
|
224 |
-
st.write(
|
225 |
-
f"<ul><li><p>{answer_text}</p></li></ul>",
|
226 |
-
unsafe_allow_html=True,
|
227 |
-
)
|
228 |
|
229 |
|
230 |
tab1, tab2 = st.tabs(["Retrieved Text", "Retrieved Documents"])
|
|
|
195 |
)
|
196 |
|
197 |
if decoder_model == "GPT-3.5 Turbo":
|
198 |
+
with col2:
|
199 |
with st.form("gpt_form"):
|
200 |
openai_key = st.text_input(
|
201 |
"Enter OpenAI key",
|
|
|
208 |
openai.api_key = api_key
|
209 |
generated_text = gpt_turbo_model(edited_prompt)
|
210 |
|
211 |
+
st.subheader("Answer:")
|
212 |
+
regex_pattern_sentences = "(?<!\w\.\w.)(?<![A-Z][a-z]\.)(?<=\.|\?)\s"
|
213 |
+
generated_text_list = re.split(regex_pattern_sentences, generated_text)
|
214 |
+
for answer_text in generated_text_list:
|
215 |
+
answer_text = f"""{answer_text}"""
|
216 |
+
st.write(
|
217 |
+
f"<ul><li><p>{answer_text}</p></li></ul>",
|
218 |
+
unsafe_allow_html=True,
|
219 |
+
)
|
220 |
+
|
221 |
if decoder_model == "Vicuna-7B":
|
222 |
with col2:
|
223 |
st.write("The Vicuna Model is running: ...")
|
224 |
st.write("The model takes 10-15 mins to generate the text.")
|
225 |
+
generated_text = vicuna_text_generate(prompt, vicuna_text_gen_model)
|
226 |
+
st.subheader("Answer:")
|
227 |
+
regex_pattern_sentences = "(?<!\w\.\w.)(?<![A-Z][a-z]\.)(?<=\.|\?)\s"
|
228 |
+
generated_text_list = re.split(regex_pattern_sentences, generated_text)
|
229 |
+
for answer_text in generated_text_list:
|
230 |
+
answer_text = f"""{answer_text}"""
|
231 |
+
st.write(
|
232 |
+
f"<ul><li><p>{answer_text}</p></li></ul>",
|
233 |
+
unsafe_allow_html=True,
|
234 |
+
)
|
235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
|
237 |
|
238 |
tab1, tab2 = st.tabs(["Retrieved Text", "Retrieved Documents"])
|
utils/__pycache__/entity_extraction.cpython-38.pyc
CHANGED
Binary files a/utils/__pycache__/entity_extraction.cpython-38.pyc and b/utils/__pycache__/entity_extraction.cpython-38.pyc differ
|
|
utils/__pycache__/models.cpython-38.pyc
CHANGED
Binary files a/utils/__pycache__/models.cpython-38.pyc and b/utils/__pycache__/models.cpython-38.pyc differ
|
|
utils/__pycache__/nltkmodules.cpython-38.pyc
ADDED
Binary file (284 Bytes). View file
|
|
utils/entity_extraction.py
CHANGED
@@ -7,20 +7,21 @@ from nltk.stem import PorterStemmer, WordNetLemmatizer
|
|
7 |
|
8 |
def generate_ner_docs_prompt(query):
|
9 |
prompt = """USER: Extract the company names and time duration mentioned in the question. The entities should be extracted in the following format: {"companies": list of companies mentioned in the question,"start-duration": ("start-quarter", "start-year"), "end-duration": ("end-quarter", "end-year")}. Return {"companies": None, "start-duration": (None, None), "end-duration": (None, None)} if the entities are not found.
|
|
|
10 |
Examples:
|
11 |
-
What did analysts ask about the Wearables during AAPL's earnings call?
|
12 |
-
{"companies": ["AAPL"], "start-duration": (None, None), "end-duration": (None, None)}
|
13 |
What is Intel's update on the server chip roadmap and strategy for Q1 2019?
|
14 |
{"companies": ["Intel"], "start-duration": ("Q1", "2019"), "end-duration": ("Q1", "2019")}
|
15 |
What are the opportunities and challenges in the Indian market for Amazon in 2016?
|
16 |
{"companies": ["Amazon"], "start-duration": ("Q1", "2016"), "end-duration": ("Q4", "2016")}
|
|
|
|
|
17 |
What is the comparative performance analysis between Intel and AMD in key overlapping segments such as PC, Gaming, and Data Centers in Q2 to Q3 2018?
|
18 |
{"companies": ["Intel", "AMD"], "start-duration": ("Q2", "2018"), "end-duration": ("Q3", "2018")}
|
19 |
How did Microsoft and Amazon perform in terms of reliability and scalability of cloud for the years 2016 and 2017?
|
20 |
{"companies": ["Microsoft", "Amazon"], "start-duration": ("Q1", "2016"), "end-duration": ("Q4", "2017")}"""
|
21 |
input_prompt = f"""###Input: {query}
|
22 |
ASSISTANT:"""
|
23 |
-
final_prompt = prompt + "\n" + input_prompt
|
24 |
return final_prompt
|
25 |
|
26 |
|
|
|
7 |
|
8 |
def generate_ner_docs_prompt(query):
|
9 |
prompt = """USER: Extract the company names and time duration mentioned in the question. The entities should be extracted in the following format: {"companies": list of companies mentioned in the question,"start-duration": ("start-quarter", "start-year"), "end-duration": ("end-quarter", "end-year")}. Return {"companies": None, "start-duration": (None, None), "end-duration": (None, None)} if the entities are not found.
|
10 |
+
|
11 |
Examples:
|
|
|
|
|
12 |
What is Intel's update on the server chip roadmap and strategy for Q1 2019?
|
13 |
{"companies": ["Intel"], "start-duration": ("Q1", "2019"), "end-duration": ("Q1", "2019")}
|
14 |
What are the opportunities and challenges in the Indian market for Amazon in 2016?
|
15 |
{"companies": ["Amazon"], "start-duration": ("Q1", "2016"), "end-duration": ("Q4", "2016")}
|
16 |
+
What did analysts ask about the Cisco's Webex?
|
17 |
+
{"companies": ["Cisco"], "start-duration": (None, None), "end-duration": (None, None)}
|
18 |
What is the comparative performance analysis between Intel and AMD in key overlapping segments such as PC, Gaming, and Data Centers in Q2 to Q3 2018?
|
19 |
{"companies": ["Intel", "AMD"], "start-duration": ("Q2", "2018"), "end-duration": ("Q3", "2018")}
|
20 |
How did Microsoft and Amazon perform in terms of reliability and scalability of cloud for the years 2016 and 2017?
|
21 |
{"companies": ["Microsoft", "Amazon"], "start-duration": ("Q1", "2016"), "end-duration": ("Q4", "2017")}"""
|
22 |
input_prompt = f"""###Input: {query}
|
23 |
ASSISTANT:"""
|
24 |
+
final_prompt = prompt + "\n\n" + input_prompt
|
25 |
return final_prompt
|
26 |
|
27 |
|