Chat session example using Ollama's Python API and DeepSeek-R1 1.5B model.
Reasoning prompts with context are stored in `PROMPTS` list in the `main.py` script.
These were selected from some recommendations by OpenAI's ChatGPT.
- [Installation](#installation)
- [Run chat session](#run-chat-session)
- [Result](#result)
- [Simple mathematics](#simple-mathematics)
- [Simple mathematics problem with history](#simple-mathematics-problem-with-history)
- [Mathematical reasoning](#mathematical-reasoning)
- [Mathematical reasoning with history](#mathematical-reasoning-with-history)
- [Logical deduction](#logical-deduction)
- [Coding problem](#coding-problem)
- [Physics problem](#physics-problem)
- [Pattern recognition](#pattern-recognition)
- [Observations](#observations)
# Installation
Follow the steps in the [top level README](/README.md#installation) to create
a virtual environment and install the packages.
# Run chat session
Run these commands.
```bash
cd
source ./venv_ollama/bin/activate
cd deepseek_opi5plus/chat
python3 main.py
```
# Result
Chat session details.
* OrangePi 5 single board computer with 8GB RAM.
* Used hardware thermal cooling (SoC heatsink and small fan) to mitigate model slowing down due to clock throttling under CPU load.
* Some issues with model responses were seen and discussed in a [later section](#observations) in this README.
## Simple mathematics
```console
(venv_ollama) orangepi@orangepi5-desktop:~/deepseek_opi5plus/chat$ python3 main.py
Model: deepseek-r1:1.5b
Prompt: What is the sum of 3 + 2?
<think>
I need to calculate the sum of 3 and 2.
First, I'll add 3 and 2 together.
Finally, I'll determine that the result is 5.
</think>
```
**Solution:**
To find the sum of \(3 + 2\), follow these simple steps:
1. **Addition Operation:**
\[
3 + 2 = 5
\]
Therefore, the final answer is:
\[
\boxed{5}
\]
```console
Last response:
Duration: 14.6s
Tokens: 103
Speed: 7.0 tokens/s
Session total:
Duration: 14.6s
Tokens: 103
Average speed: 7.0 tokens/s
```
## Simple mathematics problem with history
The prompt continues requiring history from the previous prompt.
```console
Prompt: What is the result if +1 is added to both numbers before summing them?
<think>
</think>
```
To find the result of adding 1 to each number before performing the sum, let's follow these steps:
1. **Add 1 to Each Number:**
\[
3 + 1 = 4
\]
\[
2 + 1 = 3
\]
2. **Sum the Modified Numbers:**
\[
4 + 3 = 7
\]
**Final Answer:**
\[
\boxed{7}
\]
```console
Last response:
Duration: 16.6s
Tokens: 109
Speed: 6.6 tokens/s
Session total:
Duration: 31.2s
Tokens: 212
Average speed: 6.8 tokens/s
```
> The model's answer was correct. However the response failed to include
> reasoning on this particular run inside the `<think>` tags.
## Mathematical reasoning
```console
Prompt: A car travels 60 miles in 1 hour. It then travels an additional 90 miles in 2 hours. What is the car's average speed for the entire trip?
<think>
Okay, so I have this problem about a car's average speed during a trip. Let me try to figure it out step by step.
First, let's understand what average speed means. If something travels more distance over less time, its average speed is higher. So, in this case, the car goes farther and takes longer to do so than before. But I need to calculate the exact average speed for the entire trip.
The problem states:
- The car travels **60 miles** in **1 hour**.
- Then it travels **90 miles** in **2 hours**.
Wait a minute, that seems like the car first goes 60 miles quickly and then takes twice as long but covers more ground. So overall, I need to consider both distances and times together to find the average speed for the whole trip.
I remember that average speed is calculated by dividing the total distance traveled by the total time taken. That makes sense because you're spreading out the speeds over a longer period.
Let me write down the information:
- **First leg:**
- Distance = 60 miles
- Time = 1 hour
- **Second leg:**
- Distance = 90 miles
- Time = 2 hours
**Step 1: Calculate Total Distance**
The total distance is the sum of both legs:
\[
\text{Total Distance} = 60 \text{ miles} + 90 \text{ miles} = 150 \text{ miles}
\]
**Step 2: Calculate Total Time**
The total time is the sum of the times for each leg:
\[
\text{Total Time} = 1 \text{ hour} + 2 \text{ hours} = 3 \text{ hours}
\]
**Step 3: Calculate Average Speed**
Now, divide the total distance by the total time to find the average speed:
\[
\text{Average Speed} = \frac{\text{Total Distance}}{\text{Total Time}} = \frac{150 \text{ miles}}{3 \text{ hours}} = 50 \text{ miles per hour (mph)}
\]
**Verification:**
Let me double-check the calculations to ensure there's no mistake.
- **First leg:** 60 miles in 1 hour means a speed of 60 mph.
- **Second leg:** 90 miles in 2 hours means a speed of 45 mph.
- Total distance = 150 miles, total time = 3 hours.
- Average speed = 150 / 3 = 50 mph.
Yes, that seems correct. The car's overall average speed for the entire trip is **50 miles per hour**.
\[
\boxed{50 \text{ miles per hour}}
\]
```
```console
Last response:
Duration: 88.9s
Tokens: 590
Speed: 6.6 tokens/s
Session total:
Duration: 120.1s
Tokens: 802
Average speed: 6.7 tokens/s
```
> The model's produced the expected result. However the response failed to
> close the `<\think>` tag on this particular run.
## Mathematical reasoning with history
Requires knowledge of the previous prompt.
```console
Prompt: What if the car had traveled 30 miles in the first hour instead of 60 miles?
<think>
Okay, let me think about this problem. So, originally, the car traveled 60 miles in one hour and then an additional 90 miles in two hours. The question is asking what happens to the average speed if the car had traveled 30 miles in the first hour instead of 60 miles.
First, I need to understand what average speed means. Average speed is calculated by dividing the total distance traveled by the total time taken for the trip. So, it's essentially how fast the car was going on average over the entire journey.
Let me break down the original scenario:
- **First leg:**
- Distance = 60 miles
- Time = 1 hour
- **Second leg:**
- Distance = 90 miles
- Time = 2 hours
So, total distance = 60 + 90 = 150 miles
Total time = 1 + 2 = 3 hours
Therefore, original average speed = Total Distance / Total Time = 150 miles / 3 hours = 50 mph.
Now, the modified scenario is:
- **First leg:**
- Distance = 30 miles
- Time = 1 hour
- **Second leg:**
- Distance = 90 miles
- Time = 2 hours
Calculating total distance and time again:
Total distance = 30 + 90 = 120 miles
Total time = 1 + 2 = 3 hours
Therefore, new average speed = Total Distance / Total Time = 120 miles / 3 hours = 40 mph.
Wait a minute. That seems different from the original average speed of 50 mph. Did I make a mistake here?
Let me double-check:
Original:
- First leg: 60 miles in 1 hour
- Second leg: 90 miles in 2 hours
Total distance = 150 miles, Total time = 3 hours → Average speed = 50 mph.
Modified:
- First leg: 30 miles in 1 hour
- Second leg: 90 miles in 2 hours
Total distance = 120 miles, Total time = 3 hours → Average speed = 40 mph.
Yes, the average speed decreases from 50 mph to 40 mph. That makes sense because the car traveled less distance in the first hour, even though it took the same total time for both legs.
Let me think if there's another way to approach this problem. Maybe by calculating the speeds for each leg and then averaging them differently?
Original:
- First leg speed = 60 miles / 1 hour = 60 mph
- Second leg speed = 90 miles / 2 hours = 45 mph
If we just took the average of these two speeds: (60 + 45) / 2 = 52.5 mph.
But that doesn't match with either scenario, and also, it's not considering