ValueError: Library `span-marker` is not supported yet, please open an issue on GitHub for us to add support.“`

用户在使用 Hugging Face Accelerate 的命令行工具估算第三方模型的内存占用时触发。具体命令为: accelerate estimate-memory stefan-it/span-marker-gelectra-large-germeval14 --dtypes float32

ValueError: Library `span-marker` is not supported yet, please open an issue on GitHub for us to add support.```

ValueError: Library `span-marker` is not supported yet, please open an issue on GitHub for us to add support.“`

快速结论:该报错在运行 accelerate estimate-memory 命令估算 SpanMarker 模型内存时触发。优先排查你是否使用了 Hugging Face 生态系统之外的模型库;此报错表示 Accelerate 的估算工具目前只支持 Hugging Face 官方库内的模型,而 span-marker 不在支持列表中。

问题场景

用户在使用 Hugging Face Accelerate 的命令行工具估算第三方模型的内存占用时触发。具体命令为:accelerate estimate-memory stefan-it/span-marker-gelectra-large-germeval14 --dtypes float32

报错原文

ValueError: Library `span-marker` is not supported yet, please open an issue on GitHub for us to add support.

完整 traceback(摘自 Issue 正文):

Traceback (most recent call last):
  File "/Users/user/anaconda3/envs/ner2/bin/accelerate", line 8, in 
    sys.exit(main())
  File ".../accelerate/commands/accelerate_cli.py", line 47, in main
    args.func(args)
  File ".../accelerate/commands/estimate.py", line 250, in estimate_command
    data = gather_data(args)
  File ".../accelerate/commands/estimate.py", line 217, in gather_data
    model = create_empty_model(...)
  File ".../accelerate/commands/estimate.py", line 133, in create_empty_model
    raise ValueError(
ValueError: Library `span-marker` is not supported yet, please open an issue on GitHub for us to add support.

原因分析

Accelerate 的 estimate-memory 命令在内部通过 create_empty_model 函数检查模型库,以确定如何创建空模型估算内存。对于 span-marker 这类非 Hugging Face 官方库(如 transformers, diffusers, peft 等)的模型,该函数会直接抛出 ValueError。这是 Accelerate 设计上未覆盖的支持范围,社区贡献者实现该功能后,官方表示该功能为“非计划中(not planned)”,因为发布后社区没有进一步的需求。

环境排查

  • Accelerate 版本:任何包含 estimate-memory 功能的版本都可能触发此问题。Issue 中未提及具体版本,但该命令自 Accelerate 早期版本存在。
  • 模型库:确认目标模型 (stefan-it/span-marker-gelectra-large-germeval14) 是否基于 SpanMarkerNER 框架。该框架不是 Hugging Face 原生的模型仓库,而是独立的第三方库。
  • Hugging Face Hub 模型标签:该模型在 Hub 上的 library_name 标签可能为 span-marker,导致 Accelerate 识别为未支持库。

解决步骤

  1. 可优先尝试:换用 transformers 原生模型。如果内存估算只是一个参考,你可以先使用 Hugging Face Transformers 中结构相近的模型(例如 google-bert/bert-large-uncased)来估算类似规模模型的内存占用。
  2. 可优先尝试:手动计算内存。对于 SpanMarker 模型,可以参考其 Hugging Face 模型卡片上的参数数量,用公式手动估算推理所需内存(例如参数量 × 精度字节数 × 1.2 倍缓冲区)。
  3. 如果必须通过 accelerate estimate-memory 得到精确结果,可能需要 fork Accelerate 源码,在 src/accelerate/commands/estimate.pycreate_empty_model 函数中手动添加 span-marker 的支持逻辑。具体实现请参考 transformers 等其他库的处理方式(例如调用 AutoModel.from_pretrained 并传入相关配置)。
  4. 仅作记录:此 Issue 最终被标记为“not planned”,官方不会在短期内原生支持 span-marker。社区贡献可能未被合并。

验证方法

如果尝试了方案1(使用替代模型),成功运行 accelerate estimate-memory 不报错即为解决。如果尝试了方案3(手动修改源码),运行命令后能正常输出内存估算表格(无 ValueError)即表示修改有效。

参考来源

huggingface/accelerate #2401

GamsGo AI

AI 工具推荐

想把多个 AI 模型放在一个入口?

GamsGo AI 集成 ChatGPT、DeepSeek、Gemini、Claude、Midjourney、Veo 等常用模型,适合写作、绘图、视频和日常 AI 工作流。

了解 GamsGo AI

推广链接:通过此链接购买,我可能获得佣金,不影响你的价格。

celebrityanime
celebrityanime
文章: 14619

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注