langchain 获取AttributeError: 'Llama'对象没有属性'_lora_adapter',使用llama cpp,

lf5gs5x2  于 2个月前  发布在  其他
关注(0)|答案(3)|浏览(29)

检查其他资源

  • 为这个问题添加了一个非常描述性的标题。
  • 使用集成搜索在LangChain文档中进行了搜索。
  • 使用GitHub搜索找到了一个类似的问题,但没有找到。
  • 我确信这是LangChain中的一个bug,而不是我的代码。
  • 通过更新到LangChain的最新稳定版本(或特定集成包)无法解决此错误。

示例代码

from langchain.callbacks.manager import CallbackManager
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
from langchain_community.llms import LlamaCpp

model_path = "/AI/language-models/Llama-3-Taiwan-8B-Instruct.Q5_K_M.gguf"

llm = LlamaCpp(
    model_path=model_path,
    n_gpu_layers=100,
    n_batch=512,
    n_ctx=2048,
    f16_kv=True,
    max_tokens=2048,
    callback_manager=CallbackManager([StreamingStdOutCallbackHandler()]),
    verbose=True
)

错误消息和堆栈跟踪(如果适用)

Traceback (most recent call last):
File "d:\program\python\ddavid-langchain\ddavid_langchain\start.py", line 15, in
llm = LlamaCpp(
^^^^^^^^^
File "D:\miniconda3\envs\ddavid-langchain\Lib\site-packages\pydantic\v1\main.py", line 341, in init
raise validation_error
pydantic.v1.error_wrappers.ValidationError: 1 validation error for LlamaCpp

root

Could not load Llama model from path: /AI/language-models/Llama-3-Taiwan-8B-Instruct.Q5_K_M.gguf. Received error exception: access violation reading 0x0000000000000000 (type=value_error)
Exception ignored in: <function Llama.del at 0x00000247FF061120>
Traceback (most recent call last):
File "D:\miniconda3\envs\ddavid-langchain\Lib\site-packages\llama_cpp\llama.py", line 2089, in del
AttributeError: 'Llama' object has no attribute '_lora_adapter'

描述

我在Python 3.10.14、Windows 11下安装了全新的LangChain和llama-cpp-python。几天前它运行良好,直到我尝试从0.2.82升级到0.2.83。升级后出现了“AttributeError: 'Llama' object has no attribute '_lora_adapter'”的错误。
我尝试在新的Python 3.11.9环境下在新环境中重新安装,但仍然遇到相同的错误。
我不太确定llama-cpp-python的版本是否导致了这个错误,因为目前我还没有尝试再次使用python-llama-cpp 0.2.82。

kuuvgm7e

kuuvgm7e1#

这似乎是llama-cpp-python的上游问题(特定于Llama 3.1模型)。

lc8prwob

lc8prwob3#

我也有一台out of memory,日志中前面有几行:

ggml_backend_cuda_buffer_type_alloc_buffer: allocating 47193.83 MiB on device 0: cudaMalloc failed: out of memory

相关问题