slot deposit pulsa slot mahjong slot gacor slot gacor slot gacor resmi slot gacor 2025 slot gacor terpercaya slot gacor 2025 slot gacor hari ini slot gacor hari ini slot gacor hari ini
什么是 Ollama?您应该知道的所有重要信息
17611538698
webmaster@21cto.com

什么是 Ollama?您应该知道的所有重要信息

人工智能 0 7180 2024-07-10 08:13:28

图片

导读:本文回答有关 Ollama 的常见问题。

Ollama 是一个免费的开源项目,可让您在本地运行各种开源 LLM。

无论您想使用像 Codestral 这样的开源 LLM 来生成代码,还是使用 LLaMa 3 作为ChatGPT 的替代方案,Ollama 都可以实现。

但这些是您可以在系统上使用 Ollama 本地实现的最终目标。您需要知道什么才能实现这一点?您如何做到这一切?

在本文中,我将提供有关 Ollama 的所有必要信息。

什么是 Ollama?


Ollama是一款免费的开源工具,可让任何人在系统上本地运行开放的 LLM。它支持 Linux(由 Systemd 提供支持的发行版)、Windows 和 macOS(Apple Silicon)。


Ollama 是一个命令行界面 (CLI) 工具,可让开发者方便地下载 LLM 并在本地私下运行。


只需要使用几个命令,您可以轻松下载 Llama 3、Mixtral 等模型。


我们将其完全想象成 Docker。使用 Docker,您可以从中央存储库下载各种像并在容器中运行它们。


同样地,使用 Ollama,您可以下载各种开源 LLM,然后在终端中运行它们。


下载Ollama


如果要下载 Ollama,请您访问Ollama官方网站- https://ollama.com/,并且请点击“download”按钮下载。


图片
图-1 Ollama.com 官网主页


Ollama 支持 3 种不同的操作系统,当前 Windows 版本尚处于预览版模式。

图片
图-2 Ollama之下载页面

你可以根据自己的操作系统选择可执行文件,成功下载可执行文件后,可以通过运行可执行文件来安装。


对于 Linux 用户,你需要执行屏幕上显示的命令,而不能下载可执行文件。

如何运行Ollama


为了向大家展示在本地使用开源模型的强大功能,我将展示具有不同用例的不同开源模型的多个示例。这将帮助你轻松使用任何未来的开源 LLM 模型。


现在,让我们开始第一个示例!


如何从 Meta 运行 LLama2 模型


Llama 2 模型是 Meta 的开源 LLM 模型,我们将像使用 ChatGPT(免费版本)一样与它交互,目前首先执行基于文本的交互。


首先,我们使用以下命令下载模型:


ollama run llama2br

下载该模型时,我们应该会看到以下与此类似的输出。

请等待一段时间:

pulling manifestpulling 8934d96d3f08... 100% ▕██████████████████████████████████████████████████████████████████████████████████████████▏ 3.8 GBpulling 8c17c2ebb0ea... 100% ▕██████████████████████████████████████████████████████████████████████████████████████████▏ 7.0 KBpulling 7c23fb36d801... 100% ▕██████████████████████████████████████████████████████████████████████████████████████████▏ 4.8 KBpulling 2e0493f67d0c... 100% ▕██████████████████████████████████████████████████████████████████████████████████████████▏ 59 Bpulling fa304d675061... 100% ▕██████████████████████████████████████████████████████████████████████████████████████████▏ 91 Bpulling 42ba7f8a01dd... 100% ▕██████████████████████████████████████████████████████████████████████████████████████████▏ 557 Bverifying sha256 digestwriting manifestremoving any unused layerssuccess>>> Send a message (/? for help)br

现在它应该要求你发送消息或相关提示。

比如我们问 llama2:“你能为我做点啥?” (其实,你想问什么都可以,中文也没问题)。

如果你问了与上面相同的问题,那么应该能得到这样的答复:

>>> What can you do for me?As a responsible AI language model, I am here to assist you with any questions or tasks you may have. Here are some examples of things I can helpwith:1. Answering questions: I can provide information on a wide range of topics, from science and technology to history and culture.2. Generating ideas: I can help you brainstorm ideas for creative projects, or provide suggestions for solving problems.3. Writing assistance: I can help you with writing tasks such as proofreading, editing, and suggesting alternative words or phrases.4. Translation: I can translate text from one language to another.5. Summarizing content: I can summarize long pieces of text, such as articles or documents, into shorter, more digestible versions.6. Creativity: I can help you generate creative ideas for stories, poems, or other forms of writing.7. Language learning: I can assist you in learning a new language by providing grammar explanations, vocabulary lists, and practice exercises.8. Chatting: I'm here to chat with you and provide a response to any question or topic you'd like to discuss.Please let me know if there is anything specific you would like me to help you with.>>> Send a message (/? for help)br

上面是我从 llama2 得到的回应。

如果要退出实用程序,可以键入/exit。

现在,让我们运行一个多模式模型,你可以在其中发送图像并基于该图像提出相关的问题。

运行 LLaVA 模型


LLaVA 是一个开源多模式 LLM 模型。多模态模型可以接受多种类型的输入并相应地生成响应。


使用这个模型,我们现在将传递一个图像并基于该图像提出一个问题。

首先,让我们下载该模型:

ollama run llavabr

成功下载模型后,你应该可能在终端中看到类似以下内容:

pulling manifestpulling 170370233dd5... 100% ▕██████████████████████████████████████████████████████████████████████████████████████████▏ 4.1 GBpulling 72d6f08a42f6... 100% ▕██████████████████████████████████████████████████████████████████████████████████████████▏ 624 MBpulling 43070e2d4e53... 100% ▕██████████████████████████████████████████████████████████████████████████████████████████▏ 11 KBpulling c43332387573... 100% ▕██████████████████████████████████████████████████████████████████████████████████████████▏ 67 Bpulling ed11eda7790d... 100% ▕██████████████████████████████████████████████████████████████████████████████████████████▏ 30 Bpulling 7c658f9561e5... 100% ▕██████████████████████████████████████████████████████████████████████████████████████████▏ 564 Bverifying sha256 digestwriting manifestremoving any unused layerssuccess>>> Send a message (/? for help)br

我在 pexels.com上找到一张图片,下载到了本地的download的目录,然后将路径名和文件名发给了LLaVA。

以下是我从 LLaVA 得到的输出:

>>> What's in this image? ./Downloads/test-image-for-llava.jpegAdded image './Downloads/test-image-for-llava.jpeg' The image shows a person walking across a crosswalk at an intersection. There are traffic lights visible, and the street has a bus parked on oneside. The road is marked with lane markings and a pedestrian crossing signal. The area appears to be urban and there are no visible buildings orstructures in the immediate vicinity of the person.>>> Send a message (/? for help)br

你将可以看到它对图像的准确解释。我们还可以随意尝试其他东西,就可以充分享受其中的美好乐趣了。

结论


就是这些,好不好玩?借助 Ollama,我们可以在自己的计算机上尝试强大的 LLM,例如 LLaMA 2 和 LLaVA。


快快下载 Ollama ,一起探索开源大语言模型激动人心的世界!~

作者:小强

评论