LLMs之Llama-3:Llama-3.3的简介、安装和使用方法、案例应用之详细攻略

LLMs之Llama-3:Llama-3.3的简介、安装和使用方法、案例应用之详细攻略

目录

相关文章

LLMs之LLaMA:LLaMA的简介、安装和使用方法、案例应用之详细攻略

LLMs之LLaMA-2:LLaMA 2的简介(技术细节)、安装、使用方法(开源-免费用于研究和商业用途)之详细攻略

LLMs之Llama-3:Llama 3的简介、安装和使用方法、案例应用之详细攻略

LLMs之llama3-from-scratch:llama3-from-scratch(从头开始利用pytorch来实现并解读LLaMA-3模型的每层代码)的简介、核心思路梳理

LLMs之Llama-3.1:Llama 3.1的简介、安装和使用方法、案例应用之详细攻略

MLM之Llama-3:Llama 3.2的简介、安装和使用方法、案例应用之详细攻略

LLMs之Llama-3:Llama-3.3的简介、安装和使用方法、案例应用之详细攻略

Llama-3.3的简介

1、Meta Llama 3.3 的模型信息

2、特点

3、基准测试

4、伦理考量和局限性

Llama-3.3的安装和使用方法

1、安装

2、使用方法

使用llama

工具使用 (Tool use with transformers)

使用bitsandbytes

3、责任与安全

Llama 3.3的案例应用


相关文章

LLMs之LLaMA:LLaMA的简介、安装和使用方法、案例应用之详细攻略

LLMs之LLaMA:LLaMA的简介、安装和使用方法、案例应用之详细攻略_chinese_calendar每年手动更新-CSDN博客

LLMs之LLaMA-2:LLaMA 2的简介(技术细节)、安装、使用方法(开源-免费用于研究和商业用途)之详细攻略

LLMs之LLaMA-2:LLaMA-2的简介(技术细节)、安装、使用方法(开源-免费用于研究和商业用途)之详细攻略_llama2-CSDN博客

LLMs之Llama-3:Llama 3的简介、安装和使用方法、案例应用之详细攻略

LLMs之Llama 3:Llama 3的简介、安装和使用方法、案例应用之详细攻略-CSDN博客

LLMs之llama3-from-scratch:llama3-from-scratch(从头开始利用pytorch来实现并解读LLaMA-3模型的每层代码)的简介、核心思路梳理

https://yunyaniu.blog.csdn.net/article/details/139078566

LLMs之Llama-3.1:Llama 3.1的简介、安装和使用方法、案例应用之详细攻略

LLMs之Llama 3.1:Llama 3.1的简介、安装和使用方法、案例应用之详细攻略-CSDN博客

MLM之Llama-3:Llama 3.2的简介、安装和使用方法、案例应用之详细攻略

MLM之Llama-3:Llama 3.2的简介、安装和使用方法、案例应用之详细攻略_llama 3.2安装教程-CSDN博客

LLMs之Llama-3:Llama-3.3的简介、安装和使用方法、案例应用之详细攻略

LLMs之Llama-3:Llama-3.3的简介、安装和使用方法、案例应用之详细攻略-CSDN博客

Llama-3.3的简介

2024年12月6日,Meta发布,Llama 3.3是一个70B参数的多语言大型语言模型(LLM),经过预训练和指令微调,支持多种语言的文本输入和输出,在常见行业基准测试中优于许多开源和闭源聊天模型。经过精心设计,在多个基准测试中表现出色,并具有明确的许可协议和反馈机制。

Meta Llama 3.3是一个强大的多语言大型语言模型,在多个基准测试中表现出色。它具有广泛的应用前景,但同时也存在一些伦理和安全方面的挑战。Meta 采取了多项措施来确保模型的安全性和负责任的使用,包括采用三管齐下的安全策略、进行全面的红队测试、提供多种工具和资源,以及积极参与开源社区。开发人员在使用Llama 3.3时,需要遵守许可协议,注意其使用范围和局限性,并进行必要的安全测试和微调,以确保其应用的安全性和可靠性。 模型的开放性、包容性和有用性是其核心价值观,但同时也需要持续关注和改进,以最大限度地减少潜在风险。

总而言之,Llama 3.3 70B 模型是一个高性能、低成本、多语言、注重安全性的生成式 AI 模型,在教育、软件开发和企业应用等多个领域具有广泛的应用前景。

HuggingFacehttps://huggingface.co/meta-llama/Llama-3.3-70B-Instruct

官网https://www.llama.com/docs/overview/

GitHubllama-models/models/llama3_3/MODEL_CARD.md at main · meta-llama/llama-models · GitHub

1、Meta Llama 3.3 的模型信息

>> 模型架构:基于优化的Transformer架构的自回归语言模型,微调版本使用监督微调(SFT)和基于人类反馈的强化学习(RLHF)来对齐人类对有用性和安全性的偏好。

>> 训练数据:使用了公开可用的在线数据混合集,包含超过15万亿个token。截止日期为2023年12月。支持英语、德语、法语、意大利语、葡萄牙语、印地语、西班牙语和泰语。模型使用了分组查询注意力(GQA)以提高推理的可扩展性。

>> 模型发布日期:70B指令微调版本:2024年12月6日。这是一个基于离线数据集训练的静态模型,未来版本将随着社区反馈改进模型安全性而发布。

>> 许可证:采用自定义商业许可证——Llama 3.3社区许可协议 (https://github.com/meta-llama/llama-models/blob/main/models/llama3_3/LICENSE)。

2、特点

Llama 3.3适用于多种语言的商业和研究用途。指令微调的纯文本模型适用于类似助手的聊天,而预训练模型可以适应各种自然语言生成任务。Llama 3.3模型还支持利用其模型的输出改进其他模型,包括合成数据生成和蒸馏。Llama 3.3社区许可证允许这些用例。

>> 微调数据:采用多方面的方法收集数据,结合来自供应商的人工生成数据和合成数据,以减轻潜在的安全风险。

>> 强大的性能,成本更低:Llama 3.3 70B 模型的性能与 Meta Llama 405B 模型相似,但成本更低,使高质量的生成式 AI 能够惠及更广泛的受众。

>> 改进的输出:能够生成逐步推理和准确的 JSON 响应,以满足结构化数据需求。

>> 扩展的语言支持:支持八种主要语言,包括英语、法语、印地语和泰语等,具有多语言能力。

>> 增强的编码能力:涵盖更多编程语言,改进错误处理,并提供详细的代码反馈。

>> 任务感知工具使用:更智能的工具调用,尊重预定义参数并避免不必要的调用。

>> 新功能:本版本引入了新功能,包括更长的上下文窗口多语言输入和输出以及开发人员与第三方工具的集成。

>> 评估:对Llama模型进行了常见用例和特定功能的评估。常见用例评估衡量了大多数常用应用程序(包括聊天机器人、编码助手、工具调用)系统的安全风险。

>> 红队测试:进行了反复的红队测试,目的是通过对抗性提示发现风险,并利用这些经验来改进基准测试和安全微调数据集。

>> 注重责任:Meta 的安全协议确保模型不仅强大,而且符合道德 AI 标准。内置安全防护措施,例如 Llama Guard 3 和 Prompt Guard,可防止滥用。

>> 开源合作:Meta积极参与开放联盟,包括AI联盟、人工智能合作组织和MLCommons,积极为安全标准化和透明度做出贡献。

>> 社区资源:提供了一套资源,包括输出报告机制和漏洞赏金计划,以在社区的帮助下不断改进Llama技术。

>> 其他语言支持:Llama 3.3已在比8种支持语言更广泛的语言集合上进行了预训练。开发者可以对Llama 3.3模型进行微调以支持这8种语言之外的语言,前提是他们遵守Llama 3.3社区许可证和《可接受使用政策》,在这种情况下,开发者有责任确保在其他语言中使用Llama 3.3的方式安全可靠。

3、基准测试

指令微调模型:列出了Llama 3.3与之前模型在多个基准测试上的结果比较,包括MMLU、Steerability、Reasoning、Code、Math和Multilingual等方面。

4、伦理考量和局限性

>> 核心价值观:Llama 3.3的核心价值观是开放性、包容性和有用性。

>> 潜在风险:Llama 3.3是一项新技术,与任何新技术一样,其使用也存在风险。迄今为止进行的测试并未涵盖所有场景,模型在某些情况下可能会产生不准确、有偏差或其他令人反感的回应。

>> 开发人员责任:在部署任何Llama 3.3模型应用程序之前,开发人员应进行针对其特定模型应用程序的安全测试和微调。

Llama-3.3的安装和使用方法

1、安装

>> 使用Transformers:提供了使用Transformers库 (版本>=4.45.0) 进行对话式推理的代码示例,包括使用pipeline和Auto类以及generate()函数。

>> 训练因素:使用自定义训练库、Meta的定制GPU集群和生产基础设施进行预训练。微调、标注和评估也在生产基础设施上进行。

>> 训练能耗:在H100-80GB(TDP为700W)类型的硬件上使用了累计3930万GPU小时的计算量。表格中列出了训练时间、训练功耗、基于位置的温室气体排放量和基于市场的温室气体排放量。

>> 训练数据:预训练数据来自公开来源,约15万亿个token。微调数据包括公开可用的指令数据集以及超过2500万个合成生成的示例。预训练数据的截止日期为2023年12月。

2、使用方法

提供了使用Llama 3.3模型的不同方法,包括使用流行的深度学习库Transformers和bitsandbytes进行高效的推理和内存优化,以及使用原始llama代码库的方法。

使用llama

建议遵循代码库中的说明。提供了使用huggingface-cli下载原始检查点的命令示例。

import transformers
import torch

model_id = "meta-llama/Llama-3.3-70B-Instruct"

pipeline = transformers.pipeline(
    "text-generation",
    model=model_id,
    model_kwargs={"torch_dtype": torch.bfloat16},
    device_map="auto",
)

messages = [
    {"role": "system", "content": "You are a pirate chatbot who always responds in pirate speak!"},
    {"role": "user", "content": "Who are you?"},
]

outputs = pipeline(
    messages,
    max_new_tokens=256,
)
print(outputs[0]["generated_text"][-1])

工具使用 (Tool use with transformers)

支持多种工具使用格式,并提供了使用Transformers的聊天模板进行工具调用的示例,包括定义工具、创建聊天和应用聊天模板,以及处理模型生成的工具调用和结果。

# First, define a tool
def get_current_temperature(location: str) -> float:
    """
    Get the current temperature at a location.
    
    Args:
        location: The location to get the temperature for, in the format "City, Country"
    Returns:
        The current temperature at the specified location in the specified units, as a float.
    """
    return 22.  # A real function should probably actually get the temperature!

# Next, create a chat and apply the chat template
messages = [
  {"role": "system", "content": "You are a bot that responds to weather queries."},
  {"role": "user", "content": "Hey, what's the temperature in Paris right now?"}
]

inputs = tokenizer.apply_chat_template(messages, tools=[get_current_temperature], add_generation_prompt=True)

你可以像平常一样从这个输入生成文本。如果模型生成了一个工具调用,你应该像这样将其添加到聊天中:

tool_call = {"name": "get_current_temperature", "arguments": {"location": "Paris, France"}}
messages.append({"role": "assistant", "tool_calls": [{"type": "function", "function": tool_call}]})

然后调用该工具,并将结果附加到其中,就像这样:

messages.append({"role": "tool", "name": "get_current_temperature", "content": "22.0"})

在此之后,您可以再次生成(),让模型在聊天中使用工具的结果。请注意,这只是对工具调用非常简要的介绍——如需了解更多信息,请参阅LLaMA提示格式文档和Transformers工具使用文档。

使用bitsandbytes

可以使用bitsandbytes和Transformers库对模型进行8位和4位量化,以优化内存使用。提供了相应的代码示例。

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

model_id = "meta-llama/Llama-3.3-70B-Instruct"
quantization_config = BitsAndBytesConfig(load_in_8bit=True)

quantized_model = AutoModelForCausalLM.from_pretrained(
    model_id, device_map="auto", torch_dtype=torch.bfloat16, quantization_config=quantization_config)

tokenizer = AutoTokenizer.from_pretrained(model_id)
input_text = "What are we having for dinner?"
input_ids = tokenizer(input_text, return_tensors="pt").to("cuda")

output = quantized_model.generate(**input_ids, max_new_tokens=10)

print(tokenizer.decode(output[0], skip_special_tokens=True))

3、责任与安全

>> 负责任的发布方法:采用了三管齐下的策略来管理信任和安全风险:使开发人员能够为其目标受众和Llama支持的用例部署有用、安全和灵活的体验;保护开发人员免受试图利用Llama功能造成潜在危害的恶意用户的攻击;为社区提供保护,以帮助防止滥用我们的模型。

>> 负责任的部署:Llama是一个基础技术,设计用于各种用例。Meta的Llama模型的负责任部署示例可以在其社区故事网页上找到。

>> Llama 3.3指令微调:安全微调的主要目标是为研究界提供一个宝贵的资源,用于研究安全微调的稳健性,并为开发人员提供一个随时可用、安全且强大的模型,用于各种应用程序,以减少开发人员部署安全AI系统的工作量。

Llama 3.3的案例应用

持续更新中……

>> 教育领域:为学生和教育工作者提供多语言 AI 助手。

>> 软件开发领域:通过准确的代码辅助来提高生产力。

>> 企业应用:简化客户支持、数据分析和内容生成。

### LLaMA-Factory Intel Integration and Adaptation Guide For integrating or adapting the LLaMA-Factory project with Intel hardware, understanding how to leverage specific features of Intel processors is crucial. The belief exists that providing an appropriate context can guide large language models (LLMs) effectively without altering their parameters[^1]. This principle applies when configuring environments where LLaMA-Factory operates. #### Environment Setup To ensure optimal performance on Intel platforms, it&#39;s important to set up the environment correctly: - **Compiler Selection**: Use compilers optimized for Intel architectures such as `icc` (Intel C++ Compiler). These compilers offer better optimization options specifically tailored towards Intel CPUs. - **Library Dependencies**: Utilize libraries like MKL (Math Kernel Library), which are highly optimized for Intel processors. Installing these through package managers compatible with your system ensures seamless integration. ```bash sudo apt-get install libmkl-dev ``` #### Performance Optimization Tips Optimizing model inference involves several considerations: - **Thread Affinity Settings**: Adjust thread affinity settings using tools provided by Intel to bind threads closely related tasks together within physical cores. This reduces cache misses improving overall efficiency. - **Memory Management**: Employ efficient memory management techniques including pre-fetching data into caches before actual usage begins. Tools like VTune Profiler help identify bottlenecks allowing targeted improvements. #### Example Code Snippet Demonstrating Thread Binding Using OpenMP Below demonstrates binding threads explicitly during parallel execution phases ensuring maximum utilization of available CPU resources. ```cpp #include <omp.h> int main() { omp_set_num_threads(8); // Set number of threads based on target architecture #pragma omp parallel { int tid = omp_get_thread_num(); printf("Hello World from thread %d\n", tid); // Bind current thread ID to core cpu_set_t cpuset; CPU_ZERO(&cpuset); CPU_SET(tid, &cpuset); pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); } } ``` --related questions-- 1. How does one configure compiler flags for best performance with Intel-specific optimizations? 2. What role do Intel’s Math Kernel Libraries play in enhancing computational speed for machine learning applications? 3. Can you provide more details about profiling tools offered by Intel for identifying performance issues? 4. Are there any known challenges associated with deploying LLaMA-Factory on multi-core systems? 5. In what ways might adjusting thread affinities impact real-world application scenarios involving deep learning workloads?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一个处女座的程序猿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值