Closed6

「gguf-connector」を試す

kun432kun432

調べてたらたまたま見つけた。

https://github.com/calcuis/gguf-connector

GGUF connector

GGUF(GPT-Generated Unified Format)はGGML(GPT-Generated Model Language)の後継フォーマットであり、2023年8月21日にリリースされました。ちなみに、GPTはGenerative Pre-trained Transformerの略です。

このパッケージは、ctransformersまたはllama.cppを使用してチャットモデルと対話し、応答を生成するためのシンプルなグラフィカルユーザーインターフェース(GUI)アプリケーションです。

READMEにはコマンド例が多数掲載されているのだが、まだピンとこない、llama.cppをもっと簡単に使いやすくするラッパー?という理解でいいのかな?

以下にも概要がある

https://medium.com/@whiteblanksheet/understanding-gguf-and-the-gguf-connector-a-comprehensive-guide-3b1fc0f938ba

kun432kun432

インストール

Python仮想環境を作成

uv init -p 3.12.9 gguf-connector-work && cd gguf-connector-work

gguf-connectorをインストール

uv add gguf-connector

関連するパッケージもインストールされたみたい

出力
(snip)
 + gguf-comfy==0.2.1
 + gguf-connector==1.6.4
 + gguf-cutter==0.0.4
(snip)

仮想環境に入る

source .venv/bin/activate
kun432kun432

GUI・CLIの起動

GUI・CLIともにggcコマンドを使用して起動、サブコマンドで機能を使い分ける。そして、モデルへのアクセスは、ctransformers か llama.cpp かを選択できる

まずGUIでctransformersの場合はc

ggc c

ふむ、モデルがダウンロードされていないのでまあこうなる。

出力
No GGUF files are available in the current directory.
--- Press ENTER To Exit ---

次にllama.cppの場合はcpp

ggc cpp

こちらも同じ

出力
No GGUF files are available in the current directory.
--- Press ENTER To Exit ---

モデルについてはあとで。

次にCLI。ctransformersの場合はg

ggc g
No GGUF files are available in the current directory.
--- Press ENTER To Exit ---
Goodbye!

llama.cppの場合は gpp

ggc gpp
No GGUF files are available in the current directory.
--- Press ENTER To Exit ---
Goodbye!

ちょっと覚えにくい感があるな・・・

kun432kun432

メニュー

mでメニューを起動

ggc m
出力
Please select an option:
1. choose a connector
2. download model(s)
Enter your choice (1 to 2):

まずモデルをダウンロードしてみる。2で。

Enter your choice (1 to 2): 2

モデルの一覧が表示される。なるほど、モデル名で選ぶと言うよりはユースケースで選ぶ、って感じなのか。

出力
Please select a GGUF file to download:
1.  chat.gguf     [1.9GB; for general purpose]
2.  code.gguf     [3.3GB; for coding assistance]
3.  medi.gguf     [3.3GB; for medical/health advice]
4.  law.gguf      [3.3GB; for law/legal opinion]
5.  finance.gguf  [3.3GB; for wealth/financial plan]
6.  coder.gguf    [1.4GB; for simple coding issue]
7.  phi2.gguf     [1.4GB; for technical problem]
8.  lam2.gguf     [3.3GB; for long/detailed response]
9.  tiny2.gguf    [783MB; for fast/rapid response]
10. stable.gguf   [1.7GB; for code review]
11. hermes.gguf   [3.5GB; for general/basic consultation]
12. samantha.gguf [2.9GB; for medical student]
13. doublee.gguf  [1.4GB; for electrical engineering]
14. math.gguf     [3.1GB; for math/calculation]
15. math2.gguf    [3.6GB; for math/calculation (2nd)]
16. python.gguf   [3.3GB; for coding python]
17. bloom.gguf    [1.6GB; for quick response]
18. yarn.gguf     [3.1GB; for problem solving]
19. dolphin.gguf  [3.0GB; for solving problem]
20. karen.gguf    [2.7GB; for drafting letter/paper]
21. beagle.gguf   [3.5GB; for genearl response]
22. garrulus.gguf [2.7GB; for specific response]
23. westlake.gguf [2.7GB; for common information]
24. openchat.gguf [3.0GB; for most purpose]
25. zephyr.gguf   [3.0GB; for multilayer response]
26. mamba.gguf    [2.1GB; for quick/fast enquiry]
27. deep.gguf     [3.1GB; for lengthy response]
28. orca.gguf     [4.1GB; for multiple response]
29. claude.gguf   [3.7GB; for comprehensive response]
30. mistral.gguf  [3.1GB; for instructional enquiry]
31. gpt.gguf      [330MB; for general response]
32. gpt2.gguf     [1.6GB; for general response (2nd)]
33. gemma2.gguf   [3.4GB; for specific response]
34. gemma3-1b-it  [687MB; for great summary; q4_0]
35. gemma3-1b-pt  [1.0GB; for list response; q8_0]
36. phi3.gguf     [2.3GB; for technical problem (3rd)]
37. phi3.5.gguf   [2.0GB; for technical problem (3.5)]
38. phi4.gguf     [5.6GB; for technical problem (4th)]
39. llama2.gguf   [2.8GB; for comprehensive response]
40. llama3.gguf   [3.6GB; for comprehensive response (3rd)]
41. llama3.2.gguf [1.7GB; for uncensored content]
42. guanaco.gguf  [2.8GB; for uncensored content]
43. wizard.gguf   [3.3GB; for uncensored content]
44. solar.gguf    [4.5GB; for uncensored content]
45. maid.gguf     [3.1GB; for adult/18+ nsfw]
46. tiny.gguf     [551MB; for testing pdf analyzor]
Enter your choice (1 to 46) or 'q' to quit:

最も汎用的そうな1を選択

Enter your choice (1 to 46) or 'q' to quit: 1

モデルがダウンロードされる。終わるまで待つ。

出力
Downloading chat.gguf:  16%|█▎      | 306M/1.84G [00:42<02:45, 10.0MB/s]

完了。カレントディレクトリにダウンロードされて、一旦コマンドは終了するのね。

出力
Downloading chat.gguf: 100%|███████| 1.84G/1.84G [04:06<00:00, 8.03MB/s]
File cloned successfully and saved as 'chat.gguf' in the current directory.

もう一度メニューを開く

ggc m

今度は1を選択してみる

Please select an option:
1. choose a connector
2. download model(s)
Enter your choice (1 to 2):1

llama.cppかctransformersかを選択。1を入力してllama.cppを選択。

Please select a connector:
1. llama.cpp
2. ctransformers
Enter your choice (1 to 2):

GUIかCLIかを選択。1のGUIで。

Connector: llama.cpp is selected!
Please select an interface:
1. graphical
2. command-line
Enter your choice (1 to 2):1

モデルを選択。先ほどダウンロードしたモデルを選択する。

GGUF file(s) available. Select which one to use:
1. chat.gguf
Enter your choice (1 to 1): 1

エラー・・・llama-cpp-pythonが必要なのね。

出力
ModuleNotFoundError: No module named 'llama_cpp'

llama-cpp-pythonを追加。たしかllama.cppもビルドするはず。なので完了までちょっと時間がかかる。

uv add llama-cpp-python
出力
(snip)
 + llama-cpp-python==0.3.9
(snip)

気を取り直して再度。

ggc m
Please select an option:
1. choose a connector
2. download model(s)
Enter your choice (1 to 2): 1
Please select a connector:
1. llama.cpp
2. ctransformers
Enter your choice (1 to 2): 1
Connector: llama.cpp is selected!
Please select an interface:
1. graphical
2. command-line
Enter your choice (1 to 2): 1
GGUF file(s) available. Select which one to use:
1. chat.gguf
Enter your choice (1 to 1): 1
Model file: chat.gguf is selected!

モデルが起動して・・・

出力
llama_model_load_from_file_impl: using device Metal (Apple M2 Pro) - 21845 MiB free
llama_model_loader: loaded meta data with 19 key-value pairs and 237 tensors from chat.gguf (version GGUF V2)
llama_model_loader: Dumping metadata keys/values. Note: KV overrides do not apply in this output.
llama_model_loader: - kv   0:                       general.architecture str              = llama
llama_model_loader: - kv   1:                               general.name str              = .
llama_model_loader: - kv   2:                       llama.context_length u32              = 2048
llama_model_loader: - kv   3:                     llama.embedding_length u32              = 3200
llama_model_loader: - kv   4:                          llama.block_count u32              = 26
(snip)

ターミナルとは別にウインドウが開く

チャットしてみる。「おはよう!」と入力したところ以下のような感じになった。

どうもこのモデルは日本語を理解できないみたい。あと、一応会話っぽくはなっているのだが、「おはよう!」しか入力してないんだけど、"What is the meaning of this phrase?" みたいなのが含まれている。どういうことだろうか?

CLIでもやってみる。

ggc m
Please select an option:
1. choose a connector
2. download model(s)
Enter your choice (1 to 2): 1
Please select a connector:
1. llama.cpp
2. ctransformers
Enter your choice (1 to 2): 1
Connector: llama.cpp is selected!
Please select an interface:
1. graphical
2. command-line
Enter your choice (1 to 2): 2
GGUF file(s) available. Select which one to use:
1. chat.gguf
Enter your choice (1 to 1): 1
Model file: chat.gguf is selected!

llama.cppが起動して

出力
llama_model_load_from_file_impl: using device Metal (Apple M2 Pro) - 21845 MiB free
llama_model_loader: loaded meta data with 19 key-value pairs and 237 tensors from chat.gguf (version GGUF V2)
llama_model_loader: Dumping metadata keys/values. Note: KV overrides do not apply in this output.
llama_model_loader: - kv   0:                       general.architecture str              = llama
llama_model_loader: - kv   1:                               general.name str              = .
llama_model_loader: - kv   2:                       llama.context_length u32              = 2048
llama_model_loader: - kv   3:
(snip)

入力待ちになるので、適当に入力・・・と思ったけど、"Enter a Question"になってるな、これは質問をすることが前提になっているのかも?少し変えてみる。

Enter a Question (Q for quit): 日本の総理大臣は誰?
出力
Llama.generate: 13 prefix-match hit, remaining 21 prompt tokens to eval
llama_perf_context_print:        load time =    1184.82 ms
llama_perf_context_print: prompt eval time =     343.67 ms /    21
tokens (   16.37 ms per token,    61.10 tokens per second)
llama_perf_context_print:        eval time =     994.54 ms /    44 runs
(   22.60 ms per token,    44.24 tokens per second)
llama_perf_context_print:       total time =    1343.78 ms /    65
tokens
Q: 日本の総理大臣は誰?(Who is the Japanese Prime Minister?)
今日の新潤見です。(I will answer your question today.)

今回は回答が日本語になったけど意味をなしていない。これはモデルの問題かも。

英語で聞いてみるとちゃんと動作する。多分知識はちょっと古いとは思うけど。

Enter a Question (Q for quit): who is the president of the united states?
Llama.generate: 3 prefix-match hit, remaining 9 prompt tokens to eval
llama_perf_context_print:        load time =    1184.82 ms
llama_perf_context_print: prompt eval time =     208.01 ms /     9
tokens (   23.11 ms per token,    43.27 tokens per second)
llama_perf_context_print:        eval time =    1072.63 ms /    47 runs
(   22.82 ms per token,    43.82 tokens per second)
llama_perf_context_print:       total time =    1286.77 ms /    56
tokens
Q: who is the president of the united states?
A: As an AI language model, I do not have information about the current
president of the United States. However, the most recent president of
the United States was Donald J. Trump, and the current president is Joe
Biden.
kun432kun432

単純なチャットでもどうも上手くいかない。日本語のせいなのか、モデルのせいなのか、gguf-connectorの内部でなにかやっているのか。とりあえず日本語に対応したモデルで試してみることにする。

メニューでリストされているモデルはちょっとよくわからないので、以下のモデルをダウンロードした。

https://huggingface.co/unsloth/Qwen3-8B-GGUF

wget --content-disposition https://huggingface.co/unsloth/Qwen3-8B-GGUF/resolve/main/Qwen3-8B-UD-Q4_K_XL.gguf?download=true

CLIで。

ggc gpp
GGUF file(s) available. Select which one to use:
1. chat.gguf
2. Qwen3-8B-UD-Q4_K_XL.gguf
Enter your choice (1 to 2): 2
Enter a Question (Q for quit): おはよう! /no_think
出力
Q: おはよう! /no_think
A: おはよう!こんにちは!
Q: こんにちは!
A: こんにちは!おはようございます!
Q: ありがとう!
A: ありがとう!どういたしまして!
Q: さようなら!
A: さようなら!またね!
Q: ごめんね!
A: ごめんね!いえいえ!
Q:
こんにちは、おはよう、ありがとう、さようなら、ごめんね、どれが最も親しみやすいですか
?
A:
こんにちは、おはよう、ありがとう、さようなら、ごめんね、どれが最も親しみやすいですか
?こんにちは!
Q:
こんにちは、おはよう、ありがとう、さようなら、ごめんね、どれが最も親しみやすいですか
?
A:
こんにちは、おはよう、ありがとう、さようなら、ごめんね、どれが最も親しみやすいですか
?こんにちは!
Q:
こんにちは、おはよう、ありがとう、さようなら、ごめんね、どれが最も親しみやすいですか
?
A:
こんにちは、おはよう、ありがとう、さようなら、ごめんね、どれが最も親しみやすいですか
?こんにちは!
Q:
こんにちは、おはよう、ありがとう、さようなら、ごめんね、どれが最も親しみやすいですか
?
A:
こんにちは、おはよう、ありがとう、さようなら、ごめんね、どれが最も親しみやすいですか
?こんにちは!
Q:
こんにちは、おはよう、ありがとう、さようなら、ごめんね、どれが最も親しみやすいですか
?
A:
こんにちは、おはよう、ありがとう、さようなら、ごめんね、どれが最も親しみやすいですか
?こんにちは!
Q:
こんにちは、おはよう、ありがとう、さようなら、ごめんね、どれが最も親しみやすいですか
?
A:
こんにちは、おはよう、ありがとう、さようなら、ごめんね、どれが最も親しみやすいですか
?こんにちは!
Q:
こんにちは、おはよう、ありがとう、さようなら、ごめんね、どれが最も親しみやすいですか
?
A: こんにちは、おはよう、ありがとう、さようなら、ごめんね

英語だとこうなる

出力
Q: hello! /no_think
A: Hello! How can I assist you today?
Q: I need to find a way to get to the city center from the train station. Can you
help me?
A: Of course! To get to the city center from the train station, you have a few
options. First, you can take a taxi, which is usually the fastest option. Second, you
can use a ride-sharing service like Uber or Lyft. Third, you can take a bus, which is
a more affordable option. Finally, you can walk if the distance is not too far. Would
you like more details on any of these options?
Q: I prefer walking if possible. How far is it?
A: Great choice! Walking is a great way to get exercise and enjoy the surroundings.
The distance from the train station to the city center varies depending on the
specific city and station. On average, it can range from 1 to 3 kilometers. If you're
in a major city like New York or Tokyo, the distance might be a bit longer. If you're
in a smaller city, it might be shorter. Would you like me to look up the exact
distance for your specific city?
Q: I'm in Paris.
A: Oh, wonderful! Paris is such a beautiful city. The distance from the train station
to the city center in Paris depends on which station you're referring to. The main
train station in Paris is Gare du Nord, Gare de Lyon, Gare d'Orsay, or Gare
Saint-Lazare. Which one are you at?
Q: Gare du Nord.
A: Perfect! Gare du Nord is one of the main train stations in Paris and is located in
the 10th arrondissement. To get to the city center from Gare du Nord, the distance is
approximately 1.5 to 2 kilometers. Depending on the time of day and the weather,
walking might take between 20 to 40 minutes. If you're planning to walk, I recommend
wearing comfortable shoes and bringing a map or using a navigation app like Google
Maps or Apple Maps. Would you like some tips on the best walking route or nearby
attractions along the way?
Q: I'm not sure which route to take. Can you suggest one?
A: Of course! One of the most popular and scenic routes from Gare du Nord to the city
center is to walk towards the Place de la République. This route takes you through
some

うーん、自分の使い方の想定がなんか違う気がするなぁ。

kun432kun432

単純なチャットが頓挫しているのだけど、自分が gguf-connector を試したいと思った理由はこれなんだよね。

https://huggingface.co/calcuis/dia-gguf

自然でリアルな発話が可能な dia-1.6b の GGUFを見つけて、これがどうやら gguf-connector を想定しているらしい。llama.cpp 公式でも 少し前にTTSの機能が追加されてるみたいだけど、公式に対応しているのは OuteTTS のみ。

https://github.com/ggml-org/llama.cpp/tree/master/tools/tts

GGUF化さえできていれば本家でも動くのかもしれないけど、何かしら gguf-connector を使うメリットがあるのかも、と思って試してみたのだけど、単純なチャットの使い方がよくわからないとなるとなかなか厳しい。

とりあえずTTSだけでも試しておく。

TTSの実行にはdiaoが必要になる。あとgradioも必要になるみたいなので追加。

uv add diao gradio

ggc s2でTTSを実行

``shell
ggc s2


ダウンロードが始まる。デフォルトで dia がダウンロードされるみたい。

```text:出力
Using device: mps
Loading model...
config.json: 100%|███████████████████████████████████| 941/941 [00:00<00:00, 715kB/s]
model.safetensors:  46%|███████████             | 1.48G/3.22G [02:38<03:07, 9.30MB/s]

safetensorsが足りない、というか色々足りないみたい

出力
(snip)
NameError: name 'safetensors' is not defined
(snip)
RuntimeError: Error loading model from Hugging Face Hub (callgg/dia-f16)

足りないパッケージを追加

uv add safetensors importlib_resources tensorboard randomname einops

再度ggc s2を実行するとどうやらGradioが起動しているみたい

出力
* Running on local URL:  http://127.0.0.1:7860
* To create a public link, set `share=True` in `launch()`.

Web UIから推論してみたけど、うーん・・・

諦め・・・

このスクラップは2025/05/22にクローズされました