はじめに
「DeepSeek-R1」がすごいと評判になっています。今回は「DeepSeek-R1」を使って蒸留したQwenをさらに8bitに量子化した軽量なものをOllamaを使ってローカル環境で動かしてみました。実際に使ったのは「deepseek-r1:14b-qwen-distill-q8_0 (15GB)」です。使用したPC
プロセッサ Intel(R) Core(TM) i7-12700H 実装 RAM 32.0 GB GPU RTX 3080 Laptop (VRAM 16GB)
質問
以下の質問を投げかけてみました。過去に自分が悩まされた問題です。「9 9 9 9」という4桁の数字があります。数字と数字の間に四則演算の記号を追加して計算結果が10になるようにして下さい。 数字と数字の間に少数点を追加することは禁止されています。 隣あう数字をまとめて2桁以上の数字とみなすことは禁止されています。 括弧を使うことは可能です。 以下に例を示します。 ~~~ 「1 2 3 4」なら1+2+3+4が解答の一例です。 「4 5 4 2」なら(4*5)/(4-2)が解答の一例です。 ~~~
回答
出力はなぜか英語になりました。最初にずらずらと思考過程が出力されます。「論理思考モデル」ってそういうものなんですね。思考が終了した後に最終的な回答を出力します。その回答が以下の通りです。To solve the problem of creating an expression that equals 10 using exactly four nines and the basic arithmetic operations, follow these steps: 1. Identify the goal: Create an expression using four nines that evaluates to 10. 2. Explore possible operations: Consider addition, subtraction, multiplication, and division. 3. Experiment with combinations: - Start by trying simple operations like adding or multiplying multiple nines. - For example,, which is too high but can be adjusted with division or further operations. 4. Formulate a promising expression: - Consider the expression
. - Break it down: - First, calculate
(using two nines). - Add 9 to the result:
(now using three nines). - Divide by 9:
(total four nines). 5. Verify the expression: - Ensure all operations are performed correctly. - Confirm that exactly four nines are used. The final expression is:
This equation uses four nines and basic arithmetic operations to equal 10.
感想
「お見事!!」の一言です。この問題、Claude 3.5 Sonnetでも正解に行きつきませんでした。なのにローカルで動くモデルが正解にたどり着いたことに驚かされます。しかも、モデルサイズは15GBですが常にフルに活性化しているわけではなさそうでVRAM 16GBのPCでサクサク出力されていきます。補足
「deepseek-r1:32b-qwen-distill-q4_K_M (19GB)」も試しましたがこちらは正解にたどり着きませんでした。出した回答がこちらです。Answer:![]()
パラメータ数が多いにも関わらず精度が落ちたのは4bit量子化のせいではないかと推測します。
汚名返上
Claude 3.5 Sonnetにはこの問題を解くPythonスクリプトを書いてもらいました。こういったことは得意です。
from itertools import product def find_expressions(numbers): operators = ['+', '-', '*', '/'] expressions = [] # すべての演算子の組み合わせを試す for ops in product(operators, repeat=3): patterns = [ f"{numbers[0]} {ops[0]} {numbers[1]} {ops[1]} {numbers[2]} {ops[2]} {numbers[3]}", f"({numbers[0]} {ops[0]} {numbers[1]}) {ops[1]} {numbers[2]} {ops[2]} {numbers[3]}", f"({numbers[0]} {ops[0]} {numbers[1]} {ops[1]} {numbers[2]}) {ops[2]} {numbers[3]}", f"({numbers[0]} {ops[0]} {numbers[1]}) {ops[1]} ({numbers[2]} {ops[2]} {numbers[3]})", f"{numbers[0]} {ops[0]} ({numbers[1]} {ops[1]} {numbers[2]}) {ops[2]} {numbers[3]}", f"{numbers[0]} {ops[0]} ({numbers[1]} {ops[1]} {numbers[2]} {ops[2]} {numbers[3]})", f"{numbers[0]} {ops[0]} {numbers[1]}) {ops[1]} ({numbers[2]} {ops[2]} {numbers[3]})" ] for exp in patterns: try: if eval(exp) == 10: expressions.append(exp) except: continue for answer in expressions: print(answer) if __name__ == "__main__": numbers = [9, 9, 9, 9] find_expressions(numbers)
上記を実行すると、総当たりなので以下のような回答が得られます。
(9 + 9 * 9) / 9 (9 * 9 + 9) / 9