Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -88,39 +88,51 @@ def data_ingestion(file_path):
|
|
88 |
########## CHAIN 1 norm text
|
89 |
|
90 |
def chain1():
|
91 |
-
prompt_template = """Please provide a summary of the given study material. Summarize the key concepts, findings, and important details.
|
92 |
-
Pay special attention to any definitions, theories, or conclusions presented in the text.
|
93 |
-
Your summary should be concise yet comprehensive, capturing the main points of the study material.
|
94 |
-
Your job is to write a summary of the document such that every summary of the text is of 2 sentences.
|
95 |
-
here is the content of the section:
|
96 |
-
"{text}"
|
97 |
-
|
98 |
-
SUMMARY:"""
|
99 |
-
prompt = PromptTemplate.from_template(prompt_template)
|
100 |
-
|
101 |
-
refine_template = (
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
refine_prompt = PromptTemplate.from_template(refine_template)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
chain1 = load_summarize_chain(
|
114 |
-
llm=HuggingFaceHub(repo_id="
|
115 |
model_kwargs={"temperature":1, "max_length":10000},
|
116 |
huggingfacehub_api_token=api_token),
|
117 |
-
chain_type="
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
input_key="input_documents",
|
122 |
output_key="output_text",
|
123 |
)
|
|
|
124 |
return chain1
|
125 |
|
126 |
# result = chain({"input_documents":split_docs}, return_only_outputs=True)
|
|
|
88 |
########## CHAIN 1 norm text
|
89 |
|
90 |
def chain1():
|
91 |
+
# prompt_template = """Please provide a summary of the given study material. Summarize the key concepts, findings, and important details.
|
92 |
+
# Pay special attention to any definitions, theories, or conclusions presented in the text.
|
93 |
+
# Your summary should be concise yet comprehensive, capturing the main points of the study material.
|
94 |
+
# Your job is to write a summary of the document such that every summary of the text is of 2 sentences.
|
95 |
+
# here is the content of the section:
|
96 |
+
# "{text}"
|
97 |
+
|
98 |
+
# SUMMARY:"""
|
99 |
+
# prompt = PromptTemplate.from_template(prompt_template)
|
100 |
+
|
101 |
+
# refine_template = (
|
102 |
+
# "Your job is to produce a final summary\n"
|
103 |
+
# # "We have provided an existing summary up to a certain point: {existing_answer}\n"
|
104 |
+
# "We have the opportunity to refine the existing summary"
|
105 |
+
# "(only if needed) with some more context below.\n"
|
106 |
+
# "------------\n"
|
107 |
+
# "{text}\n"
|
108 |
+
# "------------\n"
|
109 |
+
# "Given the new context, refine the original summary in English"
|
110 |
+
# "If the context isn't useful, return the original summary." )
|
111 |
+
|
112 |
+
# refine_prompt = PromptTemplate.from_template(refine_template)
|
113 |
+
# chain1 = load_summarize_chain(
|
114 |
+
# llm=HuggingFaceHub(repo_id="mistralai/Mixtral-8x7B-Instruct-v0.1",
|
115 |
+
# model_kwargs={"temperature":1, "max_length":10000},
|
116 |
+
# huggingfacehub_api_token=api_token),
|
117 |
+
# chain_type="refine",
|
118 |
+
# question_prompt=prompt,
|
119 |
+
# # refine_prompt=refine_prompt,
|
120 |
+
# return_intermediate_steps=False,
|
121 |
+
# input_key="input_documents",
|
122 |
+
# output_key="output_text",
|
123 |
+
# )
|
124 |
chain1 = load_summarize_chain(
|
125 |
+
llm=HuggingFaceHub(repo_id="sshleifer/distilbart-cnn-12-6",
|
126 |
model_kwargs={"temperature":1, "max_length":10000},
|
127 |
huggingfacehub_api_token=api_token),
|
128 |
+
chain_type="stuff",
|
129 |
+
# question_prompt=prompt,
|
130 |
+
# # refine_prompt=refine_prompt,
|
131 |
+
# return_intermediate_steps=False,
|
132 |
input_key="input_documents",
|
133 |
output_key="output_text",
|
134 |
)
|
135 |
+
|
136 |
return chain1
|
137 |
|
138 |
# result = chain({"input_documents":split_docs}, return_only_outputs=True)
|