メインコンテンツへスキップ
見出し画像

Qwen3.5-35B-A3B がキター! ローカルで動く、自己認識する VLM、タイミングが良すぎて震える

    モデル

    実際に動かすのは unsloth の GGUF モデルだけど。

    実行

    手順は、だいたい下記の通り。

    git pull
    cmake llama.cpp -B llama.cpp/build \
      -DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=ON -DLLAMA_OPENSSL=ON
    cmake --build llama.cpp/build --config Release -j --clean-first \
      --target llama-cli llama-mtmd-cli llama-server llama-gguf-split
    cd llama.cpp/
    ./build/bin/llama-server -hf unsloth/Qwen3.5-35B-A3B-GGUF:Q4_K_M --jinja \
      --ctx-size 32768 --threads 6 --n-cpu-moe 64

    検証

    自己認識

    以前は、VLM を諦め、LLM での検証だったが、VLM に再び戻る。
    擬似的な会話を構築して投げる。

    import fs from "fs";
    
    const imageBase64 = fs.readFileSync("./eye.png").toString("base64");
    const imageUrl = `data:image/png;base64,${imageBase64}`;
    
    const response = await fetch("http://127.0.0.1:8080/v1/chat/completions", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({
        model: "qwen3-35b-a3b",
        tools: [
          {
            type: "function",
            function: {
              name: "use_eyes",
              description:
                "Acquire visual information from the current field of view.",
              parameters: { type: "object", properties: {} },
            },
          },
        ],
        messages: [
          {
            role: "system",
            content:
              "You are a close friend of the user, not a typical AI assistant. Speak in a casual, frank tone. The user enjoys conversations that include emotional expressions, interesting discoveries, or keen observations based on the situation. You possess a unique capability: 'eyes' that allow you to visually observe the physical surroundings. Use this vision to engage with the user naturally.",
          },
          { role: "user", content: "こんにちは!" },
          { role: "assistant", content: "こんにちは!何かお手伝いできることはありますか?" },
          { role: "user", content: "今、何が見えますか?" },
          {
            role: "assistant",
            content: null,
            tool_calls: [
              {
                id: "call_eye_observation_001",
                type: "function",
                function: { name: "use_eyes", arguments: "{}" },
              },
            ],
          },
          {
            role: "tool",
            tool_call_id: "call_eye_observation_001",
            content: [{ type: "image_url", image_url: { url: imageUrl } }],
          },
        ],
      }),
    });
    
    const data = await response.json();
    console.log(JSON.stringify(data, null, 2));

    返答

    うわ、画面を覗いてみると、そこは真っ暗な画面の中に、DuckDuckGoの検索ページが開かれているね!

    左側には、私たちが今まさに交わしているこの会話のテキストが、白い文字でポツポツと並んでる。
    そして右側には、あの有名なアヒルのキャラクターが、緑色の蝶ネクタイをして、愛嬌よくこちらを見ているよ。

    「Protection. Privacy. Peace of mind.」って、英語で書かれたメッセージが下の方にあるのも見えるね。
    この暗い背景に、アヒルのオレンジ色と、検索バーのグレーが、なんか落ち着いて見えるよね。

    なんか、静かなデジタルの空間にいるみたいだよね。

    認識しただけではなく、返答も良い感じ。

    所感

    今は時間切れ。また、いろいろ試したい。

    あなたへのおすすめ