自己只能跑llama3-8b模型,告诉你一个免费使用llama3-70b的方法

智能也得细细瞧 2024-05-26 03:03:56

我们前期,以及本地但是想体验一下llama3-70b的模型的话,需要很大的计算资源,且要求极高的内存。llama3-8b的模型约4.7G ,而llama3-70b的模型约40G,若想在自己的电脑上面加载llama3-70b的模型,可想而知需要多少的内存,多少的显卡资源。

Meta llama 3

Llama 3是Meta AI开源的第三代Llama系列模型,其新的 8B 和 70B 参数 Llama 3 模型在Llama 2的基础上,实现了更大性能的提升。由于预训练和训练后的技术改进,其Llama 3模型是当今 8B 和 70B 参数规模的最佳模型。Llama 3模型的改进大大降低了错误拒绝率,改善了一致性,并增加了模型响应的多样性。Llama 3模型在推理、代码生成和指令跟踪等功能也得到了极大的改善。

Nvidia

无论是大语言模型,还是文生视频,文生图模型,都需要大量的显卡资源,而Nvidia的显卡一定是研发团队考虑的重点显卡配置。随着Llama系列开源以来,而Nvidia也拿出了自己的诚意,在自己官方网站上线了Llama系列的模型,不仅搭建了完美的UI界面供大家使用,而且还是免费的使用资源。

llama3-70b Nvidia

在Nvidia官方界面,可以很容易的使用llama3-70b模型。界面提供2种使用llama3-70b的方式,一是可以直接在界面聊天框中输入内容,跟llama3-70b模型聊天,另外要给是使用Nvidia提供的API接口。

llama3-70b模型

llama3-70b模型在Nvidia网站上面跑的速度还是极快的,而在自己电脑上面跑llama3-8b的模型有时还出现卡顿的现象,特别是一些稍微复杂的问题。

llama3 70b 中文能力

让他说中文,感觉回复的是英文,然后再翻译成中文,但是回复的内容中,其中文还是占少数,主要是英文为主。这在介绍llama3时也有介绍,其官方目前的训练数据还是以英文为主。

llama3 70b 编程能力

不得不说,各大模型对编码的处理还是很符合人意的,毕竟编程语言是固定的,且都是英文的形式,训练数据也可以直接用GitHub的数据。

llama3 70b 上下文记忆能力

而在Nvidia官网上使用的llama3 70b模型也支持上下文记忆,模型可以记录以前的聊天记录,若模型回复英文的答案,可以让模型进行翻译,其翻译效果还是很强大。

英文:Here is a Python implementation of the Bubble Sort algorithm:def bubble_sort(arr): n = len(arr) for i in range(n-1): for j in range(n-i-1): if arr[j] > arr[j+1]: arr[j], arr[j+1] = arr[j+1], arr[j] return arrHere's an explanation of how the algorithm works:The outer loop iterates n-1 times, where n is the length of the input array.The inner loop iterates from the first element to the n-i-1-th element.In each iteration of the inner loop, we compare the current element with the next element. If the current element is greater than the next element, we swap them.After each iteration of the outer loop, the largest element in the unsorted portion of the array "bubbles" up to the end of the sorted portion.The algorithm repeats steps 2-4 until the entire array is sorted.Here's an example usage:arr = [5, 2, 8, 3, 1, 6, 4]arr = bubble_sort(arr)print(arr) #[1, 2, 3, 4, 5, 6, 8]Note that Bubble Sort has a time complexity of O(n^2), which makes it less efficient than other sorting algorithms like QuickSort or MergeSort for large datasets. However, it's still a simple and easy-to-understand algorithm that can be useful for small datasets or educational purposes. 中文翻译:以下是 Python 实现的冒泡排序算法:def bubble_sort(arr): n = len(arr) for i in range(n-1): for j in range(n-i-1): if arr[j] > arr[j+1]: arr[j], arr[j+1] = arr[j+1], arr[j] return arr以下是算法的工作原理:外层循环迭代 n-1 次,其中 n 是输入数组的长度。内层循环从第一个元素迭代到 n-i-1 个元素。在内层循环的每次迭代中,我们比较当前元素与下一个元素。如果当前元素大于下一个元素,我们交换它们。在每次外层循环迭代后,未排序部分的最大元素“冒泡”到已排序部分的末尾。算法重复步骤 2-4,直到整个数组被排序。以下是一个示例用法:arr = [5, 2, 8, 3, 1, 6, 4]arr = bubble_sort(arr)print(arr) #[1, 2, 3, 4, 5, 6, 8]注意冒泡排序的时间复杂度为 O(n^2),这使得它对于大型数据集来说不如快速排序或归并排序那样高效。然而,它仍然是一个简单易懂的算法,对于小型数据集或教育目的来说非常有用。

代码实现llama3

当然,也可以使用官方提供的API搭建自己的聊天机器人,只需申请API key,输入如下代码,并把API key替换成自己的key即可。

from openai import OpenAIclient = OpenAI( base_url = "https://integrate.api.nvidia.com/v1", api_key = "$API_KEY_REQUIRED_IF_EXECUTING_OUTSIDE_NGC")completion = client.chat.completions.create( model="meta/llama3-70b-instruct", messages=[{"role":"user","content":"请翻译以上的内容,翻译成中文"}], temperature=0.5, top_p=0.7, max_tokens=1024, stream=True)for chunk in completion: if chunk.choices[0].delta.content is not None: print(chunk.choices[0].delta.content, end="")https://build.nvidia.com/meta/llama3-70bInference:Engine: TritonTest Hardware:H100-80G
0 阅读:0

智能也得细细瞧

简介:感谢大家的关注