地方エンジニアの学習日記

興味ある技術の雑なメモだったりを書いてくブログ。たまに日記とガジェット紹介。

【LLM】Ollamaとは

ollama.com

Ollamaは、ローカル環境でLLMを実行するためのオープンソースのプラットフォームです。これにより、クラウドに依存せず、自分のコンピュータ上で直接LLMを利用できるようになります。主にLlama2やMistralといったモデルをサポートしており、コマンドラインAPIを通じて簡単に操作可能です。これにより、データのプライバシーが守られ、クラウドAPIのコストを回避しながらLLMを使用できる利点があります​。

また、Ollamaでは自分でモデルを作成したり、Modelfileを用いてカスタマイズしたモデルを実行することもできます。Pythonのライブラリを使用してチャットボットを構築したり、REST APIを通じて他のシステムと統合することも可能です​

例えばDifyとかとも連携することができます。

qiita.com

使ってみる

ollama.com

ここから取ってくることでインストールできます。

$ ollama help
Large language model runner

Usage:
  ollama [flags]
  ollama [command]

Available Commands:
  serve       Start ollama
  create      Create a model from a Modelfile
  show        Show information for a model
  run         Run a model
  pull        Pull a model from a registry
  push        Push a model to a registry
  list        List models
  ps          List running models
  cp          Copy a model
  rm          Remove a model
  help        Help about any command

Flags:
  -h, --help      help for ollama
  -v, --version   Show version information

Use "ollama [command] --help" for more information about a command.
モデルを動かしてみる

ollama.com

使えるモデルはここにあります。

ollama.com

を使ってみます。サクサク動いてすごい。

$ ollama run llama3.1
>>> hello
Hello! How are you today? Is there something I can help you with or would you like to chat?

>>> What are the features of Linux?
Linux is a powerful and versatile operating system that has many features. Here are some of the key ones:

1. **Open-source**: Linux is free and open-source software, which means that its source code is available for anyone to modify and distribute.
2. **Highly customizable**: Linux can be customized to suit individual needs by modifying configuration files, installing new packages, or even building a
custom kernel.
3. **Stable and secure**: Linux has a reputation for being stable and secure due to its open-source nature, which encourages collaboration and bug-fixing from
the community.
4. **Multi-user support**: Linux can handle multiple users and provides various levels of access control and permissions.
5. **Network-oriented**: Linux is highly network-friendly and can connect to local area networks (LANs), wide area networks (WANs), and the internet easily.
6. **Support for various hardware architectures**: Linux can run on a variety of hardware platforms, including x86, ARM, PowerPC, and others.
7. **Package management**: Most Linux distributions come with package managers like RPM or DEB, which simplify software installation, updates, and removal.
8. **Extensive software library**: The Linux ecosystem has an impressive collection of open-source software applications, including productivity tools,
development environments, media players, and more.
9. **Scripting capabilities**: Linux offers a powerful scripting language called shell scripting (bash), which enables users to automate repetitive tasks and
create custom workflows.
10. **Virtualization support**: Many Linux distributions have built-in virtualization capabilities using technologies like KVM, Xen, or VirtualBox.

Some popular Linux features include:

* **File system management**: Linux supports various file systems, including ext4, XFS, and ZFS.
* **Security features**: Linux has built-in security features like access control lists (ACLs), SELinux, and AppArmor to protect against unauthorized access.
* **System monitoring tools**: Tools like top, htop, and sysdig provide detailed system information and performance metrics.
* **Remote desktop capabilities**: Linux supports remote desktop protocols like VNC, RDP, and SSH for easy remote access.

These are just a few of the many features that make Linux such a popular choice among developers, power users, and organizations.