Cachoups commited on
Commit
5c847e4
·
verified ·
1 Parent(s): 2da849c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -3
app.py CHANGED
@@ -26,7 +26,7 @@ summarizer = pipeline("summarization", model="human-centered-summarization/finan
26
  fin_model = pipeline("sentiment-analysis", model='yiyanghkust/finbert-tone', tokenizer='yiyanghkust/finbert-tone')
27
  fin_model_bis = pipeline("sentiment-analysis", model='ProsusAI/finbert', tokenizer='ProsusAI/finbert')
28
  table_to_text = pipeline('text2text-generation', model='google/flan-t5-large')
29
- generator = pipeline('text-generation', model='EleutherAI/gpt-neo-2.7B')
30
 
31
  def summarize_text(text):
32
  resp = summarizer(text)
@@ -271,10 +271,40 @@ def generate_text(df, country, theme):
271
  Make sure your description follows the example format and accurately reflects the data.
272
  """
273
 
274
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
275
 
276
  # Generate the descriptive text using the model
277
- result = table_to_text(prompt, max_length=248, temperature=0.7, top_p = 0.9, do_sample=True)[0]['generated_text']
278
 
279
  return result
280
  # Global variable
 
26
  fin_model = pipeline("sentiment-analysis", model='yiyanghkust/finbert-tone', tokenizer='yiyanghkust/finbert-tone')
27
  fin_model_bis = pipeline("sentiment-analysis", model='ProsusAI/finbert', tokenizer='ProsusAI/finbert')
28
  table_to_text = pipeline('text2text-generation', model='google/flan-t5-large')
29
+ generator = pipeline('text-generation', model='mattshumer/Reflection-Llama-3.1-70B')
30
 
31
  def summarize_text(text):
32
  resp = summarizer(text)
 
271
  Make sure your description follows the example format and accurately reflects the data.
272
  """
273
 
274
+ prompt =
275
+ f"""
276
+ <thinking>
277
+ You are given data on adverse growth for a specific country and topic. Your task is to describe the data in a clear and accurate manner, following the example provided. Reflect on how the values change from year to year, and analyze whether there is an increase or decrease compared to previous years. Consider if these changes indicate a worsening or improvement and specify if the change is strong or slight. Include the cumulative result and ensure your description aligns with the given example format.
278
+ </thinking>
279
+
280
+ <output>
281
+ Here is an example of how to describe adverse growth data for a given country:
282
+
283
+ Country: Australia
284
+ Adverse 2020: -0.43%
285
+ Adverse 2021: -1.99%
286
+ Adverse 2022: -1.20%
287
+ Adverse Cumulative: -3.57%
288
+ Topic: GDP
289
+
290
+ Description:
291
+ In the adverse scenario, the GDP growth in Australia was -0.43% in 2020. It decreased further to -1.99% in 2021, showing worsening conditions. However, there was a slight improvement to -1.20% in 2022. The total cumulative adverse growth is -3.57%.
292
+
293
+ Now, using the following data for {theme} in {country}, perform the following:
294
+ 1. Highlight how the values change from year to year.
295
+ 2. Describe whether the values increased or decreased compared to the previous year.
296
+ 3. Indicate if the changes represent a worsening or improvement, and if this is strong or slight.
297
+ 4. Include the cumulative result.
298
+
299
+ Data:
300
+ {row_str}
301
+ Topic: {theme}
302
+ Make sure your description follows the example format and accurately reflects the data.
303
+ </output>
304
+ """
305
 
306
  # Generate the descriptive text using the model
307
+ result = table_to_text(prompt, max_length=248)[0]['generated_text']
308
 
309
  return result
310
  # Global variable