[中文正文内容]

✨ 通过 Prompt 构建机器学习模型

plexe.ai

License

Apache-2.0 license 1.2k stars 67 forks

plexe ✨

PyPI version Discord backed-by-yc

使用自然语言构建机器学习模型。

快速开始 | 特性 | 安装 | 文档

plexe 让你通过用简单的语言描述来创建机器学习模型。 简单地解释你想要什么,这个 AI 驱动的系统通过一个自动化的 agentic 方法来构建一个功能完善的模型。 同时也可作为一个 托管云服务来使用。

demo.mp4

1. 快速开始

安装

pip install plexe

使用 plexe

你可以使用 plexe 作为一个 Python 库来构建和训练机器学习模型:

import plexe
# 定义模型
model = plexe.Model(
  intent="从新闻文章中预测情感",
  input_schema={"headline": str, "content": str},
  output_schema={"sentiment": str}
)
# 构建和训练模型
model.build(
  datasets=[your_dataset],
  provider="openai/gpt-4o-mini",
  max_iterations=10
)
# 使用模型
prediction = model.predict({
  "headline": "可再生能源的新突破",
  "content": "科学家宣布了一项重大进展..."
})
# 保存以供以后使用
plexe.save_model(model, "sentiment-model")
loaded_model = plexe.load_model("sentiment-model.tar.gz")

2. 特性

2.1. 💬 自然语言模型定义

使用简单的英文描述定义模型:

model = plexe.Model(
  intent="根据大小,位置等特征预测房价",
  input_schema={"square_feet": int, "bedrooms": int, "location": str},
  output_schema={"price": float}
)

2.2. 🤖 多 Agent 架构

该系统使用一组专业的 AI Agents 来:

2.3. 🎯 自动化模型构建

使用一个方法调用构建完整的模型:

model.build(
  datasets=[dataset_a, dataset_b],
  provider="openai/gpt-4o-mini", # LLM provider
  max_iterations=10,       # 探索的最大解决方案数量
  timeout=1800          # 可选时间限制(秒)
)

2.4. 🚀 使用 Ray 进行分布式训练

Plexe 支持使用 Ray 进行分布式模型训练和评估,以实现更快的并行处理:

from plexe import Model
# 可选: 如果使用远程 Ray,配置 Ray 集群地址
# from plexe import config
# config.ray.address = "ray://10.1.2.3:10001"
model = Model(
  intent="根据各种特征预测房价",
  distributed=True # 启用分布式执行
)
model.build(
  datasets=[df],
  provider="openai/gpt-4o-mini"
)

当探索多个模型变体时,Ray 将你的工作负载分配到可用的 CPU 核心,从而显著加快模型生成和评估速度。

2.5. 🎲 数据生成 & Schema 推断

自动生成合成数据或推断 Schema:

# 生成合成数据
dataset = plexe.DatasetGenerator(
  schema={"features": str, "target": int}
)
dataset.generate(500) # 生成 500 个样本
# 从 intent 推断 schema
model = plexe.Model(intent="根据使用模式预测客户流失")
model.build(provider="openai/gpt-4o-mini") # 自动推断 Schema

2.6. 🌐 多 Provider 支持

使用你喜欢的 LLM provider,例如:

model.build(provider="openai/gpt-4o-mini")     # OpenAI
model.build(provider="anthropic/claude-3-opus")   # Anthropic
model.build(provider="ollama/llama2")        # Ollama
model.build(provider="huggingface/meta-llama/...") # Hugging Face

有关说明和可用 providers,请参阅 LiteLLM providers

注意

Plexe 应该 可以与大多数 LiteLLM providers 一起使用,但我们仅主动测试 openai/*anthropic/* 模型。 如果你遇到其他 providers 的问题,请告知我们。

3. 安装

3.1. 安装选项

pip install plexe         # 标准安装
pip install plexe[lightweight]   # 最小依赖
pip install plexe[all]       # 包含深度学习支持

3.2. API Keys

# 设置你首选 provider 的 API key
export OPENAI_API_KEY=<your-key>
export ANTHROPIC_API_KEY=<your-key>
export GEMINI_API_KEY=<your-key>

有关环境变量名,请参阅 LiteLLM providers

4. 文档

有关完整文档,请访问 docs.plexe.ai

5. 贡献

请参阅 CONTRIBUTING.md 获取指南。 加入我们的 Discord 与团队联系。

6. License

Apache-2.0 License

7. 产品路线图

8. 引用

如果你在研究中使用 Plexe,请按如下方式引用它:

@software{plexe2025,
 author = {De Bernardi, Marcello AND Dubey, Vaibhav},
 title = {Plexe: Build machine learning models using natural language.},
 year = {2025},
 publisher = {GitHub},
 howpublished = {\url{https://github.com/plexe-ai/plexe}},
}

关于

✨ 通过 Prompt 构建机器学习模型 plexe.ai

Topics

machine-learning ml multiagent multiagent-systems agents mlops mlengineering agentic-ai

Resources

Readme

License

Apache-2.0 license

Code of conduct

Code of conduct

Security policy

Security policy