Joash2024 commited on
Commit
c5de890
·
1 Parent(s): afb8fe5

fix: use simple pipeline with our fine-tuned model and A100

Browse files
Files changed (2) hide show
  1. README.md +28 -47
  2. app.py +10 -5
README.md CHANGED
@@ -1,65 +1,46 @@
1
  ---
2
- title: Math Problem Solver Demo
3
  emoji: 🧮
4
  colorFrom: blue
5
- colorTo: purple
6
  sdk: gradio
7
- sdk_version: 5.8.0
8
  app_file: app.py
9
  pinned: false
 
 
 
 
 
 
 
 
 
10
  ---
11
 
12
- # Mathematics Problem Solver Demo
13
 
14
- This demo showcases a comparison between base and fine-tuned language models in solving mathematical problems. It features real-time performance monitoring and supports multiple types of math problems.
15
 
16
- ## Models Used
17
-
18
- - Base Model: [LlaMA 3.2 1B](https://huggingface.co/Alexis-Az/Math-Problem-LlaMA-3.2-1B-GGUF)
19
- - Fine-tuned Model: [SmolLM2 1.7B](https://huggingface.co/Alexis-Az/Math-Problem-LlaMA-3.2-1.7B-GGUF)
20
 
21
  ## Features
22
 
23
- - 🔢 Multiple problem types:
24
- - Addition operations
25
- - Root finding
26
- - Derivatives
27
- - Custom problems
28
- - 📊 Real-time performance metrics:
29
  - Response times
30
  - Success rates
31
  - Problem type distribution
32
- - 🔄 Side-by-side model comparison
33
- - ⚡ Example problems included
34
-
35
- ## How to Use
36
-
37
- 1. Select a problem type from the dropdown menu
38
- 2. Enter your math problem in the input field
39
- 3. Click "Solve" to see solutions from both models
40
- 4. Compare the results and view performance metrics
41
-
42
- ## Example Problems
43
-
44
- Try these sample problems:
45
-
46
- - Derivative: "Find the derivative of x^2 + 3x"
47
- - Root Finding: "What is the square root of 144?"
48
- - Addition: "Calculate 235 + 567"
49
-
50
- ## Performance Monitoring
51
-
52
- The interface includes a live dashboard showing:
53
-
54
- - Average response times for each model
55
- - Success rates comparison
56
- - Distribution of problem types solved
57
- - Real-time performance metrics
58
-
59
- ## Project Details
60
-
61
- This demo is part of a larger project comparing LLM performance on mathematical problems. The models have been fine-tuned on a custom dataset of mathematical problems to improve their problem-solving capabilities.
62
 
63
- ## Credits
64
 
65
- Models provided by [Alexis-Az](https://huggingface.co/Alexis-Az)
 
 
 
 
1
  ---
2
+ title: Mathematics Problem Solver
3
  emoji: 🧮
4
  colorFrom: blue
5
+ colorTo: green
6
  sdk: gradio
7
+ sdk_version: 4.8.0
8
  app_file: app.py
9
  pinned: false
10
+ hardware:
11
+ accelerator: a100
12
+ gpu: true
13
+ python_packages:
14
+ - "torch>=2.0.0"
15
+ - "transformers>=4.30.0"
16
+ - "accelerate>=0.20.0"
17
+ - "peft==0.5.0"
18
+ - "numpy>=1.21.0"
19
  ---
20
 
21
+ # Mathematics Problem Solver
22
 
23
+ This Space demonstrates our fine-tuned math model for solving various mathematical problems, with a focus on derivatives. Compare solutions between:
24
 
25
+ 1. Base Model: HuggingFaceTB/SmolLM2-1.7B-Instruct
26
+ 2. Our Fine-tuned Model: Joash2024/Math-SmolLM2-1.7B
 
 
27
 
28
  ## Features
29
 
30
+ - Side-by-side comparison of base and fine-tuned models
31
+ - Performance monitoring:
 
 
 
 
32
  - Response times
33
  - Success rates
34
  - Problem type distribution
35
+ - Support for various problems:
36
+ - Derivatives
37
+ - Addition
38
+ - Roots
39
+ - Custom problems
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
+ ## Technical Details
42
 
43
+ - A100 GPU acceleration
44
+ - Float16 precision for efficient inference
45
+ - LaTeX notation support
46
+ - Real-time performance tracking
app.py CHANGED
@@ -5,8 +5,8 @@ import numpy as np
5
  from monitoring import PerformanceMonitor, measure_time
6
 
7
  # Model IDs
8
- BASE_MODEL_ID = "Alexis-Az/Math-Problem-LlaMA-3.2-1B-GGUF"
9
- FINETUNED_MODEL_ID = "Alexis-Az/Math-Problem-LlaMA-3.2-1.7B-GGUF"
10
 
11
  # Initialize performance monitor
12
  monitor = PerformanceMonitor()
@@ -92,7 +92,7 @@ def solve_problem(problem, problem_type):
92
  # Create Gradio interface
93
  with gr.Blocks(title="Mathematics Problem Solver") as demo:
94
  gr.Markdown("# Mathematics Problem Solver")
95
- gr.Markdown("Compare solutions between base (1B) and fine-tuned (1.7B) models")
96
 
97
  with gr.Row():
98
  with gr.Column():
@@ -109,11 +109,11 @@ with gr.Blocks(title="Mathematics Problem Solver") as demo:
109
 
110
  with gr.Row():
111
  with gr.Column():
112
- gr.Markdown("### Base Model (1B)")
113
  base_output = gr.Textbox(label="Base Model Solution", lines=5)
114
 
115
  with gr.Column():
116
- gr.Markdown("### Fine-tuned Model (1.7B)")
117
  finetuned_output = gr.Textbox(label="Fine-tuned Model Solution", lines=5)
118
 
119
  # Performance metrics display
@@ -126,6 +126,11 @@ with gr.Blocks(title="Mathematics Problem Solver") as demo:
126
  ["Find the derivative of x^2 + 3x", "Derivative"],
127
  ["What is the square root of 144?", "Root Finding"],
128
  ["Calculate 235 + 567", "Addition"],
 
 
 
 
 
129
  ],
130
  inputs=[problem_input, problem_type],
131
  outputs=[base_output, finetuned_output, metrics_display],
 
5
  from monitoring import PerformanceMonitor, measure_time
6
 
7
  # Model IDs
8
+ BASE_MODEL_ID = "HuggingFaceTB/SmolLM2-1.7B-Instruct" # Base model
9
+ FINETUNED_MODEL_ID = "Joash2024/Math-SmolLM2-1.7B" # Our fine-tuned model
10
 
11
  # Initialize performance monitor
12
  monitor = PerformanceMonitor()
 
92
  # Create Gradio interface
93
  with gr.Blocks(title="Mathematics Problem Solver") as demo:
94
  gr.Markdown("# Mathematics Problem Solver")
95
+ gr.Markdown("Compare solutions between base and fine-tuned models")
96
 
97
  with gr.Row():
98
  with gr.Column():
 
109
 
110
  with gr.Row():
111
  with gr.Column():
112
+ gr.Markdown("### Base Model")
113
  base_output = gr.Textbox(label="Base Model Solution", lines=5)
114
 
115
  with gr.Column():
116
+ gr.Markdown("### Fine-tuned Model")
117
  finetuned_output = gr.Textbox(label="Fine-tuned Model Solution", lines=5)
118
 
119
  # Performance metrics display
 
126
  ["Find the derivative of x^2 + 3x", "Derivative"],
127
  ["What is the square root of 144?", "Root Finding"],
128
  ["Calculate 235 + 567", "Addition"],
129
+ ["\\sin{\\left(x\\right)}", "Derivative"],
130
+ ["e^x", "Derivative"],
131
+ ["\\frac{1}{x}", "Derivative"],
132
+ ["x^3 + 2x", "Derivative"],
133
+ ["\\cos{\\left(x^2\\right)}", "Derivative"]
134
  ],
135
  inputs=[problem_input, problem_type],
136
  outputs=[base_output, finetuned_output, metrics_display],