Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -12,7 +12,7 @@ from pathlib import Path
|
|
12 |
from langchain_huggingface import ChatHuggingFace, HuggingFaceEndpoint
|
13 |
|
14 |
llm = HuggingFaceEndpoint(
|
15 |
-
repo_id="mistralai/
|
16 |
task="text-generation",
|
17 |
max_new_tokens=4096,
|
18 |
temperature=0.5,
|
@@ -41,12 +41,8 @@ def summarize(file, n_words):
|
|
41 |
text = document.page_content
|
42 |
text_splitter = RecursiveCharacterTextSplitter(chunk_size=3000, chunk_overlap=200)
|
43 |
chunks = text_splitter.create_documents([text])
|
44 |
-
n_words = n_words
|
45 |
template = '''
|
46 |
-
Your task is to summarize
|
47 |
-
Start with an introductory sentence and then summarize the main points in a logical order, ensuring the summary is very detailed.
|
48 |
-
|
49 |
-
Here is the long text to summarize:
|
50 |
|
51 |
Text:
|
52 |
{TEXT}
|
@@ -55,7 +51,7 @@ def summarize(file, n_words):
|
|
55 |
template=template,
|
56 |
input_variables=['TEXT']
|
57 |
)
|
58 |
-
formatted_prompt = prompt.format(TEXT=text
|
59 |
output_summary = llm_engine_hf.invoke(formatted_prompt)
|
60 |
return output_summary.content
|
61 |
|
|
|
12 |
from langchain_huggingface import ChatHuggingFace, HuggingFaceEndpoint
|
13 |
|
14 |
llm = HuggingFaceEndpoint(
|
15 |
+
repo_id="mistralai/Mistral-7B-Instruct-v0.3",
|
16 |
task="text-generation",
|
17 |
max_new_tokens=4096,
|
18 |
temperature=0.5,
|
|
|
41 |
text = document.page_content
|
42 |
text_splitter = RecursiveCharacterTextSplitter(chunk_size=3000, chunk_overlap=200)
|
43 |
chunks = text_splitter.create_documents([text])
|
|
|
44 |
template = '''
|
45 |
+
Your task is to summarize texts into a VERY detailed summaries.
|
|
|
|
|
|
|
46 |
|
47 |
Text:
|
48 |
{TEXT}
|
|
|
51 |
template=template,
|
52 |
input_variables=['TEXT']
|
53 |
)
|
54 |
+
formatted_prompt = prompt.format(TEXT=text)
|
55 |
output_summary = llm_engine_hf.invoke(formatted_prompt)
|
56 |
return output_summary.content
|
57 |
|