speculators.convert.eagle
Eagle 检查点转换工具。
模块
-
eagle3_converter–具有 loguru 日志记录的 Eagle-3 检查点转换器。
-
eagle3_legacy_model–EAGLE-3 的旧模型实现。此模型已弃用,将在
-
eagle_converter–具有 loguru 日志记录的 Eagle 检查点转换器。
-
utils–用于检查点转换操作的实用函数。
类
-
EagleConverter–将 Eagle/HASS 检查点转换为 speculators 格式的转换器。
EagleConverter
将 Eagle/HASS 检查点转换为 speculators 格式的转换器。
此转换器处理将 Eagle 风格的检查点(包括 HASS 变体)转换为标准化的 speculators 格式。它支持自动功能检测、权重重新映射和可选验证。
:示例
>>> converter = EagleConverter()
>>> converter.convert(
... "yuhuili/EAGLE-LLaMA3.1-Instruct-8B",
... "./output",
... "meta-llama/Meta-Llama-3.1-8B-Instruct"
... )
方法
-
convert–将 Eagle 检查点转换为 speculators 格式。
convert
convert(
input_path: str | Path,
output_path: str | Path,
base_model: str,
fusion_bias: bool = False,
layernorms: bool = False,
validate: bool = True,
cache_dir: str | Path | None = None,
) -> None
将 Eagle 检查点转换为 speculators 格式。
此方法协调完整的转换过程
- 确保检查点在本地可用
- 加载原始配置和权重
- 如果未明确指定(layernorms、fusion bias),则自动检测功能
- 构建 speculators 配置
- 处理和重新映射权重
- 保存转换后的检查点
- 通过运行前向传播来可选地验证结果
:示例
>>> # Convert standard Eagle checkpoint
>>> converter = EagleConverter()
>>> converter.convert(
... "yuhuili/EAGLE-LLaMA3.1-Instruct-8B",
... "./eagle-converted",
... "meta-llama/Meta-Llama-3.1-8B-Instruct",
... validate=True
... )
>>> # Convert HASS checkpoint with layernorms
>>> converter.convert(
... "nm-testing/Eagle_Speculator_Llama_3_1_8B_TTT",
... "./hass-converted",
... "meta-llama/Meta-Llama-3.1-8B-Instruct",
... layernorms=True
... )
参数
-
(input_pathstr | Path) –Eagle 检查点路径(本地或 HuggingFace ID)
-
(output_pathstr | Path) –保存转换后的检查点的位置
-
(base_modelstr) –基础模型名称(例如,meta-llama/Llama-3.1-8B-Instruct)
-
(fusion_biasbool, 默认值:False) –启用融合偏差(如果未指定,则自动检测)
-
(layernormsbool, 默认值:False) –启用额外的层归一化(如果未指定,则自动检测)
-
(validatebool, 默认值:True) –是否验证转换后的检查点
-
(cache_dirstr | Path | None, 默认值:None) –可选的下载缓存目录