Chan-Y commited on
Commit
d100ccb
1 Parent(s): e2458a4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -7
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/Mixtral-8x7B-v0.1",
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 a long text into a detailed summary.
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, N_WORDS=n_words)
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