ArumugaSelvi commited on
Commit
66364b2
·
verified ·
1 Parent(s): 38c6f6f

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +16 -20
src/streamlit_app.py CHANGED
@@ -1,5 +1,6 @@
1
  import streamlit as st
2
  import torch
 
3
  from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
4
 
5
  # ---------------- PAGE CONFIG ----------------
@@ -112,13 +113,18 @@ elif st.session_state.page == "main":
112
  bmi_status = bmi_category(bmi)
113
  equipment_list = ", ".join(equipment)
114
 
115
- # ---------------- UPDATED PROMPT ----------------
 
 
116
  prompt = f"""
117
  You are a certified professional fitness trainer.
118
 
 
 
119
  Generate a structured 5-day workout plan based on the following user profile.
120
 
121
  User Profile:
 
122
  - Gender: {gender}
123
  - BMI: {bmi:.2f} ({bmi_status})
124
  - Goal: {goal}
@@ -126,26 +132,15 @@ User Profile:
126
  - Available Equipment: {equipment_list}
127
 
128
  Instructions:
129
- 1. Divide the plan clearly into Day 1, Day 2, Day 3, Day 4, and Day 5.
130
  2. Under each day, list 4-6 exercises.
131
  3. For each exercise include:
132
  - Exercise Name
133
  - Sets
134
  - Reps
135
  - Rest Time
136
- 4. Keep exercises appropriate for the user’s fitness level.
137
- 5. Avoid medical or dietary advice.
138
- 6. Keep the output clean and structured.
139
- 7. Do NOT include explanations outside the workout plan.
140
-
141
- Format Example:
142
-
143
- Day 1: Upper Body Strength
144
-
145
- 1. Push-Ups
146
- Sets: 3
147
- Reps: 12
148
- Rest: 60 seconds
149
 
150
  Only return the workout plan.
151
  """
@@ -156,12 +151,13 @@ Only return the workout plan.
156
 
157
  outputs = model.generate(
158
  **inputs,
159
- max_new_tokens=350,
160
- temperature=0.7,
161
  do_sample=True,
162
- top_p=0.9,
163
- repetition_penalty=1.8,
164
- no_repeat_ngram_size=3
 
 
165
  )
166
 
167
  result = tokenizer.decode(outputs[0], skip_special_tokens=True).strip()
 
1
  import streamlit as st
2
  import torch
3
+ import random
4
  from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
5
 
6
  # ---------------- PAGE CONFIG ----------------
 
113
  bmi_status = bmi_category(bmi)
114
  equipment_list = ", ".join(equipment)
115
 
116
+ # Add randomness token to force variation
117
+ random_token = random.randint(1, 1000000)
118
+
119
  prompt = f"""
120
  You are a certified professional fitness trainer.
121
 
122
+ Random Seed: {random_token}
123
+
124
  Generate a structured 5-day workout plan based on the following user profile.
125
 
126
  User Profile:
127
+ - Name: {name}
128
  - Gender: {gender}
129
  - BMI: {bmi:.2f} ({bmi_status})
130
  - Goal: {goal}
 
132
  - Available Equipment: {equipment_list}
133
 
134
  Instructions:
135
+ 1. Divide the plan clearly into Day 1 to Day 5.
136
  2. Under each day, list 4-6 exercises.
137
  3. For each exercise include:
138
  - Exercise Name
139
  - Sets
140
  - Reps
141
  - Rest Time
142
+ 4. Keep exercises appropriate for fitness level.
143
+ 5. Do NOT include explanations outside workout plan.
 
 
 
 
 
 
 
 
 
 
 
144
 
145
  Only return the workout plan.
146
  """
 
151
 
152
  outputs = model.generate(
153
  **inputs,
154
+ max_new_tokens=400,
 
155
  do_sample=True,
156
+ temperature=0.9, # Increased randomness
157
+ top_p=0.95,
158
+ top_k=50,
159
+ repetition_penalty=1.5,
160
+ num_beams=1 # Important: disables deterministic beam search
161
  )
162
 
163
  result = tokenizer.decode(outputs[0], skip_special_tokens=True).strip()