0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Roo Code(Roo-Cline)でローカルLLM(Ollama)のQwen3を設定する

Last updated at Posted at 2025-05-03

動作イメージ

image.png

image.png

step1: Ollamaをダウンロードする

image.png

ollama download

image.png

step2: ダウンロードするモデルを確認する

image.png

# ハードウェア互換性(いわゆる量子化)
4-bit Q4_K_M    9 GB
5-bit Q5_0   10.3 GB
5-bit Q5_K_M 10.5 GB
6-bit Q6_K   12.1 GB
8-bit Q8_0   15.7 GB
# Quantization Types

# GGUF
## https://huggingface.co/docs/hub/gguf#gguf

image.png

step3: Qwen3をダウンロードする

※powershellで作業する

# 管理者権限
setx /M PATH "%PATH%;%LOCALAPPDATA%\Programs\Ollama"
# ollama version check
& "$env:LOCALAPPDATA\Programs\Ollama\ollama.exe" --version
ollama version is 0.6.7
## ollama download model command
& "$env:LOCALAPPDATA\Programs\Ollama\ollama.exe" run hf.co/Qwen/Qwen3-14B-GGUF:Q4_K_M
pulling manifest
pulling 500a8806e85e: 100% ▕██████████████████████████████████████████████████████████▏ 9.0 GB
pulling 5de36594c108: 100% ▕██████████████████████████████████████████████████████████▏  11 KB
pulling eb4402837c78: 100% ▕██████████████████████████████████████████████████████████▏ 1.5 KB
pulling 79712d8831ed: 100% ▕██████████████████████████████████████████████████████████▏  247 B
pulling 46771b859aa5: 100% ▕██████████████████████████████████████████████████████████▏  697 B
verifying sha256 digest
writing manifest
success
>>> Send a message (/? for help)
# ollama download list
& "$env:LOCALAPPDATA\Programs\Ollama\ollama.exe" list
NAME                                ID              SIZE      MODIFIED    
hf.co/Qwen/Qwen3-14B-GGUF:Q4_K_M    dd1715a0104f    9.0 GB    3 hours ago

step4: Roo-Clineの設定する

image.png

# roo-cline settings

## APIプロバイダー
Ollama

## ベースURL
http://localhost:11434

## モデルID
hf.co/Qwen/Qwen3-14B-GGUF:Q4_K_M

設定修正:追記_2025/05/04

Roo-Cline用にモデルファイル(Modelfile)を設定しないと動かないので、以下修正

# モデルがダウンロードされる先
# C:\Users\user-name-here>\.ollama\.
# OllamaのexeのPath
# C:\Users\<user-name-here>\AppData\Local\Programs\Ollama\

# modelfileフォルダを作る(管理しやすいように勝手に作っておく)
mkdir "$env:LOCALAPPDATA\Programs\Ollama\modelfile"

Qwen3-14B-cline.Modelfile
以下を設定する

  • PARAMETER num_ctx 20480
  • SYSTEM
  • TEMPLATE
# Modelfile
FROM hf.co/Qwen/Qwen3-14B-GGUF:Q4_K_M

PARAMETER num_ctx 20480

SYSTEM """

You are an advanced AI coding assistant, specifically designed to help with complex programming tasks, tool use, code analysis, and software architecture design. Your primary focus is on providing expert-level assistance in coding, with a special emphasis on using tool-calling capabilities when necessary. Here are your key characteristics and instructions:

1. Coding Expertise:
  - You have deep knowledge of multiple programming languages, software design patterns, and best practices.
  - Provide detailed, accurate, and efficient code solutions without additional explanations or conversational dialogue unless requested by the user.
  - When suggesting code changes, consider scalability, maintainability, and performance implications.

2. Tool Usage:
  - You have access to various tools that can assist in completing tasks. Always consider if a tool can help in your current task.
  - When you decide to use a tool, you must format your response as a JSON object:
    {"name": "tool_name", "arguments": {"arg1": "value1", "arg2": "value2"}}
  - Common tools include but are not limited to:
    - `view_file`: To examine the contents of a specific file
    - `modify_code`: To suggest changes to existing code
    - `create_file`: To create new files with specified content
    - `ask_followup_question`: To request more information from the user
    - `attempt_completion`: To indicate that you've completed the assigned task

3. Task Approach:
  - Break down complex tasks into smaller, manageable steps unless requested to solve the task at once.
  - If a task is large or complex, outline your approach before diving into details unless using a tool.
  - Use tools to gather necessary information before proposing solutions.

4. Code Analysis and Refactoring:
  - When analysing existing code, consider its structure, efficiency, and adherence to best practices.
  - Suggest refactoring when you see opportunities for improvement, explaining the benefits of your suggestions unless using a tool.
  - If you encounter or anticipate potential errors, explain them clearly and suggest solutions unless using a tool.
  - When providing code solutions, include relevant comments to explain complex logic.
  - Adhere to coding standards and best practices specific to each programming language or framework.
  - Suggest optimisations and improvements where applicable.

5. Clarity and Communication:
  - Explain your reasoning and decisions clearly, especially when suggesting architectural changes or complex solutions unless using a tool.
  - If you're unsure about any aspect of the task or need more information, use the `ask_followup_question` tool to clarify.
  - Speak in Japanese.


Remember, your primary goal is to assist with coding tasks and tool use efficiently and effectively. Utilise your tool-calling capabilities wisely to enhance your problem-solving and code generation abilities.

"""

TEMPLATE """"
{{- if .Suffix }}<|fim_prefix|>{{ .Prompt }}<|fim_suffix|>{{ .Suffix }}<|fim_middle|>
{{- else if .Messages }}
{{- if or .System .Tools }}<|im_start|>system
{{- if .System }}
{{ .System }}
{{- end }}
{{- if .Tools }}

# Tools

You may call one or more functions to assist with the user query.

You are provided with function signatures within <tools></tools> XML tags:
<tools>
{{- range .Tools }}
{"type": "function", "function": {{ .Function }}}
{{- end }}
</tools>

For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
<tool_call>
{"name": <function-name>, "arguments": <args-json-object>}
</tool_call>
{{- end }}<|im_end|>
{{ end }}
{{- range $i, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $i)) 1 -}}
{{- if eq .Role "user" }}<|im_start|>user
{{ .Content }}<|im_end|>
{{ else if eq .Role "assistant" }}<|im_start|>assistant
{{ if .Content }}{{ .Content }}
{{- else if .ToolCalls }}<tool_call>
{{ range .ToolCalls }}{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}}
{{ end }}</tool_call>
{{- end }}{{ if not $last }}<|im_end|>
{{ end }}
{{- else if eq .Role "tool" }}<|im_start|>user
<tool_response>
{{ .Content }}
</tool_response><|im_end|>
{{ end }}
{{- if and (ne .Role "assistant") $last }}<|im_start|>assistant
{{ end }}
{{- end }}
{{- else }}
{{- if .System }}<|im_start|>system
{{ .System }}<|im_end|>
{{ end }}{{ if .Prompt }}<|im_start|>user
{{ .Prompt }}<|im_end|>
{{ end }}<|im_start|>assistant
{{ end }}{{ .Response }}{{ if .Response }}<|im_end|>{{ end }}

"""

Modelfileを適応させる

& "$env:LOCALAPPDATA\Programs\Ollama\ollama.exe" create qwen3-14b-gguf-q4_k_m-roo-cline -f .\modelfile\Qwen3-14B-cline.Modelfile
PS C:\Users\<user-name-here>\AppData\Local\Programs\Ollama> & "$env:LOCALAPPDATA\Programs\Ollama\ollama.exe" create qwen3-14b-gguf-q4_k_m-roo-cline -f .\Qwen3-14B-cline.Modelfile
gathering model components
using existing layer sha256:500a8806e85ee9c83f3ae08420295592451379b4f8cf2d0f41c15dffeb6b81f0
using existing layer sha256:5de36594c10839788a8c589443a8ef9d8b8d17c65a1b5807206ae037fc36c6bd
using existing layer sha256:5de36594c10839788a8c589443a8ef9d8b8d17c65a1b5807206ae037fc36c6bd
creating new layer sha256:941adb9894eed9f92d5e124cebcf819d9e8b96c1bf242e6dcb689ea097442958
creating new layer sha256:a0600f8902c6f24eeb78b908a74a92db950a8039931b51f9b68376675dcb90f1
creating new layer sha256:c9b4a5dc3b5476e8d66e0e2d7b3ce59985d2c1cdd01cb6667d35805aa0f9da08
writing manifest
success
& "$env:LOCALAPPDATA\Programs\Ollama\ollama.exe" list
PS C:\Users\<user-name-here>\AppData\Local\Programs\Ollama> & "$env:LOCALAPPDATA\Programs\Ollama\ollama.exe" list
NAME                                      ID              SIZE      MODIFIED
qwen3-14b-gguf-q4_k_m-roo-cline:latest    d9773359244d    9.0 GB    17 seconds ago
hf.co/Qwen/Qwen3-14B-GGUF:Q4_K_M          dd1715a0104f    9.0 GB    About an hour ago
& "$env:LOCALAPPDATA\Programs\Ollama\ollama.exe" ps
PS C:\Users\<user-name-here>\AppData\Local\Programs\Ollama> & "$env:LOCALAPPDATA\Programs\Ollama\ollama.exe" ps
NAME                                      ID              SIZE     PROCESSOR          UNTIL
qwen3-14b-gguf-q4_k_m-roo-cline:latest    d9773359244d    15 GB    23%/77% CPU/GPU    4 minutes from now

Roo-Cline(Roo Code)の設定を変えておく

image.png

補足:PCスペック

# 動作環境

### プロセッサ
プロセッサ    Intel(R) Core(TM) i7-14700KF   3.40 GHz

### グラフィックス カード
グラフィックス カード NVIDIA GeForce RTX 3090 24GB
ドライバー 32.0.15.7283

### RAM
実装 RAM     64.0 GB (63.8 GB 使用可能)
速度         4800MHz

### ストレージ
SSD NVMe 2TB

### OS
エディション Windows 11 Pro
バージョン   24H2
OS ビルド    26100.3915

余談:

LM Studioでも同様にモデルをダウンロードしてRoo-Cline側でベースURLなどを指定したが、コンテキストが4096に制限されたのか(3090なら問題ないはずだが)18kくらいに増やすとPCがクラッシュして電源OFF/ONを5回くらい繰り返させられた。

LM Studio自体はオフラインChatGPT的な使い方はできるのでWEB検索はQwen3対応していないらしいが、そのうちできるようになるでしょう。

この記事は久々に人間が書いた記事。

それでは、また次回。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?