跳到内容

MlxLLM

Apple MLX LLM 实现。

属性

  • path_or_hf_repo: 模型路径或 Hugging Face Hub repo id。

  • tokenizer_config: tokenizer 配置。

  • mlx_model_config: MLX 模型配置。

  • adapter_path: adapter 路径。

  • use_magpie_template: 用于启用/禁用应用 Magpie 预查询模板的标志。默认为 False

  • magpie_pre_query_template: 应用于提示或发送到 LLM 以生成指令或后续用户消息的预查询模板。有效值为 "llama3"、"qwen2" 或提供的另一个预查询模板。默认为 None

示例

生成文本

from distilabel.models.llms import MlxLLM

llm = MlxLLM(path_or_hf_repo="mlx-community/Meta-Llama-3.1-8B-Instruct-4bit")

llm.load()

# Call the model
output = llm.generate_outputs(inputs=[[{"role": "user", "content": "Hello world!"}]])