Spaces:
Sleeping
Sleeping
File size: 6,191 Bytes
1293cde | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | # Word Problem Handling Strategy
## Overview
meeTARA Agent handles word problems differently based on their complexity and type:
## Three Types of Word Problems
### 1. **Simple Math Word Problems** β **Calculator** β
**Examples:**
- "What's 15% of 340?" β Extracted as `0.15 * 340` β Calculator calculates
- "Find 25 * 48" β Calculator handles directly
- "Calculate tan(45)" β Scientific function β Calculator
**Why Calculator:**
- Clear mathematical expression can be extracted via pattern matching
- Calculator ensures 100% accuracy
- Fast and efficient
### 2. **Complex Word Problems** β **Model Directly** β
**Examples:**
- "If John has 5 apples and gives 2 away, how many does he have left?"
- "A train travels 60 miles in 2 hours. What's its speed?"
- "Sarah buys 3 books at $10 each and 2 pens at $5 each. How much did she spend?"
- "If a rectangle has length 6 cm and width 4 cm, what's its area?" (geometry - has keywords)
**Why Model Directly:**
- Requires understanding relationships between entities (John, apples, gives away)
- Need to extract formula from context (speed = distance/time)
- Need to combine multiple operations (3 books Γ $10 + 2 pens Γ $5)
- Model can understand natural language relationships and extract math
- Calculator would need perfect extraction, which is hard for complex relationships
**Detection:**
- Uses `word_problem_keywords` from config: "if", "has", "gives", "travels", "buys", "costs", etc.
- Strategy: `model_direct` (configurable in `agent_config.json`)
- Skips calculator if complex word problem detected β Sends directly to model
### 3. **Word Problems About Current Events/Data** β **Web Search + Model** β
**Examples:**
- "What's the current unemployment rate in the US?"
- "What's the current price of Bitcoin?"
- "What's today's stock market performance?"
**Why Web Search:**
- Requires up-to-date information beyond training data
- Real-time data that changes frequently
- Web search provides current data β Model structures response
## Configuration
All word problem handling is configurable in `config/agent_config.json`:
```json
{
"calculator": {
"word_problem_keywords": [
"if", "when", "has", "gives", "receives", "buys", "sells",
"travels", "drives", "costs", "price", "total", "spends",
"left", "remaining", "more than", "less than", "times"
],
"word_problem_strategy": "model_direct",
"word_problem_explanation": "Simple word problems handled by calculator. Complex word problems go to model. Current events go to web search."
}
}
```
## Decision Flow
```
User Query: Word Problem
β
Check if contains word_problem_keywords (if, has, gives, etc.)
β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β Is it about current events/data? β
β β Contains "current", "today", "latest", etc. β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
YES β Web Search β Model
NO β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β Can math be extracted via patterns? β
β β "15% of 340" β 0.15 * 340 β β
β β "tan(45)" β tan(45) β β
β β "25 * 48" β 25 * 48 β β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
YES β Calculator β Model
NO β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β Is it a complex word problem? β
β β Contains relationship keywords β
β β No clear math expression extractable β
βββββββββββββββββββββββββββββββββββββββββββββββββββ
YES β Model Directly (skip calculator)
NO β Model Directly (fallback)
```
## Examples
### Example 1: Simple β Calculator
**Query:** "What's 15% of 340?"
- Detection: Percentage pattern matched
- Extraction: `0.15 * 340`
- Calculator: `51`
- Model: Structures response with steps
### Example 2: Complex β Model Directly
**Query:** "If John has 5 apples and gives 2 away, how many does he have left?"
- Detection: Contains word_problem_keywords ("if", "has", "gives", "left")
- Complex word problem: Yes (requires understanding relationships)
- Calculator: Skipped (no clear expression to extract)
- Model: Understands relationship β Extracts: 5 - 2 = 3 β Responds
### Example 3: Current Events β Web Search
**Query:** "What's the current unemployment rate?"
- Detection: Contains "current" β Web search keyword
- Web Search: Fetches current data
- Model: Structures response with current data
### Example 4: Geometry β Full Query to Model
**Query:** "Find the surface area of a rectangular prism with dimensions: length = 6 cm, width = 4 cm, height = 5 cm"
- Detection: Geometry keywords ("surface area", "rectangular prism")
- Calculator: Receives full query (not just numbers)
- Calculator: Detects geometry β Returns context message
- Model: Calculates using formula 2(lw + lh + wh) = 148 cmΒ²
## Recommendations
1. **Simple Math** β Calculator (100% accurate, fast)
2. **Complex Word Problems** β Model (understands relationships, extracts math)
3. **Current Events** β Web Search (up-to-date data)
4. **Geometry** β Full query to calculator/model (needs formula context)
## Why This Strategy Works
- **Calculator** = Perfect for clear math expressions (ensures accuracy)
- **Model** = Perfect for understanding relationships and extracting formulas
- **Web Search** = Perfect for current/realtime data
- **Combination** = Best of all worlds (tool precision + model understanding + current data)
|