【大语言模型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 大模型
bash 复制代码
ollama run llama3

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

  • 使用 Python ,API调用
python 复制代码
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的微调模型出现。

相关推荐
1989几秒前
【零基础学AI】第31讲:目标检测 - YOLO算法
人工智能·rnn·yolo·目标检测·tensorflow·lstm
沐尘而生4 分钟前
【AI智能体】智能音视频-硬件设备基于 WebSocket 实现语音交互
大数据·人工智能·websocket·机器学习·ai作画·音视频·娱乐
巴伦是只猫8 分钟前
【机器学习笔记Ⅰ】3 代价函数
人工智能·笔记·机器学习
NetX行者9 分钟前
基于Vue 3的AI前端框架汇总及工具对比表
前端·vue.js·人工智能·前端框架·开源
hans汉斯35 分钟前
【人工智能与机器人研究】基于力传感器坐标系预标定的重力补偿算法
人工智能·算法·机器人·信号处理·深度神经网络
cver12343 分钟前
CSGO 训练数据集介绍-2,427 张图片 AI 游戏助手 游戏数据分析
人工智能·深度学习·yolo·目标检测·游戏·计算机视觉
FreeBuf_1 小时前
新型BERT勒索软件肆虐:多线程攻击同时针对Windows、Linux及ESXi系统
人工智能·深度学习·bert
强哥之神1 小时前
Meta AI 推出 Multi - SpatialMLLM:借助多模态大语言模型实现多帧空间理解
人工智能·深度学习·计算机视觉·语言模型·自然语言处理·llama
成都极云科技1 小时前
成都算力租赁新趋势:H20 八卡服务器如何重塑 AI 产业格局?
大数据·服务器·人工智能·云计算·gpu算力
喜欢吃豆1 小时前
从零构建MCP服务器:FastMCP实战指南
运维·服务器·人工智能·python·大模型·mcp