跳到内容

MixtureOfAgentsLLM

Mixture-of-Agents 的实现。

一个 LLM 类,它利用 LLM 的集体优势来生成响应,如 "Mixture-of-Agents Enhances Large Language model Capabilities" 论文中所述。这里有一个 LLM 列表,用于提出/生成输出,后续轮次/层的 LLM 可以将其用作辅助信息。最后,有一个 LLM 聚合输出以生成最终响应。

属性

  • aggregator_llm: 聚合 proposer LLM 输出的 LLM

  • proposers_llms: 提出要聚合的输出的 LLM 列表。

  • rounds: proposers_llms 生成输出的层数或轮数。默认为 1

示例

生成文本

from distilabel.models.llms import MixtureOfAgentsLLM, InferenceEndpointsLLM

llm = MixtureOfAgentsLLM(
    aggregator_llm=InferenceEndpointsLLM(
        model_id="meta-llama/Meta-Llama-3-70B-Instruct",
        tokenizer_id="meta-llama/Meta-Llama-3-70B-Instruct",
    ),
    proposers_llms=[
        InferenceEndpointsLLM(
            model_id="meta-llama/Meta-Llama-3-70B-Instruct",
            tokenizer_id="meta-llama/Meta-Llama-3-70B-Instruct",
        ),
        InferenceEndpointsLLM(
            model_id="NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO",
            tokenizer_id="NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO",
        ),
        InferenceEndpointsLLM(
            model_id="HuggingFaceH4/zephyr-orpo-141b-A35b-v0.1",
            tokenizer_id="HuggingFaceH4/zephyr-orpo-141b-A35b-v0.1",
        ),
    ],
    rounds=2,
)

llm.load()

output = llm.generate_outputs(
    inputs=[
        [
            {
                "role": "user",
                "content": "My favorite witty review of The Rings of Power series is this: Input:",
            }
        ]
    ]
)

参考文献