Skip to main content

[Beta] A custom llama-cpp-python wheel tailored for Intel 10th Gen CPUs on Windows 11.

Project description

kinako-llama-cpp

**⚠️ This package is an early experimental/testing release. This is a custom-built, wheel-embedded distribution of llama-cpp-python optimized to run LLMs like Gemma 4 smoothly on everyday, mid-to-low spec PCs running Windows 11 (specifically tested on Intel 7th, 8th, 9th, 10th, and 13th Gen CPUs).

⚠️ 本パッケージは検証用の早期(取り急ぎの)リリースです。 知人・友人環境での動作検証を通じ、今後記述や構成を随時修正・アップデートしていく前提のプロジェクトです。 本パッケージは、Windowsの身近な低スペックPC環境において、軽量LLMを動作させることを目的とした llama-cpp-python のカスタムビルド(Wheel同梱版)です。

開発者より: 現時点ではWindows+CPU AVX2環境での動作を想定していますが、構成の厳密な検証はこれからです。(Intel 7,8,9,10,13世代/Win11で確認済) 実際に pip install してみて動いた・動かなかったなどのフィードバック(動作報告)をもとに、セットアップ設定やドキュメントを順次修正していきます。

インストール方法

pip install kinako-llama-cpp

Important (English):
If you already have the official llama-cpp-python installed in your environment, installing this package directly may cause module conflicts inside the llama_cpp folder.
Please make sure to uninstall the official version before installing this package to prevent any broken dependencies.

Bash
### ⚠️ すでに公式の llama-cpp-python をインストールしている方へ / For Existing Users

**重要 (Japanese):**
もし、すでに本家(公式)の `llama-cpp-python` をインストール済みの環境に本パッケージを導入する場合、中身のモジュール(`llama_cpp`)が衝突して正常に動作しなくなる恐れがあります。
本パッケージを試す前に、必ず一度既存のパッケージをアンインストールしてください。

```bash
# 既存の公式版を一度削除する
pip uninstall llama-cpp-python -y

# その後、本パッケージをインストールする
pip install kinako-llama-cpp

> Python program sample
>
import os
import sys
from llama_cpp import Llama

# ── 設定項目 / Configuration ──
MODEL_PATH = r"C:\pythonfiles\llm\gemma-4-E2B-it-RotorQuant-Q8_0.gguf"

print("--- LLMモデルを読み込んでいます(数秒〜十数秒かかります)... ---")
print("--- Loading LLM model (This may take a few seconds)... ---")

try:
    llm = Llama(
        model_path=MODEL_PATH, 
        n_ctx=2048,
        n_batch=128,      # 過去の履歴を読み直す速度をCPU向けに最適化 / Optimized for CPU
        n_gpu_layers=0    # 完全CPUモード / CPU Only Mode
    )
except Exception as e:
    print(f"[ERROR] Model file not found or could not be loaded.")    
    print(f"\n【エラー】モデルファイルが見つからないか、読み込めませんでした。")
    print(f"Please check the path: {MODEL_PATH}")
    input("\nPress Enter to exit...")
    sys.exit(1)

print("\n=========================================")
print("  Windows CPU-driven PC Chat")
print("  Type 'exit' to quit the chat. / 終了するには「exit」と入力してください。")
print("=========================================\n")

# 過去の会話履歴を保存するリスト / Chat history list
chat_history = []

while True:
    try:
        user_input = input("You / あなた: ")
        
        if not user_input.strip():
            continue
            
        if user_input.strip().lower() == "exit":
            print("Closing chat. Thank you! / チャットを終了します。お疲れ様でした!")
            break
        
        # -------------------------------------------------
        # プロンプトの組み立て / Prompt Construction
        # -------------------------------------------------
        # 多言語に対応できるよう、指示を英語に統一し「ユーザーの言語に合わせる」ルールを追加
        system_prompt = "System: Act as a helpful AI assistant. Reply kindly and politely within 400 characters. (Please respond in the same language the user speaks.)\n"
        #日本語のみの場合
        #system_prompt = "System: 親切なAIとして、400文字以内で、優しく丁寧に回答してください。\n"
        
        # 履歴を直近の2回分(発言数に直すと最大4つ)に絞る
        recent_history = chat_history[-4:]
        history_text = "".join(recent_history)
        
        # 今回の質問をドッキング
        current_prompt = f"User: {user_input}\nAI: "
        full_prompt = system_prompt + history_text + current_prompt
        
        print("\nAI: ", end="", flush=True)
        
        # ストリーミング実行 / Streaming Execution
        response_stream = llm(
            full_prompt,
            max_tokens=500,  # 余裕を持たせた上限設定
            stop=["User:", "\nUser:", "System:", "\nSystem:"],
            echo=False,
            stream=True
        )
        
        # 1文字ずつ出力しながら、今回の回答テキストを記録
        ai_response = ""
        for chunk in response_stream:
            text = chunk["choices"][0]["text"]
            sys.stdout.write(text)
            sys.stdout.flush()
            ai_response += text
            
        print("\n-----------------------------------------")
        
        # ── 今回の会話を履歴リストに追加 ──
        chat_history.append(f"User: {user_input}\n")
        chat_history.append(f"AI: {ai_response.strip()}\n")
        
    except KeyboardInterrupt:
        print("\n Exit requested. Closing chat./ チャットを終了します。")
        print("\n")
        break
    except Exception as e:
        print(f"\n An error occurred / エラーが発生しました  {e}")
        break

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kinako_llama_cpp-0.3.24.post2.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kinako_llama_cpp-0.3.24.post2-py3-none-any.whl (6.2 MB view details)

Uploaded Python 3

File details

Details for the file kinako_llama_cpp-0.3.24.post2.tar.gz.

File metadata

  • Download URL: kinako_llama_cpp-0.3.24.post2.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.14

File hashes

Hashes for kinako_llama_cpp-0.3.24.post2.tar.gz
Algorithm Hash digest
SHA256 da5cf303f08621aacaa961ffe6dff42b010ecc65694195f2e93e98f668153cce
MD5 aff03136483bd7a2cc08bb16e7bf3f78
BLAKE2b-256 46ba3bb739f4e9e7a69f31cc774dfc0dc179c9850f7b8c71ef7e0ac1549a625f

See more details on using hashes here.

File details

Details for the file kinako_llama_cpp-0.3.24.post2-py3-none-any.whl.

File metadata

File hashes

Hashes for kinako_llama_cpp-0.3.24.post2-py3-none-any.whl
Algorithm Hash digest
SHA256 ad34476a0317921598a796d1f4b3e0004348ba60ddb4879dece7cc047520d122
MD5 74a577f3d99dcca9035672175090a33f
BLAKE2b-256 01aac455f98ee8722a5dd96064a0ce2207d7e7bc6d5ec30829ad470292b7d47b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page