Llama 3.1:开源语言模型的新里程碑

大家好,最近AI领域的新闻接踵而至,让人目不暇接。就在7月(23号)晚上,Meta发布了Llama 3.1系列模型,包括8B、70B参数的版本,以及此前提到过的400B参数模型(实际上是405B)。根据Meta官方公布的数据,Llama 3.1 405B参数模型在某些测试数据集上甚至略微胜过了GPT-4。今天,让我们一起来了解Llama 3.1的更新内容,以及如何免费使用这个令人期待的模型。

https://ai.meta.com/blog/meta-llama-3-1/https://ai.meta.com/blog/meta-llama-3-1/我测试了它写代码能力,让它用python写个贪吃蛇游戏,写代码速度很慢,但是一次成功,下面是它写的代码和,代码运行的效果。

python 复制代码
import pygame
import sys
import random

# Initialize Pygame
pygame.init()

# Set up some constants
WIDTH, HEIGHT = 800, 600
BLOCK_SIZE = 20
SPEED = 10

# Set up some colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = (0, 255, 0)

# Set up the display
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("Snake")

# Set up the font
font = pygame.font.Font(None, 36)

# Set up the snake and food
snake = [(200, 200), (220, 200), (240, 200)]
food = (400, 300)

# Set up the direction
direction = "RIGHT"

# Game loop
while True:
    # Event handling
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
        elif event.type == pygame.KEYDOWN:
            if event.key == pygame.K_UP and direction!= "DOWN":
                direction = "UP"
            elif event.key == pygame.K_DOWN and direction!= "UP":
                direction = "DOWN"
            elif event.key == pygame.K_LEFT and direction!= "RIGHT":
                direction = "LEFT"
            elif event.key == pygame.K_RIGHT and direction!= "LEFT":
                direction = "RIGHT"

    # Move the snake
    head = snake[-1]
    if direction == "UP":
        new_head = (head[0], head[1] - BLOCK_SIZE)
    elif direction == "DOWN":
        new_head = (head[0], head[1] + BLOCK_SIZE)
    elif direction == "LEFT":
        new_head = (head[0] - BLOCK_SIZE, head[1])
    elif direction == "RIGHT":
        new_head = (head[0] + BLOCK_SIZE, head[1])
    snake.append(new_head)

    # Check for collision with food
    if snake[-1] == food:
        food = (random.randint(0, WIDTH - BLOCK_SIZE) // BLOCK_SIZE * BLOCK_SIZE,
                random.randint(0, HEIGHT - BLOCK_SIZE) // BLOCK_SIZE * BLOCK_SIZE)
    else:
        snake.pop(0)

    # Check for collision with self or wall
    if (snake[-1] in snake[:-1] or
            snake[-1][0] < 0 or snake[-1][0] >= WIDTH or
            snake[-1][1] < 0 or snake[-1][1] >= HEIGHT):
        pygame.quit()
        sys.exit()

    # Draw everything
    screen.fill(BLACK)
    for pos in snake:
        pygame.draw.rect(screen, GREEN, (pos[0], pos[1], BLOCK_SIZE, BLOCK_SIZE))
    pygame.draw.rect(screen, RED, (food[0], food[1], BLOCK_SIZE, BLOCK_SIZE))
    text = font.render(f"Score: {len(snake)}", True, WHITE)
    screen.blit(text, (10, 10))
    pygame.display.flip()

    # Cap the frame rate
    pygame.time.delay(1000 // SPEED)

运行效果如下:

Llama 3.1的主要更新

  1. Context Window扩展:Llama 3.1将模型的Context Window从原来的8K tokens扩展到了128K tokens,极大地提升了处理长文和长对话的能力。

  2. 模型架构:Llama 3.1沿用了Llama 3的基础架构,即使是405B参数的模型也采用标准的decoder-only transformer架构,而非混合专家模型。同时继续使用GQA(分组查询注意力)技术,提高了长文处理能力。

  3. 性能表现

    • Llama 3.1 405B模型在多个测试数据集上超越了GPT-4o和Claude 3.5 Sonnet等顶级商业闭源模型。
    • 8B参数版本优于参数相近的Gemma 2 9B IT和Mistral 7B Instruct。
    • 70B参数版本不仅胜过开源模型Mixtral 8x22B,还在多项测试中大幅领先GPT-3.5 Turbo。
  4. 许可证更新:Meta更新了Llama 3.1的许可条款,允许使用模型输出来改进其他语言模型,但要求训练出的新模型名称必须以"Llama"开头,并标注"Built with Llama"。

  5. 指令微调:Llama 3.1的Instruct版本根据工具调用进行了微调,并引入了新的iPython角色来接收和记录工具调用返回的数据。

如何免费使用Llama 3.1

在线使用

  1. HuggingChat

  2. Groq

本地运行

推荐使用LM Studio程序:LM Studio - Discover, download, and run local LLMsLM Studio is an easy to use desktop app for experimenting with local and open-source Large Language Models (LLMs). The LM Studio cross platform desktop app allows you to download and run any ggml-compatible model from Hugging Face, and provides a simple yet powerful model configuration and inferencing UI. The app leverages your GPU when possible.https://lmstudio.ai/

  • 提供便捷的模型下载界面和对话窗口。
  • 使用llama.cpp进行模型推理,适合无独立显卡的设备。
  • 支持不同程度量化的模型版本,如Q4_K_M(推荐),平衡大小和性能。

结语

Llama 3.1的发布无疑是开源语言模型发展的一个重要里程碑。405B参数模型与顶级商业闭源模型的竞争力,以及8B参数模型超越Google Gemma 2 9B的表现,都展示了开源社区的巨大潜力。Meta允许将Llama 3.1用于知识蒸馏,这一决定将进一步推动开源AI社区的蓬勃发展。

让我们一起期待AI技术的持续进步,为更开放、更强大的语言模型贡献力量。

如果您喜欢这篇文章,欢迎点赞订阅我的频道。下期再见,各位兄弟朋友们请多保重!

相关推荐
云空23 分钟前
《探索电脑麦克风声音采集多窗口实时可视化技术》
人工智能·python·算法
麦兜*27 分钟前
【Spring Boot】Spring Boot 4.0 的颠覆性AI特性全景解析,结合智能编码实战案例、底层架构革新及Prompt工程手册
java·人工智能·spring boot·后端·spring·架构
张较瘦_31 分钟前
[论文阅读] 人工智能 | 5C提示词框架的研究
论文阅读·人工智能
超龄超能程序猿44 分钟前
使用 Python 对本地图片进行图像分类
开发语言·人工智能·python·机器学习·分类·数据挖掘·scipy
大千AI助手1 小时前
RLHF:人类反馈强化学习 | 对齐AI与人类价值观的核心引擎
人工智能·深度学习·算法·机器学习·强化学习·rlhf·人类反馈强化学习
我爱一条柴ya1 小时前
【AI大模型】RAG系统组件:向量数据库(ChromaDB)
数据库·人工智能·pytorch·python·ai·ai编程
MARS_AI_1 小时前
云蝠智能VoiceAgent重构企业电话客服体系
人工智能·自然语言处理·人机交互·交互·信息与通信
在猴站学算法5 小时前
机器学习(西瓜书) 第二章 模型评估与选择
人工智能·机器学习
科技宅说6 小时前
36氪专访丨乐橙CEO谢运:AI科技下的业务创新与长期主义下的品牌坚守
人工智能·科技
学术小八6 小时前
2025年人工智能、虚拟现实与交互设计国际学术会议
人工智能·交互·vr