Barisha commited on
Commit
862915a
·
verified ·
1 Parent(s): b123e5c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -6
app.py CHANGED
@@ -13,7 +13,7 @@ generator = pipeline(
13
  )
14
 
15
  # ------------------------------------------------
16
- # Fact quantization (GENERIC)
17
  # ------------------------------------------------
18
  def magnitude_bucket(x):
19
  if x < 0.05:
@@ -79,7 +79,8 @@ def analyze_kpi(csv_file, top_n):
79
  other_facts = None
80
 
81
  # -------------------------------
82
- # Model input = PURE FACTS
 
83
  # -------------------------------
84
  model_input = (
85
  "Write a short insight-style summary using only the facts below.\n\n"
@@ -89,26 +90,38 @@ def analyze_kpi(csv_file, top_n):
89
  f"{other_facts}"
90
  )
91
 
 
 
 
92
  output = generator(
93
  model_input,
94
  max_new_tokens=120,
95
- do_sample=False
 
 
 
96
  )[0]["generated_text"]
97
 
98
  return ranked.head(top_n)[["Kpi", "abs_diff"]], output
99
 
100
  # ------------------------------------------------
101
- # UI (HF Space)
102
  # ------------------------------------------------
103
  with gr.Blocks(title="Network Insight Summary") as demo:
104
  gr.Markdown("## 📊 Network Insight Summary")
105
  gr.Markdown(
106
  "Upload KPI CSV to generate a concise, insight-style summary "
107
- "focused on the most significant KPI changes."
108
  )
109
 
110
  csv_input = gr.File(file_types=[".csv"])
111
- top_n_input = gr.Slider(3, 6, value=5, step=1, label="KPIs to Display")
 
 
 
 
 
 
112
 
113
  btn = gr.Button("Generate Insight")
114
 
 
13
  )
14
 
15
  # ------------------------------------------------
16
+ # Generic fact quantization (NO domain logic)
17
  # ------------------------------------------------
18
  def magnitude_bucket(x):
19
  if x < 0.05:
 
79
  other_facts = None
80
 
81
  # -------------------------------
82
+ # Model input = FACT BLOCK ONLY
83
+ # (no narrative text embedded)
84
  # -------------------------------
85
  model_input = (
86
  "Write a short insight-style summary using only the facts below.\n\n"
 
90
  f"{other_facts}"
91
  )
92
 
93
+ # -------------------------------
94
+ # Controlled variation generation
95
+ # -------------------------------
96
  output = generator(
97
  model_input,
98
  max_new_tokens=120,
99
+ do_sample=True,
100
+ temperature=0.6,
101
+ top_p=0.85,
102
+ repetition_penalty=1.1
103
  )[0]["generated_text"]
104
 
105
  return ranked.head(top_n)[["Kpi", "abs_diff"]], output
106
 
107
  # ------------------------------------------------
108
+ # Gradio UI (Hugging Face Space)
109
  # ------------------------------------------------
110
  with gr.Blocks(title="Network Insight Summary") as demo:
111
  gr.Markdown("## 📊 Network Insight Summary")
112
  gr.Markdown(
113
  "Upload KPI CSV to generate a concise, insight-style summary "
114
+ "highlighting the most significant KPI changes."
115
  )
116
 
117
  csv_input = gr.File(file_types=[".csv"])
118
+ top_n_input = gr.Slider(
119
+ minimum=3,
120
+ maximum=6,
121
+ value=5,
122
+ step=1,
123
+ label="KPIs to Display"
124
+ )
125
 
126
  btn = gr.Button("Generate Insight")
127