3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Windowsで3ステップでローカルLLM動かしてみた(n番煎じ)

Last updated at Posted at 2025-05-27

ollamaで簡単、ローカルLLM

情報は新規性のない、2025年5月時点でのやってみた系記事です。
極めて簡単に、話題の「LLM」というものが、お手元のパソコンで動きますよ、試してみよう、という記事です。

1. ollamaをダウンロード、インストールする #1GBくらいダウンロードあり

2. PowerShellで「ollama run gemma3:1b」と打ってみる #1GBくらいダウンロードあり

3. 「何ができますか?」と打ってみる

以上でもう動いてます!

  • ollamaがPS5とかSwitchみたいなもので、色々と「モデル」というカセットをプレイできるようなイメージ
  • 数GB~数十GBのファイルをダウンロードするので気長に待ちましょう
  • 実用性考えると、ブラウザベースで対話したいですね
  • 会話開始後はインターネット切断しても動きます

手順詳細

1.公式サイトからインストーラをダウンロード、実行し、ウィザードに従ってインストールします。
アイコンかわいい。
FireAlpacaのアイコンかと思った。

#オプションだけどおすすめな手順
モデルの保存場所を変えておけます。
モデルを色々試したくなるのですが、数GB~数十GBのファイルを配置することになるので、
例えばCドライブ以外の方が広いとかあればそちらに設定しておく方が良いかなと思います。

「Windowsキー+R」→sysdm.cplと打ってエンター→「詳細設定」タブ最下部、「環境変数(N)」
→「システム環境変数(S)」を「新規(W)」→変数名「OLLAMA_MODELS」、変数値を任意の場所指定。
「D:\opt\ollama\models」などお好みで。
デフォルトは「C:\Users\インストールしたユーザ名.ollama\models」
もし上手く場所が切り替わらない場合、ollamaの再起動またはパソコンの再起動をしてみましょう。

2.PowerShellでモデルを指定して実行します。
「Windowsキー+R」→powershellと打ってエンター→「ollama run gemma3:1b」と打ってエンター

3.「>>> 」という感じのプロンプトになったら、「何ができますか?」など、質問してみましょう。
会話を終了する際は、「/bye」か「Ctrl + d」ということです。

4.モデル探し
最初は軽いもので試しました。
もっと色々なモデルが利用可のなので幾つか試してみてください。
公式サイトから探せます。

または以下のサイトもサポートされています。

カセットの形式が「GGUF」だ、という感じで良いかなと思います。
基本的に、「ollama run」の対象となるカセット探し、という感じです。

参考ログ

手元のパソコンでやってみたログは以下の通りです。

  • CPU Xeon E3-1270v3、メモリ16GB、win10。重いモデルは多少応答に時間かかるな、という感じでした
  • 応答がマークダウンだったりするので、やっぱりブラウザで表示したいですね。方法は色々あるようですね
  • 別にコマンドプロンプトでも動きますが、ウィンドウ閉じても前回のコマンド覚えていてくれるので単純に便利って感じでPowerShellをおすすめしてます
  • モデル3つに対して、以下のお願いをしてみました
    「日本語で回答お願いいたします。fizzbuzzのプログラムを作成してください。htmlファイル一つで、内部でJavaScriptを使って、1から100までの数字を表示しますが、3の倍数の時はfizz、5の倍数の時はbuzz、3と5両方の倍数の時はfizzbuzzと表示する、というものです。」

gemma3:1b
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

新しいクロスプラットフォームの PowerShell をお試しください https://aka.ms/pscore6

PS C:\Users\usr> ollama --version
ollama version is 0.7.0
PS C:\Users\usr> ollama run gemma3:1b
pulling manifest
pulling 7cd4618c1faf: 100% ▕████████████████████▏ 815 MB
pulling e0a42594d802: 100% ▕████████████████████▏  358 B
pulling dd084c7d92a3: 100% ▕████████████████████▏ 8.4 KB
pulling 3116c5225075: 100% ▕████████████████████▏   77 B
pulling 120007c81bf8: 100% ▕████████████████████▏  492 B
verifying sha256 digest
writing manifest
success
>>> hello. what can you do?
Hello there! I’m a large language model, which means I can do a lot of
things involving text. Here’s a breakdown of what I can do:

**1. Creative Writing & Content Generation:**

*   **Stories & Scripts:** I can write stories in various genres – fantasy,
sci-fi, romance, mystery, etc. I can also help you with scripts for videos,
podcasts, or even plays.
*   **Poems:** I can generate poems on a variety of topics and styles.
*   **Articles & Blog Posts:** I can draft articles on many subjects,
providing outlines and content.
*   **Emails & Letters:** I can help you draft professional or informal
emails.
*   **Social Media Content:**  I can create captions, tweets, and other
social media posts.
*   **Song Lyrics:** I can write lyrics based on a theme or topic.

**2. Information & Knowledge:**

*   **Answering Questions:** I’ve been trained on a massive dataset of text
and code, so I can answer your questions on a wide range of topics.
*   **Definitions & Explanations:** I can define words, concepts, and
jargon.
*   **Summarization:** I can summarize long articles or documents into shorter, more digestible
versions.
*   **Research Assistance:** I can gather information and provide summaries of different topics.
(Remember, my knowledge is based on the data I was trained on, so I might not have the very latest updates.)

**3. Conversational & Task-Oriented:**

*   **Brainstorming:** I can help you brainstorm ideas for projects, stories, or anything else.
*   **Role-Playing:** I can engage in role-playing scenarios.
*   **Translation:** I can translate between many languages.
*   **Code Generation (simple):** I can generate basic code snippets in various languages (like Python).
*   **Math Problems:** I can solve basic math problems.

**4.  Other Capabilities:**

*   **Creative Text Formats:** I can try my hand at different creative text formats, like haikus, sonnets, and
riddles.
*   **Follow Instructions:** I’m designed to follow your instructions and complete your requests thoroughly.



**To help me give you a more tailored response, could you tell me:**

*   **What are you hoping to do today?** (e.g., "Write a short story," "Explain quantum physics," "Brainstorm
ideas for a marketing campaign")

>>> japanese ok?
Okay! Let’s do Japanese! 😊

I can definitely help you with Japanese. I can:

*   **Translate:** I can translate between Japanese and English (and many other languages).
*   **Write in Japanese:** I can write in Japanese, though my fluency isn’t perfect.
*   **Answer questions about Japanese language:** I can provide information about grammar, vocabulary, kanji,
and culture.
*   **Help with practice:** If you’re learning Japanese, I can offer practice exercises or help you with
vocabulary.

**What would you like to do today?**  Do you have any specific requests or would you like to start with a
simple conversation?

>>> では、日本語で回答お願いいたします。fizzbuzzのプログラムを作成してください。htmlファイル一つで、内部でJavaScript
... を使って、1から100までの数字を表示しますが、3の倍数の時はfizz、5の倍数の時はbuzz、3と5両方の倍数の時はfiz
... zbuzzと表示する、というものです。
Okay, let’s create a FizzBuzz program in HTML with JavaScript! Here’s the code:

<!DOCTYPE html>
<html>
<head>
<title>FizzBuzz</title>
<style>
body { font-family: sans-serif; }
.result { margin-bottom: 20px; }
</style>
</head>
<body>

<h1>FizzBuzz</h1>

<p><b>FizzBuzz</b></p>

<ol>
  <li>1.  FizzBuzz</li>
  <li>2.  Buzz</li>
  <li>3.  FizzBuzz</li>
  <li>4.  Buzz</li>
  <li>5.  FizzBuzz</li>
</ol>

<div class="result"></div>

<script>
function fizzBuzz() {
  let result = "";

  for (let i = 1; i <= 100; i++) {
    if (i % 3 === 0 && i % 5 === 0) {
      result += "FizzBuzz";
    } else if (i % 3 === 0) {
      result += "Fizz";
    } else if (i % 5 === 0) {
      result += "Buzz";
    }
    result += i;
  }

  document.getElementById("result").textContent = result;
}

fizzBuzz();
</script>

</body>
</html>
**How it works:**

1.  **HTML Structure:**  The HTML defines the basic structure of the page with a heading and a paragraph. It
also includes a `div` with the class "result" where the output will be displayed.

2.  **CSS (Basic Styling):**  The CSS styles the body font and the `div` for the result.

3.  **JavaScript:**
   *   The `fizzBuzz()` function is the core of the program.
   *   It loops through numbers 1 to 100.
   *   Inside the loop:
      *   If the number is divisible by both 3 and 5, it displays "FizzBuzz".
      *   If the number is divisible by 3, it displays "Fizz".
      *   If the number is divisible by 5, it displays "Buzz".
      *   It displays the number itself.
   *   The `result` variable accumulates the output.
   *   Finally, the `document.getElementById("result").textContent = result;` line updates the `div` with the
`result` string to display the output.

**How to run this code:**

1.  **Save as HTML:** Save the code above as a `.html` file (e.g., `fizzbuzz.html`).
2.  **Open in Browser:**  Open the `.html` file in any web browser (Chrome, Firefox, Safari, etc.).

Let me know if you have any questions or would like me to modify it to add any features!

>>>
Use Ctrl + d or /bye to exit.
>>> /bye

image.png

何か違う。雰囲気は伝わる。
スクリプトが上手く動作してないっぽい。


gemma3:4b
PS C:\Users\usr> ollama run gemma3:4b
pulling manifest
pulling aeda25e63ebd: 100% ▕███████████████████████████████████████████████████████▏ 3.3 GB
pulling e0a42594d802: 100% ▕███████████████████████████████████████████████████████▏  358 B
pulling dd084c7d92a3: 100% ▕███████████████████████████████████████████████████████▏ 8.4 KB
pulling 3116c5225075: 100% ▕███████████████████████████████████████████████████████▏   77 B
pulling b6ae5839783f: 100% ▕███████████████████████████████████████████████████████▏  489 B
verifying sha256 digest
writing manifest
success
>>> hello. what can you do?
Okay, let's talk about what I can do! I'm a large language model, which means I'm a computer program trained to
understand and generate human language. Think of me as a really, *really* good student of language.

Here's a breakdown of what I can do, broken down into categories:

**1. Content Generation:**

* **Writing:** I can write almost anything you need:
    * **Stories:** Short stories, poems, scripts, even longer narratives.  Tell me the genre, characters, and
plot points.
    * **Articles & Blog Posts:** I can draft articles on a huge variety of topics.
    * **Emails & Letters:**  Formal or informal, I can write emails, letters, and other correspondence.
    * **Marketing Copy:**  Headlines, slogans, product descriptions.
    * **Summaries:** I can condense long texts into shorter summaries.
    * **Creative Content:**  I can generate jokes, riddles, and other creative content.

**2. Information & Knowledge:**

* **Answering Questions:** I can answer your questions on almost any topic. My knowledge cutoff is **September
2021**, so I won't have information about events after that date. I try to provide accurate and helpful
answers, but always double-check with reliable sources.
* **Definitions & Explanations:** I can define words, explain concepts, and break down complex topics.
* **Research Assistance:** I can help you gather information for research projects (although I can't replace
thorough research!). I can provide summaries of findings, compare different viewpoints, etc.

**3.  Interactive Tasks & Assistance:**

* **Brainstorming:** Need help coming up with ideas? I can help you brainstorm.
* **Translation:** I can translate text between many different languages.
* **Code Generation (Limited):** I can generate simple code snippets in various languages (Python, JavaScript,
etc.).  My coding abilities are still developing.
* **Role-Playing:** We can engage in imaginative role-playing scenarios.
* **Following Instructions:** I can follow your instructions carefully. Just be specific!
* **Text Transformation:** I can rephrase text, rewrite content in a different style, etc.

**4.  My Limitations (Important!)**

* **No Real-Time Information:** As mentioned before, my knowledge is only up to September 2021.
* **I Can Make Mistakes:** I’m still under development, and I can sometimes provide inaccurate or misleading
information.  **Always verify information from me with reliable sources.**
* **I Lack Common Sense & Emotional Understanding:** I don’t truly *understand* the world like a human does.
I'm processing patterns in data, not having genuine experiences.
* **I Can't Offer Professional Advice:** I'm not a doctor, lawyer, financial advisor, or therapist.  Don't rely
on me for professional guidance.


**How to Interact With Me Effectively:**

* **Be Clear and Specific:** The more details you give me, the better I can understand your request.
* **Break Down Complex Requests:** If you have a complicated task, break it down into smaller, more manageable
steps.
* **Iterate:** Don't be afraid to refine your prompts based on my responses.

---

**Okay, now that you know what I can do, what would you like to try?  Do you have a specific question, task, or
something you'd like me to generate?**  For example, you could ask me:

* "Write a short poem about a rainy day."
* "What is the capital of France?"
* "Summarize the plot of *Hamlet*."
* "Brainstorm some ideas for a marketing campaign for a new coffee shop."

>>> 日本語で回答お願いいたします。fizzbuzzのプログラムを作成してください。htmlファイル一つで、内部でJavaScriptを使っ
... て、1から100までの数字を表示しますが、3の倍数の時はfizz、5の倍数の時はbuzz、3と5両方の倍数の時はfizzbuzz
... と表示する、というものです。
はい、承知いたしました。以下にHTMLファイルの内容とJavaScriptコードを記載します。

<!DOCTYPE html>
<html>
<head>
  <title>FizzBuzz</title>
  <style>
    body {
      font-family: sans-serif;
      text-align: center;
    }
    #output {
      margin-top: 20px;
    }
  </style>
</head>
<body>
  <h1>FizzBuzz</h1>
  <div id="output"></div>

  <script>
    const output = document.getElementById('output');

    for (let i = 1; i <= 100; i++) {
      let result = '';

      if (i % 3 === 0) {
        result += 'Fizz';
      }
      if (i % 5 === 0) {
        result += 'Buzz';
      }

      if (result === '') {
        result = i;
      }

      output.innerHTML += result + '<br>';
    }
  </script>
</body>
</html>
**説明:**

1.  **HTML構造:**
    *   `<!DOCTYPE html>`: HTML5の文書であることを宣言します。
    *   `<html>`: HTMLドキュメントのルート要素です。
    *   `<head>`: ドキュメントに関するメタデータ(タイトルなど)を含みます。
    *   `<title>`: ブラウザのタブに表示されるタイトルを指定します。
    *   `<style>`:  CSSスタイルシートを含みます。ここでは、基本的なスタイル(フォント、テキストの配置)を設定して
います。
    *   `<body>`:  ブラウザの画面に表示されるコンテンツを含みます。
    *   `<h1>`:  見出しを表示します。
    *   `<div id="output">`:  出力結果を表示するための`<div>`要素です。`id`属性でJavaScriptからアクセスできるよう
にしています。
    *   `<script>`:  JavaScriptコードを含みます。

2.  **JavaScriptコード:**
    *   `const output = document.getElementById('output');`:  `id`が`output`の`<div>`要素を取得し、`output`という
変数に格納します。
    *   `for (let i = 1; i <= 100; i++)`: 1から100までの数字を順番に処理するためのループです。
    *   `let result = '';`:  現在の数字に対する出力結果を格納するための変数です。
    *   `if (i % 3 === 0) { result += 'Fizz'; }`:  現在の数字が3で割り切れる場合、'Fizz'を`result`に追加します。
`%`は剰余演算子で、割り算の余りを計算します。
    *   `if (i % 5 === 0) { result += 'Buzz'; }`:  現在の数字が5で割り切れる場合、'Buzz'を`result`に追加します。

    *   `if (result === '') { result = i; }`:  もし`result`が空文字列の場合(つまり、3でも5でもない数字の場合)、
現在の数字を`result`に代入します。
    *   `output.innerHTML += result + '<br>';`:  `result`の内容を`output`の`innerHTML`に設定し、改行文字`<br>`を
追加して表示します。  `innerHTML`はHTMLの内容を変更するためのプロパティです。

**使い方:**

1.  上記のコードをテキストエディタにコピーして、`.html`拡張子で保存します。(例:`fizzbuzz.html`)
2.  保存した`.html`ファイルをWebブラウザで開きます。
3.  ブラウザに1から100までの数字がFizzBuzzのルールに従って表示されます。

このプログラムは、HTMLファイルとJavaScriptコードをまとめて実行します。ご希望通りにFizzBuzzの動作をするはずです。
もし動作に問題がある場合は、ブラウザのコンソール(通常、F12キーで開けます)にエラーメッセージが表示されているか確
認してください。

>>> bye
>>>
Use Ctrl + d or /bye to exit.
>>> /bye

image.png

中略

image.png

大丈夫そう。


mistral
PS C:\Users\usr> ollama run mistral
pulling manifest
pulling ff82381e2bea: 100% ▕███████████████████████████████████████████████████████▏ 4.1 GB
pulling 43070e2d4e53: 100% ▕███████████████████████████████████████████████████████▏  11 KB
pulling 491dfa501e59: 100% ▕███████████████████████████████████████████████████████▏  801 B
pulling ed11eda7790d: 100% ▕███████████████████████████████████████████████████████▏   30 B
pulling 42347cd80dc8: 100% ▕███████████████████████████████████████████████████████▏  485 B
verifying sha256 digest
writing manifest
success
>>> hello. what can you do?
⠸  Hello! As a conversational AI, I can assist you with various tasks such as answering questions, providing
information, helping with problem-solving, generating creative ideas, and much more. I'm here to make your
digital interactions easier and more enjoyable. How may I help you today?

>>> can you speak japanese?
 Yes, I can speak Japanese! I have been programmed to understand and generate responses in multiple languages,
including Japanese. Let me know if there is something specific you would like me to do or say in Japanese.

>>> 日本語で回答お願いいたします。fizzbuzzのプログラムを作成してください。htmlファイル一つで、内部でJavaScriptを使っ
... て、1から100までの数字を表示しますが、3の倍数の時はfizz、5の倍数の時はbuzz、3と5両方の倍数の時はfizzbuzz
... と表示する、というものです。
 Sure! Here is a simple HTML file with JavaScript that fulfills your request. This code will display the
FizzBuzz sequence from 1 to 100, where multiples of 3 are labeled as "fizz," multiples of 5 as "buzz," and
multiples of both 3 and 5 as "fizzbuzz."

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>FizzBuzz</title>
</head>
<body>
    <ul id="fizzbuzz"></ul>
    <script>
        function fizzBuzz() {
            const fizzBuzzList = document.getElementById('fizzbuzz');

            for (let i = 1; i <= 100; i++) {
                let output = '';

                if (i % 3 === 0) {
                    output += 'Fizz';
                }

                if (i % 5 === 0) {
                    output += 'Buzz';
                }

                if (output.length === 0) {
                    output += i;
                }

                const li = document.createElement('li');
                li.textContent = output;
                fizzBuzzList.appendChild(li);
            }
        }

        window.onload = function() {
            fizzBuzz();
        };
    </script>
</body>
</html>
>>> /bye


image.png

中略

image.png

大丈夫そう。


#後片付け
もし容量がいっぱいになったとか、
もうこのモデルは不要、となった場合、以下のコマンドで削除しましょう。

「ollama list」で削除対象を確認します。

「ollama rm」で削除しましょう。

*実行例

PS D:\opt\Ollama> ollama list
NAME                    ID              SIZE      MODIFIED
llm-jp-13b-v2:latest    431faa45aafe    8.3 GB    4 minutes ago
mistral:latest          f974a74358d6    4.1 GB    58 minutes ago
gemma3:4b               a2af6cc3eb7f    3.3 GB    11 hours ago
gemma3:1b               8648f39daa8f    815 MB    11 hours ago

PS D:\opt\Ollama> ollama rm llm-jp-13b-v2:latest
deleted 'llm-jp-13b-v2:latest'


ブラウザベースでの会話も試してみました。
今回の手順にちょっと付け加えるだけで、
インターネットなしで、chatGPTやGemini、CopilotのようなチャットAIが、
お手元のパソコンで動きますよ、試してみよう、という記事です。

3
2
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
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?