我正在使用 Llama 创建一个应用程序。以前我使用过 openai,但正在寻找免费的替代品。根据我有限的研究,这个库提供了类似 openai 的 api 访问,使其可以很容易地添加到我现有的代码中。但是该库在下载时出现错误。我尝试安装 cmake 但没有帮助。
\nBuilding wheels for collected packages: llama-cpp-python\n Building wheel for llama-cpp-python (pyproject.toml) ... error\n error: subprocess-exited-with-error\n\n \xc3\x97 Building wheel for llama-cpp-python (pyproject.toml) did not run successfully.\n \xe2\x94\x82 exit code: 1\n \xe2\x95\xb0\xe2\x94\x80> [20 lines of output]\n *** scikit-build-core 0.5.1 using CMake 3.27.7 (wheel)\n *** Configuring CMake...\n 2023-10-10 21:23:02,749 - scikit_build_core - WARNING - Can't find a Python library, got libdir=None, ldlibrary=None, multiarch=None, masd=None\n loading initial cache file C:\\Users\\ARUSHM~1\\AppData\\Local\\Temp\\tmpf1bzj6ul\\build\\CMakeInit.txt\n -- Building for: …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 llama-cpp-python (llama.cpp 的 Python 包装器)使用 Google Colab 中的 Llama LLM 进行推理。我的代码如下所示:
!pip install llama-cpp-python
from llama_cpp import ChatCompletionMessage, Llama
model = Llama(
"/content/drive/MyDrive/<weights-file>.bin",
)
Run Code Online (Sandbox Code Playgroud)
但是,当运行它时,我收到此错误:
AssertionError Traceback (most recent call last)
<ipython-input-13-652eb650093d> in <cell line: 9>()
7 }
8
----> 9 model = Llama(
10 model_path="/content/drive/MyDrive/careo/Wizard-Vicuna-13B-Uncensored.ggmlv3.q4_1.bin",
11 )
/usr/local/lib/python3.10/dist-packages/llama_cpp/llama.py in __init__(self, model_path, n_ctx, n_parts, n_gpu_layers, seed, f16_kv, logits_all, vocab_only, use_mmap, use_mlock, embedding, n_threads, n_batch, last_n_tokens_size, lora_base, lora_path, low_vram, tensor_split, rope_freq_base, rope_freq_scale, n_gqa, rms_norm_eps, mul_mat_q, verbose)
321 self.model_path.encode("utf-8"), self.params
322 …Run Code Online (Sandbox Code Playgroud) assertion google-colaboratory llamacpp llama llama-cpp-python
我已经在 Ubuntu 20.04 和 NVIDIA GTX 1060 6GB 上使用oobabooga text- Generation-webui几个星期了,没有出现任何问题。我一直在使用 llama2-chat 模型在 RAM 和 NVIDIA VRAM 之间共享内存。我按照其存储库上的说明安装没有太多问题。
所以我现在想要的是使用模型加载器llama-cpp及其包llama-cpp-python绑定来自己玩弄它。因此,使用 oobabooga text- Generation-webui 使用的相同 miniconda3 环境,我启动了一个 jupyter 笔记本,我可以做出推断,一切都运行良好,但仅适用于 CPU。
下面是一个工作示例,
from llama_cpp import Llama
llm = Llama(model_path="/mnt/LxData/llama.cpp/models/meta-llama2/llama-2-7b-chat/ggml-model-q4_0.bin",
n_gpu_layers=32, n_threads=6, n_ctx=3584, n_batch=521, verbose=True),
prompt = """[INST] <<SYS>>
Name the planets in the solar system?
<</SYS>>
[/INST]
"""
output = llm(prompt, max_tokens=350, echo=True)
print(output['choices'][0]['text'].split('[/INST]')[-1])
Run Code Online (Sandbox Code Playgroud)
当然!以下是太阳系中的八颗行星,按距太阳从近到远的顺序列出:
- 汞
- 金星
- 地球
- 火星
- 木星
- 土星
- 天王星
- 海王星
请注意,冥王星以前被认为是一颗行星,但由于其较小的尺寸和独特的轨道,现在被归类为矮行星。
我也想使用 …