response = query_engine.query("花未眠") print(response) 基本思路是加载 LLM 和 Embedding 模型,然后将 data 作为知识库进行查询。因为代码注释详细,不再赘述。 参考文献 [1]https://docs.llamaindex.ai/en/stable/ [2]https://github.com/run-llama/llama_index [3] QwenCustomLLMOffline(本文源码):http...
LLMMetadata, )fromllama_index.llms.baseimport llm_completion_callbackfromtransformers import AutoTokenizer, AutoModelForCausalLM class QwenCustomLLM(CustomLLM): context_window: int =8192# 上下文窗口大小 num_output: int =128# 输出的token数量 model_name: str ="Qwen-1_8B-Chat"# 模型名称 tokenizer...