我面临导入错误:在实施时无法从“llama_index.llms”(未知位置)导入名称“LlamaCPP” 和 ModuleNotFoundError:没有名为“llama_index.llms.llama_utils”的模块 实施此操作时:
import torch
#from llama_index.llms import LlamaCPP
from llama_index.llms.llama_utils import messages_to_prompt, completion_to_prompt
llm = LlamaCPP(
model_url='https://huggingface.co/TheBloke/Mistral-7B-Instruct-v0.1-GGUF/resolve/main/mistral-7b-instruct-v0.1.Q4_K_M.gguf',
# optionally, you can set the path to a pre-downloaded model instead of model_url
model_path=None,
temperature=0.1,
max_new_tokens=256,
# llama2 has a context window of 4096 tokens, but we set it lower to allow for some wiggle room
context_window=3900,
# kwargs to pass to __call__()
generate_kwargs={},
# kwargs to pass to __init__()
# set to at least 1 to use GPU
model_kwargs={"n_gpu_layers": -1},
# transform inputs into Llama2 format
messages_to_prompt=messages_to_prompt,
completion_to_prompt=completion_to_prompt,
verbose=True,
)
我正在创建的 PDF 聊天机器人
您的进口商品似乎已贬值 尝试使用
from llama_index.llms.llama_cpp.llama_utils import messages_to_prompt, completion_to_prompt
还安装 llama.cpp 的 c 依赖项