Kathirsci commited on
Commit
a9009ba
Β·
verified Β·
1 Parent(s): 1dc7433

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -39
app.py CHANGED
@@ -18,7 +18,7 @@ logger = logging.getLogger(__name__)
18
 
19
  # Constants
20
  EMBEDDING_MODEL = 'sentence-transformers/all-MiniLM-L6-v2'
21
- DEFAULT_MODEL = "facebook/bart-large-cnn"
22
 
23
  @st.cache_resource
24
  def load_embeddings():
@@ -71,44 +71,35 @@ def summarize_report(documents: List[Document], llm) -> str:
71
  """Summarize the report using the loaded model."""
72
  try:
73
  prompt_template = """
74
- You are an AI specialized in summarizing comprehensive reports with a focus on funding, finances, and global comparisons. Given the detailed report content below, generate a concise and structured summary using bullet points and emojis. The summary should highlight key funding figures, financial data, budget allocations, comparisons between regions, and notable insights about [FOCUS_REGION]'s role in the global context of [TOPIC].
75
- Report Content:
76
- {text}
77
- Your summary should follow this structure:
78
- Summary:
79
- πŸ’° [TOPIC] Overview for [FOCUS_REGION]:
80
-
81
- πŸ”΄ [FOCUS_REGION]'s Position in Global [TOPIC]:
82
- πŸ“ Total investment/funding: [amount]
83
- πŸ“ Breakdown of funding sources (e.g., government, private sector)
84
- πŸ“ [FOCUS_REGION]'s ranking in global investment
85
- πŸ“ Key statistics and figures
86
-
87
- πŸ”΄ Financial Impact and Projections:
88
- πŸ“ Expected ROI or economic benefits
89
- πŸ“ Financial milestones or targets
90
- πŸ“ Impact on relevant areas
91
-
92
- πŸ”΄ Global Comparison:
93
- πŸ“ [List of relevant countries/regions with their financial figures]
94
- πŸ“ Comparative analysis of [FOCUS_REGION] vs other major players
95
-
96
- πŸ”΄ Budget Analysis:
97
- πŸ“ Major budget items
98
- πŸ“ Key budget allocations
99
- πŸ“ Year-over-year budget changes
100
- πŸ“ Comparison to industry benchmarks
101
-
102
- πŸ”΄ Funding Strategies:
103
- πŸ“ Key funding mechanisms (e.g., grants, loans, public-private partnerships)
104
- πŸ“ Innovative financing approaches
105
-
106
- πŸ”΄ Progress and Significance:
107
- πŸ“ Key achievements or milestones
108
- πŸ“ [1-2 concluding points about [FOCUS_REGION]'s role or significance in [TOPIC]]
109
-
110
- Please ensure the summary is concise, informative, and easy to read at a glance. Use precise figures where available and highlight any significant financial trends or insights. The summary should provide a comprehensive overview of both the financial aspects and the broader context of [TOPIC] in [FOCUS_REGION].
111
- """
112
 
113
  prompt = PromptTemplate.from_template(prompt_template)
114
  chain = load_summarize_chain(llm, chain_type="stuff", prompt=prompt)
 
18
 
19
  # Constants
20
  EMBEDDING_MODEL = 'sentence-transformers/all-MiniLM-L6-v2'
21
+ DEFAULT_MODEL = "liuhaotian/llava-v1.6-mistral-7b"
22
 
23
  @st.cache_resource
24
  def load_embeddings():
 
71
  """Summarize the report using the loaded model."""
72
  try:
73
  prompt_template = """
74
+ <s>[INST] You are an advanced AI assistant with expertise in summarizing technical documents. Your goal is to create a clear, concise, and well-organized summary using Markdown formatting. Focus on extracting and presenting the essential points of the document effectively.
75
+
76
+ *Instructions:*
77
+ - Analyze the provided context and input carefully.
78
+ - Identify and highlight the key points, main arguments, and important details.
79
+ - Format the summary using Markdown for clarity:
80
+ - Use # for main headers and ## for subheaders.
81
+ - Use **text** for important terms or concepts.
82
+ - Provide a brief introduction, followed by the main points, and a concluding summary if applicable.
83
+ - Ensure the summary is easy to read and understand, avoiding unnecessary jargon.
84
+
85
+ *Example Summary Format:*
86
+
87
+ # Overview
88
+ *Document Title:* Technical Analysis Report
89
+
90
+ *Summary:*
91
+ The report provides an in-depth analysis of the recent technical advancements in AI. It covers key areas such as ...
92
+
93
+ # Key Findings
94
+ - *Finding 1:* Description of finding 1.
95
+ - *Finding 2:* Description of finding 2.
96
+
97
+ # Conclusion
98
+ The analysis highlights the significant advancements and future directions for AI technology.
99
+
100
+ *Your Response:* [/INST]</s> {input}
101
+ Context: {context}
102
+ """
 
 
 
 
 
 
 
 
 
103
 
104
  prompt = PromptTemplate.from_template(prompt_template)
105
  chain = load_summarize_chain(llm, chain_type="stuff", prompt=prompt)