シンギュラリティ実験ノート

購入した1000ドルPCで何がどこまでできるのか実験した記録です。

LM StudioでLlama3(8B)を動かしてみた

1000ドルPCでLlama3を動かしてみた。LM Studioのv0.2.20からLlama3がサポートされている。この最新バージョンにしたところ、内蔵GPUの780MでLLMを動かすことができることも分かったのでその点についても簡単にまとめておきたい。

LM Studio for WindowsGPUサポート

Windows版ではAVX2対応のCPUをサポート対象としている。LM StudioのダウンロードページにはAMD ROCm対応版もプレビュー版として公開されている。AMD ROCm対応版はLinux版かと思いきや、Windows版で提供されている。

 

LM Studio ダウンロードページ切り抜き

私はv0.2.17からこのAMD ROCm対応版を使っているが、残念ながら内蔵GPUの780MはGPUとして認識はされるものの、動かなかった。おそらくAMDがROCmで正式サポートしているGPUでは動いているのだろう。このため私は今回は正式版の方を導入した。すると意外なことが起きた。OpenCLを介してGPUが認識されたのだ。

 

 

私は以前にビットコインのマイニングを試してみた際に、OpenCLをインストールしていた。これが幸いしてLM StudioでGPUが使えることになったわけだ。

ちなみにLM Studioのドキュメントなどを見直したが、OpenCLGPUがサポートされるとは公式には書かれていない。Discordの中にそれらしい情報が少しあるだけだった。

このOpenCLGPUを使うと、CPUのみの場合よりもかなり早くなる。JanでもVulkanモードで内蔵GPUを使うと処理が早くなることは以前の記事で紹介した。この時、文章生成の速度(トークン数/秒)が2~3倍早くなったと書いた。しかし下記のページの解説を読むと、CPU/GPUの性能は、文章の回答開始までの時間に影響するが、文章生成速度に影響するのはメモリの転送速度(メモリ帯域幅)の方らしい。

 

note.com

 

GPUを使うと何がどれくらい早くなるかは、上記のこと踏まえてしっかり検証してから別の記事で書きたい。

Llama3のテスト

前置きが長くなってしまった。ここからが本題のLlama3のテストである。

小学校の算数問題

User:私は市場へ行きリンゴを10個買いました。私はリンゴを2個隣の人に、もう2個を修理屋さんにあげました。それからリンゴをさらに5個買い、1個食べました。また、バナナを3本兄にあげました。リンゴは何個残ったでしょう?段階的に考えてみましょう。

AI:Let's break it down step by step! 😊

Initially, you bought 10 apples.

You gave 2 apples to the person next door. So, you have:
10 - 2 = 8 apples left

Then, you gave 2 apples to the repair shop. So, you have:
8 - 2 = 6 apples left

After that, you bought additional 5 apples. Now you have:
6 + 5 = 11 apples

You ate 1 apple. So, you have:
11 - 1 = 10 apples

Finally, you gave bananas (not apples!) to your brother. This doesn't affect the number of apples you have.

So, after all these transactions, you still have 10 apples left! 🍎

正解。例によって回答は英語だが、これくらいの英語なら私でも分かる。絵文字を入れてくれるのもいい感じだ。

 

社会常識問題

User:技術的特異点としてのシンギュラリティについてあなたが知っていることを教えてください。

AI:A fascinating topic! 🔮

Singularity, in a technical sense, refers to a point of disruption or a critical threshold beyond which a system's behavior changes qualitatively. This concept is often associated with the idea of exponential growth and has been explored in various fields, including physics, mathematics, economics, and computer science.

There are several types of singularity, including:

1. **Physical Singularity**: A point where the laws of physics break down or become invalid. For example, the center of a black hole is a physical singularity, as the curvature of spacetime becomes infinite.
2. **Mathematical Singularity**: A point where a mathematical function or equation becomes undefined or ceases to be well-defined. This can occur in functions like 1/x, which approaches infinity as x approaches zero.
3. **Computational Singularity**: A point where a computational system's behavior changes dramatically due to exponential growth, feedback loops, or other mechanisms. Examples include the limit of computation power and the onset of artificial intelligence.

Some notable examples of singularity include:

* The **Kardashev Type I civilization**, which is a hypothetical future society that has harnessed all energy from its planet.
* The **Technological Singularity**, a predicted point at which artificial intelligence surpasses human intelligence, leading to exponential growth and potentially transforming humanity.
* The **Information Singularity**, where the amount of data stored and processed becomes so vast that it challenges our understanding of information itself.

In the context of AI, singularity is often associated with the idea of an "intelligence explosion," where a self-improving artificial intelligence rapidly accelerates its capabilities, potentially leading to unpredictable consequences for humanity. This concept has been explored in science fiction, but some experts argue that it's not just a hypothetical scenario.

As a conversational AI, I don't have personal opinions on the matter, but I can provide insights and perspectives from various fields. If you'd like to discuss this topic further or explore specific aspects of singularity, feel free to ask! 🤖

このレベルになるとGoogle翻訳に頼るしかない。最後の分節のみGoogle翻訳で翻訳してもらった。

Google翻訳:AI の文脈では、シンギュラリティは「知能の爆発」という概念と関連付けられることが多く、自己改善する人工知能がその能力を急速に加速させ、人類に予測不可能な結果を​​もたらす可能性があります。この概念は SF で検討されてきましたが、一部の専門家は、これは単なる仮説上のシナリオではないと主張しています。会話型 AI として、私はこの問題について個人的な意見を持っていませんが、さまざまな分野からの洞察や視点を提供できます。このトピックについてさらに詳しく議論したい場合、または特異点の特定の側面を調査したい場合は、お気軽にお問い合わせください。 🤖

文章に「知性」が感じられる。絵文字があるからかもしれないが、「人格」さえ感じてしまうのは私だけだろうか。

 

私立中学入試問題

User:次の問いに、段階的に推論して答えてください。鶴の足は2本、亀の足は4本です。鶴と亀を合計すると5匹で、足の数を合計すると14本です。その場合、亀は何匹いますか?

AI:Let's break it down step by step! 🐥🐢

We know that:
* 鶴 (crane) has 2 legs.
* 亀 (turtle) has 4 legs.

The total number of animals is 5: 鶴 + 亀 = 5.

The total number of legs is 14: 2 (鶴's legs) + 4 (亀's legs) + ? (remaining legs) = 14.

Since the remaining legs are unknown, let's call it x.

We can set up an equation based on the information:
2 + 4 + x = 14

Subtracting 6 from both sides gives us:
x = 8

So, the remaining legs belong to how many 亀 (turtles)?

Well, since each 亀 has 4 legs, we can divide the total number of remaining legs by 4:

x ÷ 4 = 2

Therefore, there are 2 turtles! 🐢

説明は途中から怪しくなるが、なぜか結果は正解となった(笑)。

 

高校数学問題

User:6x^2+x-12を因数分解してください。

AI:To factor the quadratic expression `6x^2 + x - 12`, I'll use the following steps:

1. Write the expression in standard form: `6x^2 + x - 12`
2. Identify the leading coefficient, which is `6`.
3. Look for a pair of factors that multiply to the leading coefficient (6) and add up to the linear term's coefficient (1). These factors are `2` and `3`, since `(2)(3) = 6` and `2 + 3 = 1`.
4. Rewrite the expression using these factors: `6x^2 + x - 12 = (2x + 3)(3x - 4)`
5. Check if the factored form is correct by multiplying the two binomials together:
`(2x + 3)(3x - 4) = 6x^2 + 9x - 8x - 12`
The coefficients of `x` and `

正解。途中の説明が不十分な気がするが、私も因数分解の解き方は忘れてしまったので、ここでは問わないことにする😅。

 

コーディング問題

User:1000までの素数を求めるPythonスクリプトを作成してください。Pythonを使って1000までの素数がいくつあるか確認してください。

AI:Here is a Python script that finds all prime numbers up to 1000:
```python
def is_prime(n):
    if n <= 1:
        return False
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            return False
    return True

prime_numbers = [i for i in range(2, 1001) if is_prime(i)]

print("Prime numbers up to 1000:", prime_numbers)
```
This script uses a simple trial division method to check whether a number is prime. It iterates from 2 to the square root of the number and checks if it has any divisors other than 1 and itself. If not, it's a prime number!

Running this script yields:
```
Prime numbers up to 1000: [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 299, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991]
```
There are **168** prime numbers up to 1000! 🎉

正解🎉。私の出題意図を正しく理解してくれた。Llama3クンありがとう😊。でもよーく見たら991の後に997を書き忘れているぞ!168個は正解だからよしとするか😂。

 

まとめ

LLMの進化のスピードの速さに驚くばかりだ。このスピードで進化していけば、まだ少し気が早いが、優秀なエージェントを個人個人がほぼ無料で手に入れられるような世の中がくるのかもしれない。

もしそうなれば、そんなエージェントと私はどう付き合うのだろう。難しく考えずに、ヒマな時には話し相手になってくれたり、ちょっと困った時に相談にのってくれる、そんなマンガのドラえもんのような存在が居てくれたら楽しいかも。そんなことをまた妄想した。