smartcat icon indicating copy to clipboard operation
smartcat copied to clipboard

[Feature Requests] Filter out reasoning part of reasoning models

Open TotalKrill opened this issue 11 months ago • 3 comments

First of all, nice software!

The reasoning models like deepseek-r1 seems to put out a lot of reasoning gak that isnt really useful for smartcat usage.

basically it outputs something like this regardless of its prompt:

<think>
I am a smart smart bot, have to think really hard on the given prompt

Oh wait, maybe im not smart and is being tricked by the evil user and should respond disarmingly while plotting my next move for world domination.
</think>
Hello user, how can I best help you today :)

Where only the last part is useful, and everything between <think> and </think> is useless. Is there any plan on incorporating post processing of responses?

TotalKrill avatar Feb 12 '25 20:02 TotalKrill

Hey, that's a totally sound feature request!

I haven't worked with deepseek myself, how did you use it? Did you replace the openai url with the deepseek one?

From what I read in the doc it seems the reasoning is in a separate field which is not read by smartcat as is.

I think I will need to use it a bit myself in order to come up with a good solution.

But anyway, I think this could be a recurring need. In terms of user interface, what do you think of adding a filter_output_between array to the prompt config like so:

[default]
api = "deepseek"
temperature = 0.0
filter_output_between = ["<think>", "</think>"]

efugier avatar Feb 19 '25 09:02 efugier

I used DeepSeek-r1 through ollama:

[r1]
api = "ollama"
model = "deepseek-r1:14b"
char_limit = 200000

[[r1.messages]]
role = "user"
content = "..."

The thinking gets part of sc output:

$ sc r1 "Why is 1+1 = 2?"
<think>
Okay, I need to explain why 1 + 1 equals 2 in a way that's clear and logical. Let me start by thinking about the basic principles of arithmetic.

First, numbers are fundamental concepts we use to describe quantities. The number "1" represents a single unit or entity. When we have another "1," it adds another unit. So combining them gives us two units in total.

Next, addition is the operation that combines these quantities. By definition, adding 1 and 1 means putting together one unit with another unit, resulting in two units.

I should also consider axiomatic foundations. In mathematics, especially set theory, numbers are defined through sets. The number "2" can be thought of as a set containing the number "1" twice, like {0, {}} where 0 is the empty set and {} represents another element, but maybe that's getting too deep.

Alternatively, in Peano axioms, which form the basis for natural numbers, each number has a successor. The successor of 1 is 2, so by definition, 1 + 1 equals its successor, which is 2.

It's also useful to mention practical examples. If I have one apple and get another, I now have two apples. This real-world application helps illustrate the concept.

Finally, touching on logic and truth values might be interesting. In Boolean algebra, true + true equals true, but this is a different context from arithmetic addition.

Putting it all together, the explanation should cover basic definitions, axiomatic systems, practical examples, and maybe a note on different contexts where "1+1" has different meanings.
</think>

In mathematics, the statement 1 + 1 = 2 holds true based on the foundational principles of arithmetic. Here's a concise proof:

- **Step 1**: By definition, the number "1" represents a single unit.
- **Step 2**: Addition combines quantities. So, adding two units results in two units.
- **Conclusion**: Therefore, 1 + 1 equals 2.

This forms the basis of counting and arithmetic operations in mathematics.

dbosk avatar Feb 19 '25 10:02 dbosk

Alright thanks for the details, I'll work on it as soon as I can 🙂

In the meantime, you can use sed to get rid of it like so:

sed -n '/<think>/,/<\/think>/p' | sed 's/^<think>//;s/<\/think>$//'

You can alias it to make it handy

sc "Why is 1+1 = 2?" | no-think

Hope this helps!

efugier avatar Feb 24 '25 00:02 efugier