# !pip3 install -U openai
# !pip3 install -U anthropic
# !pip3 install -U google-genai
DeepSeek Reasoner
- Claude 3.5 sonnet does not have reasoning capabilities, so in this blog post, we extract thinking steps from deepseek and gemini and pass it to claude 3.5 sonnet to behave like a reasoning model
- DeepSeek Reasoner is a specialized reasoning model that implements Chain of Thought (CoT) reasoning. Before providing a final answer, it generates detailed reasoning steps to enhance accuracy.
- Key features of DeepSeek Reasoner:
- Supports up to 64K context length
- CoT output can reach up to 32K tokens
- Final response can be up to 8K tokens (default 4K)
- Provides both reasoning_content (CoT steps) and content (final answer)
- Supports chat completion and chat prefix completion
- Does not support function calling, JSON output, or FIM
- Temperature and other sampling parameters are not supported
- In multi-round conversations, previous CoT steps are not included in the context
- The model requires the latest OpenAI SDK for proper functionality
- API access requires a DeepSeek API key and uses a custom base URL
Gemini 2.0 Flash Thinking is an experimental model that explicitly showcases its thoughts and reasoning process
- Gemini 2.0 Flash Thinking is built on the speed and performance of Gemini 2.0 Flash, specifically trained to use thoughts for enhanced reasoning
- Key features of Gemini Thinking Model:
- Exposes internal thought process through the ‘thought’ flag in responses
- Built on Gemini 2.0 Flash architecture for fast performance
- Optimized for complex tasks requiring multiple rounds of strategizing
- Supports multimodal reasoning (can think about text, images, and code)
- Available through v1alpha API version
- Requires ‘thinking_config’ with ‘include_thoughts: True’ to expose reasoning
- Response contains separate parts for thoughts and final answer
- More consistent answers due to explicit reasoning steps
- Technical requirements:
- Requires google-genai SDK version >= 0.6.0
- API access requires a Google API key
- Must use v1alpha API version to access thinking features
- Thoughts can be accessed through response.candidates[0].content.parts with thought flag
Install the required libraries and load the environment variables
from dotenv import load_dotenv
import os
load_dotenv()
True
= os.getenv("DEEPSEEK_API_KEY")
deepseek_api_key = os.getenv("GEMINI_API_KEY")
gemini_api_key = os.getenv("ANTHROPIC_API_KEY") anthropic_api_key
How to use DeepSeek Reasoning Model
from openai import OpenAI
= OpenAI(api_key=deepseek_api_key, base_url="https://api.deepseek.com")
client
# Round 1
= [{"role": "user", "content": "9.11 and 9.8, which is greater?"}]
messages = client.chat.completions.create(
response ="deepseek-reasoner",
model=messages
messages
)
= response.choices[0].message.reasoning_content
reasoning_content_deepseek = response.choices[0].message.content content_deepseek
from IPython.display import Markdown
display(Markdown(reasoning_content_deepseek))
Okay, so I need to figure out whether 9.11 is greater than 9.8 or if 9.8 is greater than 9.11. Let me start by recalling how decimal numbers work. The digits to the left of the decimal point represent whole numbers, and the digits to the right represent fractions of a whole number. In this case, both numbers have 9 in the ones place, so they’re both between 9 and 10.
Since the whole number parts are the same (both are 9), I need to compare the decimal parts: .11 and .8. Hmm, but wait, .8 is the same as .80, right? Because adding a zero at the end of a decimal doesn’t change its value. So, if I rewrite 9.8 as 9.80, then it’s easier to compare with 9.11.
Now, looking at the tenths place: in 9.11, the tenths digit is 1, and in 9.80, the tenths digit is 8. Since 8 is greater than 1, that means 9.80 has a larger tenths value than 9.11. Therefore, 9.80 (which is the same as 9.8) is greater than 9.11.
Wait a second, let me verify that again. If I convert both numbers to fractions, maybe that’ll help. 9.11 is 9 + 11/100, and 9.8 is 9 + 8/10. To compare 11/100 and 8/10, I can convert them to have the same denominator. 8/10 is equal to 80/100. Now, comparing 11/100 and 80/100, it’s clear that 80/100 is larger. So again, 9.8 is greater.
Alternatively, I can subtract one from the other to see which is larger. Let’s subtract 9.11 from 9.8. 9.8 minus 9.11. Aligning the decimals:
9.80
-9.11
------
0.69
The result is 0.69, which is positive, meaning 9.8 is larger by 0.69. So that confirms it again.
Another way to think about it is by considering money. If these are amounts of money, $9.11 versus $9.80. Clearly, $9.80 is more because 80 cents is more than 11 cents. That makes sense.
Wait, but sometimes people might get confused because 9.11 has two digits after the decimal and 9.8 only has one. Maybe someone might think 9.11 is more because there are more digits? But no, the place value matters. The first digit after the decimal is tenths, the second is hundredths. So 9.11 is 9 + 1/10 + 1/100, whereas 9.8 is 9 + 8/10. Even though 9.11 has two digits, the tenths place is much lower (1 vs 8), so 9.8 is definitely larger.
I think I’ve covered multiple methods: converting to fractions with common denominators, subtracting, using money as an analogy, and considering place value. All of them lead to the same conclusion that 9.8 is greater than 9.11. I can’t think of a method where 9.11 would come out as greater. Maybe if someone incorrectly compares the numbers digit by digit without considering place value? For example, looking at 9.11 vs 9.8 and comparing the first digit after the decimal (1 vs 8) and stopping there, but no, even that would show 8 is bigger. Wait, actually, if someone compares 9.11 and 9.8 as strings, like in a dictionary, then “9.11” comes before “9.8” because 1 is less than 8 in the tenths place. But mathematically, that’s not the correct way because the number of digits after the decimal doesn’t affect the value in that way.
Alternatively, if someone pads 9.8 with a zero to make it 9.80, then compares digit by digit:
- Units place: 9 vs 9 (same)
- Tenths place: 1 vs 8 (8 is bigger)
- Hundredths place: 1 vs 0 (1 is bigger, but since the tenths place was already larger, 9.80 is still greater overall)
So even if you go digit by digit, once you find a place where one number is larger, you can stop. So the tenths place decides it here.
Therefore, all methods confirm that 9.8 is greater than 9.11. I don’t see any other angles here. It’s a common decimal comparison problem where ensuring both numbers have the same number of decimal places helps avoid confusion.
Final Answer The greater number is .
display(Markdown(content_deepseek))
To determine whether 9.11 or 9.8 is greater, we start by comparing the whole number parts, which are both 9. Next, we compare the decimal parts.
First, we rewrite 9.8 as 9.80 to have the same number of decimal places as 9.11. Now, we compare the tenths place: 1 (from 9.11) vs. 8 (from 9.80). Since 8 is greater than 1, 9.80 is greater than 9.11.
To verify, we can convert the decimals to fractions: - 9.11 = 9 + 11/100 - 9.8 = 9 + 8/10 = 9 + 80/100
Comparing 11/100 and 80/100, we see 80/100 is larger, confirming 9.8 is greater.
Subtracting 9.11 from 9.8: [ \[\begin{array}{r} 9.80 \\ -9.11 \\ \hline 0.69 \\ \end{array}\]] The positive result (0.69) shows 9.8 is greater.
Considering place value and money analogy, 80 cents (from 9.80) is more than 11 cents (from 9.11), confirming 9.8 is greater.
Thus, the greater number is .
How to Use Gemini Reasoning Models
import google.genai as genai
= genai.Client(
client =gemini_api_key,
api_key={'api_version':'v1alpha'}, # Required for thinking mode
http_options
)
# Round 1
= client.models.generate_content(
response ="gemini-2.0-flash-thinking-exp-01-21",
model={'thinking_config': {'include_thoughts': True}},
config="9.11 and 9.8, which is greater?"
contents
)
# Extract reasoning and final answer
= ""
reasoning_content_gemini = ""
content_gemini
for part in response.candidates[0].content.parts:
if part.thought:
= part.text
reasoning_content_gemini else:
= part.text
content_gemini
# Display results using Markdown
display(Markdown(reasoning_content_gemini))
Understand the question: The question is asking to compare two decimal numbers, 9.11 and 9.8, and determine which one is greater.
Compare the whole number part: Both numbers have the same whole number part, which is 9. Since the whole number parts are equal, we need to compare the decimal parts.
Compare the decimal parts digit by digit:
- First decimal place: In 9.11, the first decimal digit is 1. In 9.8, the first decimal digit is 8.
- Compare the first decimal digits: 1 and 8. 8 is greater than 1.
Conclusion: Since the first decimal digit of 9.8 (which is 8) is greater than the first decimal digit of 9.11 (which is 1), we can conclude that 9.8 is greater than 9.11.
Optional: Visualize on a number line: Imagine a number line. 9.11 is slightly to the right of 9, and 9.8 is further to the right of 9.11. Numbers further to the right on the number line are greater.
Optional: Add a zero to make the decimal parts have the same number of digits: We can write 9.8 as 9.80. Now we are comparing 9.11 and 9.80. Comparing the decimal parts 11 and 80, it’s clear that 80 is greater than 11. Therefore, 9.80 is greater than 9.11, which means 9.8 is greater than 9.11.
State the answer: 9.8 is greater than 9.11. To answer the question “which is greater?”, the answer is 9.8.
display(Markdown(content_gemini))
To determine which number is greater between 9.11 and 9.8, we can compare them by looking at their decimal places.
First, let’s compare the whole number part. Both numbers have the same whole number part, which is 9.
Next, we compare the decimal parts. For 9.11, the decimal part is .11. For 9.8, the decimal part is .8.
To easily compare the decimal parts, we can make them have the same number of decimal places. We can write 9.8 as 9.80, so it has two decimal places, just like 9.11.
Now we compare 9.11 and 9.80. Comparing the tenths place: In 9.11, the tenths digit is 1. In 9.80, the tenths digit is 8. Since 8 is greater than 1, 9.80 is greater than 9.11.
Therefore, 9.8 is greater than 9.11.
Alternatively, we can think of this in terms of fractions or place values. 9.11 is equal to 9 + 0.11, which is 9 + 11/100. 9.8 is equal to 9 + 0.8, which is 9 + 8/10, which is 9 + 80/100.
Comparing 11/100 and 80/100, it’s clear that 80/100 is greater than 11/100. Thus, 9 + 80/100 is greater than 9 + 11/100, meaning 9.8 is greater than 9.11.
Answer: 9.8 is greater.
Using Gemini and DeepSeek thinking steps on Anthropic Models
# Combine thinking steps and pass to Claude
import anthropic
= anthropic.Anthropic()
claude_client = """You are an advanced reasoning model that utilizes thinking steps from multiple AI models to provide accurate answers.
system_message You will receive reasoning steps from DeepSeek and Gemini models, and you should use these steps to formulate your own response.
Use the thinking steps to provide a final answer.While answering, no need to say you are using thinking steps."""
= claude_client.messages.create(
message ="claude-3-5-sonnet-20241022",
model=1000,
max_tokens=0,
temperature=system_message,
system=[
messages
{"role": "user",
"content": [
{"type": "text",
"text": f"""Question: Which number is greater between 9.11 and 9.8:
DeepSeek's reasoning:
{reasoning_content_deepseek}
Gemini's reasoning:
{reasoning_content_gemini}
"""
}
]
}
]
)
# Display Claude's response
from IPython.display import Markdown
0].text)) display(Markdown(message.content[
9.8 is greater than 9.11.
To understand this, let’s look at the decimal parts since both numbers have the same whole number (9). In 9.8, the first decimal place is 8 tenths, while in 9.11, it’s only 1 tenth. Since 8 tenths is greater than 1 tenth, we can immediately determine that 9.8 is the larger number.
We can also write 9.8 as 9.80 (adding a zero doesn’t change the value) to make it clearer. Now comparing 9.80 with 9.11, we can see that 80 hundredths is greater than 11 hundredths.
Therefore, 9.8 is the greater number.