Ruby Minion: 一个强大的开源 AGI 框架

femto · 2025年03月07日 · 最后由 a0nqm 回复于 2025年04月07日 · 394 次阅读

Minion: 一个强大的开源 AGI 框架

大家好,我想向 Ruby China 社区介绍我开发的开源 AGI 框架 - Minion

Minion 是什么?

Minion 是一个设计用于执行各种类型查询的开源 AGI 框架,它提供了一系列展示其灵活性和智能性的功能。框架采用循环优化的工作方式,能够不断改进解决方案直到达到满意的结果。

Minion 工作流程

核心特点

  • 出色的性能表现:在多个基准测试中取得了令人印象深刻的结果

    • GSM8K 测试达到 96% 的准确率(使用 DeepSeek-Chat)
    • Game of 24 在 20 个最难问题上达到 100% 成功率
    • AIME 2024 数学竞赛题目完成率 26%(15 道题中完成 4 道),为 Claude 3.5 Sonnet 的 170%
    • Humaneval 达到 98.2% pass@1 率(使用 gpt-4o)
  • 灵活的任务处理能力

    • 可处理数学计算(如 Game of 24、方程求解)
    • 支持创意写作(如小说创作)
    • 能够处理复杂的数学竞赛题目
    • 其他各种任务
  • 智能迭代的工作流程

    1. 接收查询(Query)
    2. 生成解决方案(Solution)
    3. 检查结果(Check)
    4. 需要时进行改进(Improve)并返回优化

技术实现

不同例子的代码(参见 examples/smart_minion/brain.py ) 中。您可以通过修改代码来尝试不同的示例,因为各种场景已经被注释掉以便于测试。

#数学例子
obs, score, *_ = await brain.step(query="what's the solution 234*568")
print(obs)

#game 24例子
obs, score, *_ = await brain.step(query="what's the solution for game of 24 for 4 3 9 8")
print(obs)

obs, score, *_ = await brain.step(query="what's the solution for game of 24 for 2 5 11 8")
print(obs)

#解方程例子
obs, score, *_ = await brain.step(query="solve x=1/(1-beta^2*x) where beta=0.85")
print(obs)

#写小说例子
obs, score, *_ = await brain.step(
    query="Write a 500000 characters novel named 'Reborn in Skyrim'. "
          "Fill the empty nodes with your own ideas. Be creative! Use your own words!"
          "I will tip you $100,000 if you write a good novel."
          "Since the novel is very long, you may need to divide it into subtasks."
)
print(obs)

#解aime例子
cache_plan = os.path.join(current_file_dir, "aime", "plan_gpt4o.1.json")
obs, score, *_ = await brain.step(
    query="Every morning Aya goes for a $9$-kilometer-long walk and stops at a coffee shop afterwards. When she walks at a constant speed of $s$ kilometers per hour, the walk takes her 4 hours, including $t$ minutes spent in the coffee shop. When she walks $s+2$ kilometers per hour, the walk takes her 2 hours and 24 minutes, including $t$ minutes spent in the coffee shop. Suppose Aya walks at $s+\frac{1}{2}$ kilometers per hour. Find the number of minutes the walk takes her, including the $t$ minutes spent in the coffee shop.",
    route="cot",
    dataset="aime 2024",
    cache_plan=cache_plan,
)
print(obs)

cache_plan = os.path.join(current_file_dir, "aime", "plan_gpt4o.7.json")

#解方程例子
obs, score, *_ = await brain.step(
    query="Find the largest possible real part of\[(75+117i)z+\frac{96+144i}{z}\]where $z$ is a complex number with $|z|=4$.",
    route="cot",
    dataset="aime 2024",
    cache_plan=cache_plan,
)
print(obs)

# 编程例子
    test_data = {
        "task_id": "HumanEval/88",
        "prompt": "\ndef sort_array(array):\n    \"\"\"\n    Given an array of non-negative integers, return a copy of the given array after sorting,\n    you will sort the given array in ascending order if the sum( first index value, last index value) is odd,\n    or sort it in descending order if the sum( first index value, last index value) is even.\n\n    Note:\n    * don't change the given array.\n\n    Examples:\n    * sort_array([]) => []\n    * sort_array([5]) => [5]\n    * sort_array([2, 4, 3, 0, 1, 5]) => [0, 1, 2, 3, 4, 5]\n    * sort_array([2, 4, 3, 0, 1, 5, 6]) => [6, 5, 4, 3, 2, 1, 0]\n    \"\"\"\n",
        "entry_point": "sort_array",
        "test": ["assert candidate([]) == []",
                "assert candidate([5]) == [5]",
                "assert candidate([2, 4, 3, 0, 1, 5]) == [0, 1, 2, 3, 4, 5]",
                "assert candidate([2, 4, 3, 0, 1, 5, 6]) == [6, 5, 4, 3, 2, 1, 0]"]
    }

    obs, score, *_ = await brain.step(
        query=test_data["prompt"],
        route="python",
        post_processing="extract_python",
        entry_point=test_data["entry_point"],
        check=10,
        check_route="ldb_check",
        dataset="HumanEval",
        metadata={"test_cases": test_data["test"]}  # 添加测试用例到 metadata
    )
    print(obs)

框架设计基于最新的神经科学研究成果和机器学习算法,能够在多变的环境中自我调整,以实现更高效的智能推理和决策。

快速开始

安装

git clone https://github.com/femto/minion.git && cd minion && pip install -r requirements.txt
cp config/config.yaml.example config/config.yaml
cp config/.env.example config/.env

然后编辑 config/config.yaml:

models:
  "default":
    api_type: "openai"
    base_url: "${DEFAULT_BASE_URL}"
    api_key: "${DEFAULT_API_KEY}"
    model: "deepseek-chat"
    temperature: 0

接着编辑 config/.env:

DEFAULT_API_KEY=sk-xxx
DEFAULT_BASE_URL=base_url
DEFAULT_MODEL=...

使用 Docker Python 环境

docker build -t intercode-python -f docker/python.Dockerfile .
brain = Brain()  # 默认将使用 docker python 环境

或使用 rpyc 环境

python docker/utils/python_server.py --port 3007
brain = Brain(python_env=RpycPythonEnv(port=3007))

演示视频

查看这些演示视频,了解 Minion 的实际应用:

社区与支持

加入我们的 Discord 社区,与其他 Minion 用户交流,获取支持,并了解最新动态。

为什么选择 Minion?

与现有的 AI 解决方案相比,Minion 框架不仅能够支持复杂的多任务处理,还能适应不同领域的需求。其模块化设计允许用户根据具体需求进行功能定制和扩展,从而提高智能系统的灵活性和适用性。

相关链接

欢迎大家试用并提供反馈!如果你对 AGI 和人工智能感兴趣,Minion 将是一个很好的工具和学习资源。

AGI?可别乱说……

需要 登录 后方可回复, 如果你还没有账号请 注册新账号