geoffrey-llm
一个轻量的 LLM 与多云工具包,包含机器学习、深度学习、agent 构建、大模型微调和多云资源管理模块。每个模块依赖隔离,按需安装。
模块总览
| 模块 | 说明 | 安装 extras | 状态 |
|---|---|---|---|
geoffrey_llm.ml |
机器学习(基于 sklearn,统一 API + 中文评估报表) | [ml] |
|
geoffrey_llm.dl |
深度学习(基于 torch,神经网络封装) | [dl] |
|
geoffrey_llm.geocode |
大模型 agent 构建(Claude Code 风格 REPL) | [geocode] |
|
geoffrey_llm.blog |
个人博客 REST API 客户端 | [blog] |
|
geoffrey_llm.finetune |
大模型微调(LoRA / QLoRA,基于 transformers/peft) | [finetune] |
|
geoffrey_llm.cloud |
多云核心资源统一入口(阿里云/腾讯云/华为云/AWS) | [cloud-*] |
安装
# 只装机器学习
pip install geoffrey-llm[ml]
# 只装 agent REPL
pip install geoffrey-llm[geocode]
# 只装博客客户端
pip install geoffrey-llm[blog]
# 只装 AWS 多云适配器(其余厂商对应 cloud-alibaba/cloud-tencent/cloud-huawei)
pip install geoffrey-llm[cloud-aws]
# 装全部(含 dev 工具;云 SDK 请按需装 cloud 或单厂商 cloud-*)
pip install geoffrey-llm[all]
快速上手
机器学习模块
from geoffrey_llm.ml import Trainer, Evaluator
# 训练(分类)
trainer = Trainer(task="classification", model_name="random_forest")
trainer.fit(X_train, y_train)
preds = trainer.predict(X_test)
# 评估(中文报表)
print(Evaluator.classification_report(y_test, preds, chinese=True))
# 持久化
trainer.save("model.pkl")
trainer2 = Trainer.load("model.pkl", task="classification", model_name="random_forest")
支持的算法:
- 分类:
random_forest/logistic_regression/svm/gradient_boosting - 回归:
random_forest/linear_regression/gradient_boosting
agent 构建模块(geocode)
# 命令行启动 REPL
geocode
geocode --provider deepseek --model deepseek-chat
from geoffrey_llm.geocode import REPL, BaseModel
from geoffrey_llm.geocode.models.base import get_registry, ModelConfig
config = ModelConfig(model_name="moonshot-v1-8k")
model = get_registry().create("kimi", config)
repl = REPL(model=model)
geocode 特性:
- 多模型: Kimi / DeepSeek / Qwen / OpenAI 兼容
- 工具调用: FileRead / FileWrite / FileEdit / Bash(带白名单)
- 文件式记忆系统(yaml frontmatter)
- 会话持久化与 resume
- MCP (Model Context Protocol) 集成
博客客户端
博客客户端调用博客的 API_TOKEN,不是 Flask 的 SECRET_KEY。支持的环境变量优先级为 BLOG_API_TOKEN、BLOG_SECRET、BLOG_SERCET;BLOG_SERCET 用于兼容已有配置。
export BLOG_BASE_URL="https://blog.geoffrey-peng.cc"
export BLOG_SERCET="your-blog-api-token"
from geoffrey_llm.blog import BlogClient
with BlogClient() as blog:
posts = blog.list_posts(page=1, per_page=10)
blog.create_post(
title="SDK 发布",
slug="sdk-release",
content="通过 geoffrey-llm 发布。",
category_id=1,
is_public=True,
)
支持分类、文章 CRUD 和分享链接管理:list_categories、list_posts、get_post、create_post、update_post、delete_post、create_share、list_shares、revoke_share。
多云客户端
cloud 提供实例、VPC/子网、安全组、对象存储和托管数据库的统一入口。默认只读;安全组规则变更还必须显式打开变更权限并关闭 dry-run。凭据仅由各官方 SDK 的环境变量、配置文件或工作负载角色链解析,不能写入代码或 CloudConfig。
from geoffrey_llm.cloud import CloudClient, CloudConfig
cloud = CloudClient(CloudConfig(provider="aws", region="ap-southeast-1"))
instances = cloud.instances.list()
security_groups = cloud.security_groups.list()
buckets = cloud.object_storage.list_buckets()
本地无凭据验证可使用内存 Mock provider:
cloud = CloudClient(CloudConfig(provider="mock", region="test-1"))
assert cloud.databases.list()[0].id == "db-demo"
官方资料与资源映射存放在仓库根目录 .cloud/,其中不允许保存密钥或真实资源标识。
设计原则
- 依赖隔离:
import geoffrey_llm不拉任何重依赖,各模块按 extras 安装 - 中文友好:错误信息、评估报表默认中文
- 统一 API:不同后端(sklearn / lightgbm / xgboost)共用
Trainer入口 - 混合实现:核心算法用主流库,周边工具(评估/报表/记忆/会话)自己写
项目结构
geoffrey_llm/
├── common/ # 共享:Registry / BaseConfig / GeoffreyError
├── ml/ # 机器学习
│ ├── trainer.py
│ ├── evaluator.py
│ ├── report.py
│ ├── models.py
│ └── backends/
├── dl/ # 深度学习(占位)
├── geocode/ # agent 构建
│ ├── cli.py / repl.py
│ ├── models/ tools/ memory/ session/ cmd/ mcp/ prompts/
├── blog/ # 个人博客 REST API 客户端
└── finetune/ # 大模型微调(占位)
License
MIT
Roadmap
-
ml: lightgbm / xgboost 后端 -
ml: 场景化 pipeline(表格分类一键流程) -
ml: 特征工程 / 自动调参 / 模型解释性 -
dl: CNN / RNN / Transformer 封装,DLTrainer -
finetune: LoRATrainer / QLoRATrainer / DatasetPreprocessor -
geocode: 更多 provider、工具系统增强
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file geoffrey_llm-0.3.0.tar.gz.
File metadata
- Download URL: geoffrey_llm-0.3.0.tar.gz
- Upload date:
- Size: 56.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d70e717c1009e9e0648b3533abcbfb9464beddd96d5a5a68a1284b4dc8e9a685
|
|
| MD5 |
69faba4ccbef75144254ec87b2aa18d4
|
|
| BLAKE2b-256 |
964bf5bce9c468095a2c704f56e1d143adc95bfd9fda9f2a918503a0bbbbb78f
|
File details
Details for the file geoffrey_llm-0.3.0-py3-none-any.whl.
File metadata
- Download URL: geoffrey_llm-0.3.0-py3-none-any.whl
- Upload date:
- Size: 72.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/7.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d11e18fa00a273153a21582c1b1957c40ccbc04cbb66d602bf08530a324b4d7
|
|
| MD5 |
09964e3164d1b4ef2678dd4c377d780f
|
|
| BLAKE2b-256 |
3b0a567e7208e197932f0d55654174240271cadfaa25498d1075c3731571b513
|