Internlm3 8b Instruct Gguf
モデル概要
モデル特徴
モデル能力
使用事例
🚀 InternLM3-8B-Instruct GGUFモデル
internlm3-8b-instruct
のGGUF形式モデルは、llama.cppという人気のある大規模言語モデル(LLM)推論用のオープンソースフレームワークを通じて、ローカルやクラウドなど様々なハードウェアプラットフォームで利用できます。
このリポジトリでは、internlm3-8b-instruct
のGGUF形式モデルを半精度と、q5_0
、q5_k_m
、q6_k
、q8_0
などの様々な低ビット量子化バージョンで提供しています。
以降のセクションでは、まずインストール手順を紹介し、次にモデルのダウンロード方法を説明します。 最後に、具体的な例を通じてモデルの推論方法とサービスのデプロイ方法を示します。
🚀 クイックスタート
以下では、internlm3-8b-instruct
モデルのインストール、ダウンロード、推論、サービスデプロイの手順を説明します。
📦 インストール
llama.cpp
をソースからビルドすることをおすすめします。以下のコードスニペットはLinux CUDAプラットフォームの例です。他のプラットフォームの手順については、公式ガイドを参照してください。
- ステップ1: conda環境を作成し、cmakeをインストール
conda create --name internlm3 python=3.10 -y
conda activate internlm3
pip install cmake
- ステップ2: ソースコードをクローンし、プロジェクトをビルド
git clone --depth=1 https://github.com/ggerganov/llama.cpp.git
cd llama.cpp
cmake -B build -DGGML_CUDA=ON
cmake --build build --config Release -j
ビルドされたすべてのターゲットは、サブディレクトリbuild/bin
にあります。
以降のセクションでは、作業ディレクトリがllama.cpp
のルートディレクトリであると仮定します。
📥 モデルのダウンロード
導入セクションで述べたように、このリポジトリにはさまざまな計算精度のモデルが含まれています。必要に応じて適切なモデルをダウンロードできます。
例えば、internlm3-8b-instruct-fp16.gguf
は以下のようにダウンロードできます。
pip install huggingface-hub
huggingface-cli download internlm/internlm3-8b-instruct-gguf internlm3-8b-instruct.gguf --local-dir . --local-dir-use-symlinks False
💻 使用例
基本的な使用法
推論
llama-cli
を使用して推論を行うことができます。llama-cli
の詳細な説明は、このガイドを参照してください。
チャットの例
以下は、思考システムプロンプトを使用した例です。
thinking_system_prompt="<|im_start|>system\nYou are an expert mathematician with extensive experience in mathematical competitions. You approach problems through systematic thinking and rigorous reasoning. When solving problems, follow these thought processes:\n## Deep Understanding\nTake time to fully comprehend the problem before attempting a solution. Consider:\n- What is the real question being asked?\n- What are the given conditions and what do they tell us?\n- Are there any special restrictions or assumptions?\n- Which information is crucial and which is supplementary?\n## Multi-angle Analysis\nBefore solving, conduct thorough analysis:\n- What mathematical concepts and properties are involved?\n- Can you recall similar classic problems or solution methods?\n- Would diagrams or tables help visualize the problem?\n- Are there special cases that need separate consideration?\n## Systematic Thinking\nPlan your solution path:\n- Propose multiple possible approaches\n- Analyze the feasibility and merits of each method\n- Choose the most appropriate method and explain why\n- Break complex problems into smaller, manageable steps\n## Rigorous Proof\nDuring the solution process:\n- Provide solid justification for each step\n- Include detailed proofs for key conclusions\n- Pay attention to logical connections\n- Be vigilant about potential oversights\n## Repeated Verification\nAfter completing your solution:\n- Verify your results satisfy all conditions\n- Check for overlooked special cases\n- Consider if the solution can be optimized or simplified\n- Review your reasoning process\nRemember:\n1. Take time to think thoroughly rather than rushing to an answer\n2. Rigorously prove each key conclusion\n3. Keep an open mind and try different approaches\n4. Summarize valuable problem-solving methods\n5. Maintain healthy skepticism and verify multiple times\nYour response should reflect deep mathematical understanding and precise logical thinking, making your solution path and reasoning clear to others.\nWhen you're ready, present your complete solution with:\n- Clear problem understanding\n- Detailed solution process\n- Key insights\n- Thorough verification\nFocus on clear, logical progression of ideas and thorough explanation of your mathematical reasoning. Provide answers in the same language as the user asking the question, repeat the final answer using a '\\boxed{}' without any units, you have [[8192]] tokens to complete the answer.\n<|im_end|>\n"
build/bin/llama-cli \
--model internlm3-8b-instruct.gguf \
--predict 2048 \
--ctx-size 8192 \
--gpu-layers 48 \
--temp 0.8 \
--top-p 0.8 \
--top-k 50 \
--seed 1024 \
--color \
--prompt "$thinking_system_prompt" \
--interactive \
--multiline-input \
--conversation \
--verbose \
--logdir workdir/logdir \
--in-prefix "<|im_start|>user\n" \
--in-suffix "<|im_end|>\n<|im_start|>assistant\n"
その後、Given the function\(f(x)=\mathrm{e}^{x}-ax - a^{3}\),\n(1) When \(a = 1\), find the equation of the tangent line to the curve \(y = f(x)\) at the point \((1,f(1))\).\n(2) If \(f(x)\) has a local minimum and the minimum value is less than \(0\), determine the range of values for \(a\).
のような質問を入力します。
関数呼び出しの例
llama-cli
の例:
build/bin/llama-cli \
--model internlm3-8b-instruct.gguf \
--predict 512 \
--ctx-size 4096 \
--gpu-layers 48 \
--temp 0.8 \
--top-p 0.8 \
--top-k 50 \
--seed 1024 \
--color \
--prompt '<|im_start|>system\nYou are InternLM-Chat, a harmless AI assistant.<|im_end|>\n<|im_start|>system name=<|plugin|>[{"name": "get_current_weather", "parameters": {"required": ["location"], "type": "object", "properties": {"location": {"type": "string", "description": "The city and state, e.g. San Francisco, CA"}, "unit": {"type": "string"}}}, "description": "Get the current weather in a given location"}]<|im_end|>\n<|im_start|>user\n' \
--interactive \
--multiline-input \
--conversation \
--verbose \
--in-suffix "<|im_end|>\n<|im_start|>assistant\n" \
--special
会話結果:
<s><|im_start|>system
You are InternLM-Chat, a harmless AI assistant.<|im_end|>
<|im_start|>system name=<|plugin|>[{"name": "get_current_weather", "parameters": {"required": ["location"], "type": "object", "properties": {"location": {"type": "string", "description": "The city and state, e.g. San Francisco, CA"}, "unit": {"type": "string"}}}, "description": "Get the current weather in a given location"}]<|im_end|>
<|im_start|>user
> I want to know today's weather in Shanghai
I need to use the get_current_weather function to get the current weather in Shanghai.<|action_start|><|plugin|>
{"name": "get_current_weather", "parameters": {"location": "Shanghai"}}<|action_end|>32
<|im_end|>
> <|im_start|>environment name=<|plugin|>\n{"temperature": 22}
The current temperature in Shanghai is 22 degrees Celsius.<|im_end|>
>
高度な使用法
サービスのデプロイ
llama.cpp
はOpenAI API互換のサーバーllama-server
を提供しています。internlm3-8b-instruct.gguf
を以下のようにサービスとしてデプロイできます。
./build/bin/llama-server -m ./internlm3-8b-instruct.gguf -ngl 48
クライアント側では、OpenAI APIを通じてサービスにアクセスできます。
from openai import OpenAI
client = OpenAI(
api_key='YOUR_API_KEY',
base_url='http://localhost:8080/v1'
)
model_name = client.models.list().data[0].id
response = client.chat.completions.create(
model=model_name,
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": " provide three suggestions about time management"},
],
temperature=0.8,
top_p=0.8
)
print(response)
📄 ライセンス
このプロジェクトはApache-2.0ライセンスの下で提供されています。



