Skip to main content
Glama

贝叶斯 MCP

用于贝叶斯推理、推断和信念更新的模型调用协议 (MCP) 服务器。该工具使法学硕士 (LLM) 能够执行严格的贝叶斯分析和概率推理。

特征

  • 🧠贝叶斯推理:使用 MCMC 抽样,利用新证据更新信念

  • 📊模型比较:使用信息标准比较竞争模型

  • 🔮预测推理:通过不确定性量化生成预测

  • 📈可视化:创建后验分布的可视化

  • 🔌 MCP 集成:与任何支持 MCP 的 LLM 无缝集成

Related MCP server: Calculator MCP Server

安装

开发安装

克隆存储库并安装依赖项:

git clone https://github.com/wrenchchatrepo/bayesian-mcp.git
cd bayesian-mcp
pip install -e .

要求

  • Python 3.9+

  • PyMC 5.0+

  • 阿维兹

  • NumPy

  • Matplotlib

  • 快速API

  • 优维康

快速入门

启动服务器

# Run with default settings
python bayesian_mcp.py

# Specify host and port
python bayesian_mcp.py --host 0.0.0.0 --port 8080

# Set log level
python bayesian_mcp.py --log-level debug

服务器将启动并监听指定主机和端口上的 MCP 请求。

API 使用

贝叶斯 MCP 服务器通过其 API 公开了几个功能:

1.创建模型

使用指定的变量创建一个新的贝叶斯模型。

# MCP Request
{
    "function_name": "create_model",
    "parameters": {
        "model_name": "my_model",
        "variables": {
            "theta": {
                "distribution": "normal",
                "params": {"mu": 0, "sigma": 1}
            },
            "likelihood": {
                "distribution": "normal",
                "params": {"mu": "theta", "sigma": 0.5},
                "observed": [0.1, 0.2, 0.3, 0.4]
            }
        }
    }
}

2.更新信念

用新证据更新模型信念。

# MCP Request
{
    "function_name": "update_beliefs",
    "parameters": {
        "model_name": "my_model",
        "evidence": {
            "data": [0.1, 0.2, 0.3, 0.4]
        },
        "sample_kwargs": {
            "draws": 1000,
            "tune": 1000,
            "chains": 2
        }
    }
}

3. 做出预测

使用后验分布生成预测。

# MCP Request
{
    "function_name": "predict",
    "parameters": {
        "model_name": "my_model",
        "variables": ["theta"],
        "conditions": {
            "x": [1.0, 2.0, 3.0]
        }
    }
}

4. 比较模型

使用信息标准比较多个模型。

# MCP Request
{
    "function_name": "compare_models",
    "parameters": {
        "model_names": ["model_1", "model_2"],
        "metric": "waic"
    }
}

5.创建可视化

生成模型后验分布的可视化。

# MCP Request
{
    "function_name": "create_visualization",
    "parameters": {
        "model_name": "my_model",
        "plot_type": "trace",
        "variables": ["theta"]
    }
}

示例

examples/目录包含几个示例,演示如何使用贝叶斯 MCP 服务器:

线性回归

一个简单的线性回归示例来演示参数估计:

python examples/linear_regression.py

A/B 测试

贝叶斯 A/B 测试转化率的示例:

python examples/ab_test.py

支持的发行版

贝叶斯引擎支持以下分布:

  • normal :正态(高斯)分布

  • lognormal :对数正态分布

  • beta :Beta 分布

  • gamma :伽马分布

  • exponential :指数分布

  • uniform :均匀分布

  • bernoulli :伯努利分布

  • binomial :二项分布

  • poisson :泊松分布

  • deterministic :确定性变换

MCP 集成

此服务器实现了模型调用协议 (MCP),使其与各种 LLM 和框架兼容。要将其与您的 LLM 一起使用:

import requests

response = requests.post("http://localhost:8000/mcp", json={
    "function_name": "create_model",
    "parameters": {
        "model_name": "example_model",
        "variables": {...}
    }
})

result = response.json()

执照

麻省理工学院

致谢

基于 Wrench AI 框架的概念和代码。

-
security - not tested
A
license - permissive license
-
quality - not tested

Resources

Looking for Admin?

Admins can modify the Dockerfile, update the server description, and track usage metrics. If you are the server author, to access the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/wrenchchatrepo/bayes-msp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server