发布于 2026-01-06 1 阅读
0

解锁 Meta Llama LLM 的强大功能:在本地开发环境中轻松托管指南 如何托管我自己的本地 AI 聊天代理? Mux 呈现的全球开发者展示挑战赛:展示你的项目!

解锁 Meta Llama LLM 的强大功能:轻松在本地开发环境中托管

如何托管我自己的本地 AI 聊天代理

由 Mux 赞助的 DEV 全球展示挑战赛:展示你的项目!

我在之前的文章中介绍了人工智能工具如何彻底改变了我的开发工作流程。在文章结尾,我分享了如何在本地计算机上部署 Meta Llama LLM 的详细步骤。

因为这些步骤一直放在博客的最后,所以我决定单独写一篇博客来介绍这些步骤,因为很多人都从中受益匪浅。

一探究竟!

如何托管我自己的本地 AI 聊天代理

接下来,我将带您了解我使用 Llama(以及其他可用的开源 AI 模型)的几个简单步骤:

步骤 1:在本地计算机上下载并安装 Ollama

访问Ollama 官方网站,快速下载适用于 Windows、Mac 或 Linux 系统的 Ollama。

Ollama 是一款轻量级工具,可让您在本地计算机上运行大型语言模型(例如 Llama 3.2、Mistral 和 Gemma 2)。安装后,您就可以在本地计算机上运行和自定义模型。

图片描述

步骤 2:运行 Ollama 设置向导

下载完成后,打开 Ollama Setup 可执行文件,并按照向导的指示在您的计算机上安装 Ollama 工具。

正如您所预期的,Ollama 的安装向导会快速添加运行 Ollama 工具所需的所有文件。

图片描述

步骤 3:验证 Ollama 安装

如果 Ollama 安装正确,您现在应该能够从标准命令提示符访问它。

有时,安装 Ollama 时会自动打开命令提示符窗口,如果没有自动打开,则需要手动打开。

在 Windows 电脑上,搜索“cmd”,即可打开命令提示符。

打开后,输入以下命令并按回车键/回车键来验证安装:

ollama
Enter fullscreen mode Exit fullscreen mode

你应该会看到类似这样的输出:

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
  stop        Stop a running 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.
Enter fullscreen mode Exit fullscreen mode

图片描述

步骤 4:安装并运行大型语言模型

安装 Ollama 后,我们距离在自己的机器上拥有本地 LLM 只差一步之遥了。

首先,让我们安装 Meta 的Llama3.2模型。

在命令提示符窗口中,输入:

ollama run llama3.2
Enter fullscreen mode Exit fullscreen mode

这样做会达到两个目的:

  1. 如果您的机器上当前没有安装 Llama3.2,请安装它。如果您的机器上当前没有安装 Llama3.2,请安装它。
  2. 运行 Llama3.2 模型

按下回车键,你应该会看到类似这样的内容(如果未安装 Llama3.2):

pulling manifest
pulling dde5aa3fc5ff...  26% ▕████████████                                            ▏ 532 MB/2.0 GB   32 MB/s     48s
Enter fullscreen mode Exit fullscreen mode

图片描述

Ollama 现在将在您的计算机上下载并安装 Llama3.2 模型,完成后,运行 llama3.2 模型供您交互。

在命令行窗口中,您应该会看到类似这样的内容:

pulling manifest
pulling dde5aa3fc5ff... 100% ▕████████████████████████████████████████████████████████▏ 2.0 GB
pulling 966de95ca8a6... 100% ▕████████████████████████████████████████████████████████▏ 1.4 KB
pulling fcc5a6bec9da... 100% ▕████████████████████████████████████████████████████████▏ 7.7 KB
pulling a70ff7e570d9... 100% ▕████████████████████████████████████████████████████████▏ 6.0 KB
pulling 56bb8bd477a5... 100% ▕████████████████████████████████████████████████████████▏   96 B
pulling 34bb5ab01051... 100% ▕████████████████████████████████████████████████████████▏  561 B
verifying sha256 digest
writing manifest
success
>>> Send a message (/? for help)
Enter fullscreen mode Exit fullscreen mode

图片描述

就这样,你的本地计算机上就拥有了一个LLM!

此外,如果您想安装Ollama 提供的任何其他模型,您可以使用相同的命令:

ollama run MODEL_NAME
Enter fullscreen mode Exit fullscreen mode

第五步:测试你的大型语言模型

现在Llama3.2已经安装在我们的机器上了,让我们来测试一下。

我们来问一个简单的问题:

Hey Llama! Could you tell me a little bit about yourself?
Enter fullscreen mode Exit fullscreen mode

您应该会收到类似这样的回复:

Hey Llama! Could you tell me a little bit about yourself?
I'm happy to chat with you. I'm an artificial intelligence model known as Llama, which stands for "Large Language
Model Meta AI." My primary function is to process and generate human-like text based on the input I receive.

I was trained on a massive dataset of text from various sources, including books, articles, and online
conversations. This training allows me to understand and respond to a wide range of questions, topics, and styles.

Some key features of my abilities include:

.....
Enter fullscreen mode Exit fullscreen mode

瞧!是不是很简单!

包起来

就这样,您的 Llama LLM 应该就能在您的本地计算机上轻松启动并运行了。

如果您有兴趣查看 Ollamas Docs,可以在这里找到它们。

如果您有兴趣了解一款能让您更轻松地使用 Ollama 的图形用户界面 (GUI),请查看Open Web UI。希望不久的将来能发布一篇博客文章,详细介绍如何设置它。

在此之前,尽情享受你的专属羊驼私人助理吧!


图片来源(按出现顺序):

使用 Google Gemini
主题拍摄的封面照片:
A llama with a confident smirk on its face, wearing a blue cape emblazoned with a infinity symbol, flies in against a sunset, ready to save the day in this cartoon style illustration.


关注我的社交媒体账号:
https://linktr.ee/bradstondev

文章来源:https://dev.to/bradstondev/unlock-the-power-of-meta-llama-llm-easy-guide-to-hosting-in-your-local-dev-environment-7d