Upload continuous_learning_session.py
Browse files
continuous_learning_session.py
CHANGED
|
@@ -181,7 +181,7 @@ class ContinuousLearningSession:
|
|
| 181 |
# max_length=Config.MAX_LENGTH, # Removed as per diff
|
| 182 |
do_sample=True,
|
| 183 |
temperature=0.7, # Changed from 0.6 to 0.7
|
| 184 |
-
repetition_penalty=1.
|
| 185 |
pad_token_id=self.model.tokenizer.eos_token_id
|
| 186 |
)
|
| 187 |
|
|
@@ -237,10 +237,20 @@ class ContinuousLearningSession:
|
|
| 237 |
current_q = line.split(":", 1)[1].strip()
|
| 238 |
elif line.startswith("A") and ":" in line and current_q:
|
| 239 |
current_a = line.split(":", 1)[1].strip()
|
| 240 |
-
|
|
|
|
|
|
|
| 241 |
current_q = None
|
| 242 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
print(f" ✨ Generated {len(variations)-1} synthetic variations.")
|
|
|
|
|
|
|
|
|
|
| 244 |
return variations
|
| 245 |
|
| 246 |
def learn(self, user_input: str, correct_answer: str, concept_id: str = "general"):
|
|
|
|
| 181 |
# max_length=Config.MAX_LENGTH, # Removed as per diff
|
| 182 |
do_sample=True,
|
| 183 |
temperature=0.7, # Changed from 0.6 to 0.7
|
| 184 |
+
repetition_penalty=1.0, # Reset to default (was 1.2) to fix silence
|
| 185 |
pad_token_id=self.model.tokenizer.eos_token_id
|
| 186 |
)
|
| 187 |
|
|
|
|
| 237 |
current_q = line.split(":", 1)[1].strip()
|
| 238 |
elif line.startswith("A") and ":" in line and current_q:
|
| 239 |
current_a = line.split(":", 1)[1].strip()
|
| 240 |
+
# Validation: Ensure neither Q nor A is empty
|
| 241 |
+
if current_q and current_a:
|
| 242 |
+
variations.append({"q": current_q, "a": current_a})
|
| 243 |
current_q = None
|
| 244 |
|
| 245 |
+
# Fallback: If synthetic generation failed, duplicate original
|
| 246 |
+
if len(variations) == 1:
|
| 247 |
+
print(" ⚠️ Synthetic generation failed to produce valid format. Duplicating original.")
|
| 248 |
+
variations.append({"q": question, "a": answer})
|
| 249 |
+
|
| 250 |
print(f" ✨ Generated {len(variations)-1} synthetic variations.")
|
| 251 |
+
for i, v in enumerate(variations):
|
| 252 |
+
print(f" [{i}] Q: {v['q'][:30]}... A: {v['a'][:30]}...")
|
| 253 |
+
|
| 254 |
return variations
|
| 255 |
|
| 256 |
def learn(self, user_input: str, correct_answer: str, concept_id: str = "general"):
|