【大语言模型LLM】-Ollama+Llama3 部署你自己的大语言模型

在这里插入图片描述

🔥博客主页西瓜WiFi

🎥系列专栏《大语言模型》

很多非常有趣的模型,值得收藏,满足大家的收集癖! 如果觉得有用,请三连👍⭐❤️,谢谢!

长期不定时更新,欢迎watch和fork!❤️❤️❤️

❤️感谢大家点赞👍 收藏⭐ 评论⭐


🎥大语言模型LLM基础-系列文章

【大语言模型LLM】- AI工具收录集合,一篇就够了!
【大语言模型LLM】-大语言模型如何编写Prompt?
【大语言模型LLM】-如何使用大语言模型提高工作效率?
【大语言模型LLM】-使用大语言模型搭建点餐机器人
【大语言模型LLM】-基础语言模型和指令微调的语言模型

持续更新中…

一、电脑配置要求

  • 推荐16GB内存以上,最低8GB。
  • 最近几年的CPU均可。
  • 有英伟达显卡性能表现会更好,但不是必须。

二、Ollama 介绍

在这里插入图片描述
Ollama是一个开源的大模型管理工具,它支持模型的训练、部署和监控等功能。通过使用Ollama,用户可以轻松地管理本地的大模型,从而提高模型的训练速度和部署效率。此外,Ollama还支持多种机器学习框架,如TensorFlow和PyTorch等,使用户可以根据自己的需求选择合适的框架进行模型的训练。

Ollama不仅是一个大型语言模型服务,提供了类似OpenAI的API接口和聊天界面,还支持热加载模型文件,使得部署最新版本的GPT模型并通过接口使用变得非常方便。它是基于Go语言开发的,可以帮助用户在本地快速运行大模型,通过简单的安装指令,可以用一条命令就在本地运行大模型。

Ollama的功能还包括启动并运行大型语言模型,如Llama 2、Code Llama和其他模型,以及自定义并创建用户自己的模型。它支持GPU/CPU混合模式,允许用户根据自己笔记本电脑的GPU和GPU显存来选择运行模式。

此外,Ollama被设计用于在Docker容器中部署LLM(大型语言模型),其主要功能是在Docker容器内部署和管理LLM,使该过程变得非常简单。它还提供了与微软AI合作的最先进的大型语言模型合集,这些模型在复杂的聊天、多语言、推理和代理用例上提高了性能。

Ollama是一个功能强大的工具,适用于需要在本地部署和管理大型语言模型的用户。它支持多种机器学习框架,提供API接口和聊天界面,支持GPU/CPU混合模式,并且可以通过Docker容器简化部署过程。

三、部署流程

  • 下载安装 Ollama
  • 下载 Llama3 大模型
ollama run llama3

在这里插入图片描述

第一次运行要下载大模型,下载的快慢取决于你的网速。

  • 使用 Python ,API调用
import requests


def get_lamma_response(prompt):
    # 定义请求的 URL
    url = 'http://localhost:11434/api/chat'
    # 定义请求的数据
    data = {
        "model": "llama3",
        "messages": [
            {
                "role": 'user',
                "content": prompt
            }
        ],
        "stream": False
    }
    # 发送 POST 请求
    response = requests.post(url, json=data)
    # 获取响应内容
    response_data = response.json()

    return response_data['message']['content']


prompt='''
why is the sky blue?
'''
response = ollama_model(prompt)

print(response)
The sky appears blue to us because of a combination of factors involving light, atmosphere, and our own perception. Here's a breakdown:

1. **Sunlight**: When sunlight enters Earth's atmosphere, it contains all the colors of the visible spectrum (red, orange, yellow, green, blue, indigo, and violet). The shorter wavelengths of light, like blue and violet, are more easily scattered by the tiny molecules of gases like nitrogen (N2) and oxygen (O2).
2. **Atmospheric scattering**: As sunlight interacts with these gas molecules, it scatters in all directions. This scattering effect is more pronounced for shorter wavelengths (like blue and violet) than longer wavelengths (like red and orange). Think of it like a game of pool: the smaller balls (shorter wavelengths) are more likely to bounce around and change direction than the larger balls (longer wavelengths).
3. **Rayleigh scattering**: In 1871, Lord Rayleigh discovered that the amount of scattering depends on the wavelength of light and the size of the particles involved. This phenomenon is now known as Rayleigh scattering. It's responsible for the blue color we see in the sky during the daytime.
4. **Perception**: Our brains are wired to perceive the blue light that reaches our eyes as a dominant feature of the sky. The scattered blue light from all directions appears to come from above, creating the illusion of a blue sky.
5. **Earth's atmosphere**: The color of the sky can also be influenced by various atmospheric conditions, such as:
	* Dust and pollutants: These particles can scatter light in different ways, making the sky appear more hazy or gray.
	* Water vapor: High levels of water vapor can make the sky appear more white or cloudy.
	* Aerosols: Tiny particles in the air, like those from volcanic eruptions or human activities, can scatter light and change the apparent color of the sky.

In summary, the combination of sunlight, atmospheric scattering (especially Rayleigh scattering), and our perception of the scattered blue light creates the blue color we see in the sky. The Earth's atmosphere can also influence this appearance through various factors.

Llama3的发布对AI行业产生了深远影响。目前已经出现中文版本微调模型了,不过目前这个项目还不算完善,距离完成还有很长的路要走。虽然微调模型是在预训练的基础上做的微调,但事实上预训练和微调是两个不同的概念。预训练只是为了让模型更好的掌握基础知识,而微调则是为了让模型在不同任务中表现得更好。尽管目前国内也有一些针对Llama3的微调模型,但还不够完善,而且并不能做到通用。
目前国内对Llama3微调模型的支持主要还是通过开源社区获取,这是因为Llama3开源社区目前处于起步阶段,很多细节都还没有完善,不过我相信在不久的将来会有更多针对Llama3的微调模型出现。

相关推荐

  1. AI:语言模型LLM

    2024-04-30 09:04:01       39 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-04-30 09:04:01       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-04-30 09:04:01       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-04-30 09:04:01       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-04-30 09:04:01       18 阅读

热门阅读

  1. 电路邱关源学习笔记——3.1电路的图

    2024-04-30 09:04:01       11 阅读
  2. 排序 + 模拟,LeetCode 1329. 将矩阵按对角线排序

    2024-04-30 09:04:01       13 阅读
  3. 【MySQL】如何在MySQL中编写循环

    2024-04-30 09:04:01       12 阅读
  4. 如何贡献开源项目:Git 入门指南

    2024-04-30 09:04:01       9 阅读