自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

Mixture-of-Agents系統(tǒng),竟然如此簡(jiǎn)單!

發(fā)布于 2024-7-15 09:23
瀏覽
0收藏

嘿,大家好!這里是一個(gè)專注于AI智能體的頻道!

首先,讓我們來聊聊LLM。這些模型通過在海量數(shù)據(jù)集上預(yù)訓(xùn)練,已經(jīng)展現(xiàn)出了驚人的能力,無論是理解還是生成自然語(yǔ)言,它們都能做得很好。但問題來了,這些模型的規(guī)模和訓(xùn)練成本都很高,這讓它們?cè)趯?shí)際應(yīng)用中有點(diǎn)不切實(shí)際。

這時(shí)候,MoA登場(chǎng)了!MoA通過利用多個(gè)LLM的集體優(yōu)勢(shì),提供了一個(gè)創(chuàng)新的解決方案。想象一下,如果每個(gè)智能體都能貢獻(xiàn)自己的一份力量,那么最終的輸出結(jié)果將會(huì)多么強(qiáng)大!

MoA的結(jié)構(gòu)就像是一個(gè)分層的建筑,每一層都有多個(gè)LLM智能體。每個(gè)智能體都會(huì)處理上一層的輸出,然后生成更精細(xì)的響應(yīng)。這個(gè)過程會(huì)一直迭代,直到產(chǎn)生一個(gè)最終的、強(qiáng)大的輸出。

Mixture-of-Agents系統(tǒng),竟然如此簡(jiǎn)單!-AI.x社區(qū)

這種結(jié)構(gòu)的好處在于,LLM之間有一種天然的協(xié)作性。研究表明,當(dāng)LLM能夠參考其他模型的輸出時(shí),它們會(huì)產(chǎn)生更高質(zhì)量的響應(yīng),哪怕這些輔助響應(yīng)的質(zhì)量低于模型獨(dú)立輸出的質(zhì)量。

Together.ai就是MoA的一個(gè)典型例子。他們開發(fā)的Together MoA在AlpacaEval 2.0上的得分高達(dá)65.1%,超過了之前領(lǐng)先的GPT-4o的57.5%。這不僅僅是一個(gè)數(shù)字的勝利,更是MoA方法在實(shí)際應(yīng)用中的成功證明。

Mixture-of-Agents系統(tǒng),竟然如此簡(jiǎn)單!-AI.x社區(qū)

MoA的優(yōu)勢(shì)不僅僅在于性能的提升,還在于成本效益和靈活性。通過使用多個(gè)開源模型并優(yōu)化層數(shù)和智能體的數(shù)量,MoA能夠在保持高性能的同時(shí),成本也更加可控。

Together的MOA框架已經(jīng)開源了~ ,下面是示例代碼

import os
from together import Together
os.environ["TOGETHER_API_KEY"] = "your_api_key_here"

client = Together(api_key=os.environ.get("TOGETHER_API_KEY"))
import asyncio
from together import AsyncTogether

async_client = AsyncTogether(api_key=os.environ.get("TOGETHER_API_KEY"))

user_prompt = "What is Karma Yoga as per Bhagavad Gita, Vyadha Gita, Yoga Vasistham and Tripura Rahasya?"
reference_models = [
    "Qwen/Qwen2-72B-Instruct",
    "Qwen/Qwen1.5-72B-Chat",
    "mistralai/Mixtral-8x22B-Instruct-v0.1",
    "databricks/dbrx-instruct",
]
aggregator_model = "mistralai/Mixtral-8x22B-Instruct-v0.1"
aggregator_system_prompt = """You have been provided with a set of responses from various open-source models to the latest user query. Your task is to synthesize these responses into a single, high-quality response. It is crucial to critically evaluate the information provided in these responses, recognizing that some of it may be biased or incorrect. Your response should not simply replicate the given answers but should offer a refined, accurate, and comprehensive reply to the instruction. Ensure your response is well-structured, coherent, and adheres to the highest standards of accuracy and reliability.

Responses from models:"""


async def run_llm(model):
    """Run a single LLM call with a reference model."""
    response = await async_client.chat.completions.create(
        model=model,
        messages=[{"role": "user", "content": user_prompt}],
        temperature=0.7,
        max_tokens=512,
    )
    print(f"Response from {model}: {response.choices[0].message.content}\n")
    return response.choices[0].message.content


async def main():
    results = await asyncio.gather(*[run_llm(model) for model in reference_models])

    finalStream = client.chat.completions.create(
        model=aggregator_model,
        messages=[
            {"role": "system", "content": aggregator_system_prompt},
            {"role": "user", "content": ",".join(str(element) for element in results)},
        ],
        stream=True,
    )

    for chunk in finalStream:
        print(chunk.choices[0].delta.content or "", end="", flush=True)


# asyncio.run(main())
await main()

收藏
回復(fù)
舉報(bào)
回復(fù)
相關(guān)推薦