You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用ctransformers加载GGUF模型时from_pretrained()报RuntimeError错误

解决ctransformers加载GGUF模型的RuntimeError问题
  • 检查模型文件路径与名称
    即使模型放在同目录,也要确认文件名和代码中完全一致,包括大小写、后缀。可以用以下代码列出当前目录文件,核对文件名:

    import os
    print(os.listdir())
    
  • 修正model_type参数
    Hermes-3基于Llama-3.1架构,ctransformers中对应的model_type应为"llama3"而非"llama",修改后的代码:

    from ctransformers import AutoModelForCausalLM
    
    llm = AutoModelForCausalLM.from_pretrained("Hermes-3-Llama-3.1-8B.Q4_K_M.gguf", model_type="llama3")
    
  • 指定backend参数(可选)
    若仍报错,可尝试显式指定backend参数,适配GGUF模型:

    llm = AutoModelForCausalLM.from_pretrained("Hermes-3-Llama-3.1-8B.Q4_K_M.gguf", model_type="llama3", backend="ggml")
    
  • 验证模型文件完整性
    下载的模型可能损坏,核对文件大小与官方提供的一致,必要时重新下载模型文件。

内容的提问来源于stack exchange,提问作者Alhusain Alharthi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 23:57:32