Khoi1234210 commited on
Commit
a07f719
·
verified ·
1 Parent(s): b8dcaff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -45
app.py CHANGED
@@ -12,55 +12,16 @@ math_samples = []
12
  loading_status = {"loaded": False, "error": None}
13
 
14
  def load_sample_problems():
15
- """Load sample problems asynchronously"""
16
  global math_samples, loading_status
17
- samples = []
18
 
19
- try:
20
- # GSM8K
21
- gsm8k = load_dataset("openai/gsm8k", "main", streaming=True, split="train")
22
- for i, item in enumerate(gsm8k):
23
- if i >= 30:
24
- break
25
- samples.append(item["question"])
26
-
27
- # Fineweb-edu
28
- fw = load_dataset("HuggingFaceFW/fineweb-edu", name="sample-10BT", split="train", streaming=True)
29
- fw_count = 0
30
- for item in fw:
31
- if fw_count >= 15:
32
- break
33
- text_lower = item['text'].lower()
34
- if any(w in text_lower for w in ['math', 'calculate', 'solve', 'equation']):
35
- q = item['text'][:120].strip()
36
- if len(q) > 20:
37
- samples.append(q + "...")
38
- fw_count += 1
39
-
40
- # Ultrachat
41
- ds = load_dataset("HuggingFaceH4/ultrachat_200k", streaming=True, split="train_sft")
42
- ds_count = 0
43
- for item in ds:
44
- if ds_count >= 15:
45
- break
46
- if len(item['messages']) > 0:
47
- content = item['messages'][0]['content'].lower()
48
- if any(w in content for w in ['math', 'solve', 'equation', 'calculate']):
49
- samples.append(item['messages'][0]['content'])
50
- ds_count += 1
51
-
52
- math_samples = samples if samples else get_fallback_samples()
53
- loading_status["loaded"] = True
54
- print(f"✅ Loaded {len(math_samples)} samples")
55
-
56
- except Exception as e:
57
- print(f"⚠️ Dataset error: {e}")
58
- math_samples = get_fallback_samples()
59
- loading_status["error"] = str(e)
60
- loading_status["loaded"] = True
61
 
62
  def get_fallback_samples():
63
- """Extended fallback problems"""
64
  return [
65
  "Find the derivative of f(x) = 3x² + 2x - 1",
66
  "A triangle has sides 5, 12, and 13. What is its area?",
@@ -77,6 +38,16 @@ def get_fallback_samples():
77
  "Solve x² - 4x + 4 = 0",
78
  "Find tan(π/4)",
79
  "What is 15% of 240?",
 
 
 
 
 
 
 
 
 
 
80
  ]
81
 
82
  # Start background loading
 
12
  loading_status = {"loaded": False, "error": None}
13
 
14
  def load_sample_problems():
15
+ """Load sample problems - using fallback only to avoid storage limits"""
16
  global math_samples, loading_status
 
17
 
18
+ # Skip dataset loading to avoid 50GB storage limit
19
+ math_samples = get_fallback_samples()
20
+ loading_status["loaded"] = True
21
+ print(f"✅ Loaded {len(math_samples)} fallback samples")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  def get_fallback_samples():
24
+ """Extended fallback problems covering diverse topics"""
25
  return [
26
  "Find the derivative of f(x) = 3x² + 2x - 1",
27
  "A triangle has sides 5, 12, and 13. What is its area?",
 
38
  "Solve x² - 4x + 4 = 0",
39
  "Find tan(π/4)",
40
  "What is 15% of 240?",
41
+ "Evaluate ∫x³ dx from 1 to 3",
42
+ "Find the slope of the line through (2,3) and (5,9)",
43
+ "Convert 45° to radians",
44
+ "Solve |2x - 5| = 7",
45
+ "Find the vertex of y = x² - 6x + 8",
46
+ "Calculate the discriminant of 2x² + 3x - 5 = 0",
47
+ "What is the standard deviation of [2, 4, 6, 8, 10]?",
48
+ "Simplify √(72)",
49
+ "Find cos(60°)",
50
+ "Solve the inequality 3x - 7 > 11",
51
  ]
52
 
53
  # Start background loading