Skip to main content

deVision

deVision

deVision = Decision + Vision:看图做决策。输入一张图片和若干英文问题,输出 Jev 格式的答案(noul 是非题 / choice 选择题)和校准过的概率。SigLIP2 看图,Laya 的 ModernBERT 决策头打分,不生成文字;没有 GPU 也能跑。

模型在 Hugging Face:lukbit/devision(当前 v0.2)。

安装

pip install devision            # 推理 + HTTP 服务
pip install "devision[train]"   # 再加训练

需要 Python 3.11+。在本仓库里开发用 uv sync。

Python

import devision

decider = devision.load("lukbit/devision")   # Hugging Face 上的最新版;也可传本地 checkpoint 目录
# 固定版本 revision="v0.2";设备默认 auto(CUDA > MPS > CPU),可指定 device="cpu"

result = decider.predict(            # 与 decider.decide(...) 相同,predict 是 Laya 的叫法
    image="kitchen.jpg",
    state="",                        # 文字背景;没有就传 ""
    questions={
        "has_fork": {"type": "noul", "instructions": "Is there a fork in the image?"},
        "room": {"type": "choice", "instructions": "Which room is this?",
                 "criteria": {"kitchen": None, "bathroom": "has a sink and a toilet", "bedroom": None}},
    },
)
print(result["answers"]["has_fork"]["noul"])        # 陈述成立的概率
print(result["answers"]["room"]["choice"])          # 概率最高的选项
print(result["answers"]["room"]["probabilities"])   # 每个选项的概率,和为 1
  • image:本地路径、http(s) URL、Data URI、Base64、bytes 或 PIL 图片。
  • state:文字背景,字符串、对象或数组,和 Jev 一样。
  • 请求不合法时抛出 devision.InvalidRequest。

HTTP 服务

devision-serve --checkpoint lukbit/devision --port 8000   # 浏览器打开 http://127.0.0.1:8000 是 web demo

常用参数:--revision v0.2 固定版本,--device cpu|cuda|mps(默认自动),--no-demo 只开接口。

curl -s http://127.0.0.1:8000/v1/systemone -H 'Content-Type: application/json' -d '{
  "image": "https://example.com/kitchen.jpg",
  "state": "customer says the order arrived damaged",
  "questions": {
    "has_fork": {"type": "noul", "instructions": "Is there a fork in the image?"},
    "room": {"type": "choice", "instructions": "Which room is this?",
             "criteria": {"kitchen": null, "bathroom": "has a sink and a toilet", "bedroom": null}}
  }
}'
{
  "model": "devision-v0.2",
  "answers": {
    "has_fork": {"type": "noul", "noul": 0.03},
    "room": {"type": "choice", "choice": "kitchen",
             "probabilities": {"kitchen": 0.81, "bathroom": 0.07, "bedroom": 0.12}, "confidence": 0.72}
  },
  "usage": {"input_tokens": 180, "output_tokens": 0}
}
  • 请求:image 是 http(s) URL、Data URI 或 Base64(不读服务器本地文件);choice 有 2–255 个选项,criteria 的值可以加一句说明帮模型区分;不支持 score。
  • 响应与 Jev 相同:noul 是陈述成立的概率;confidence = (n·p_max − 1)/(n − 1)。请求不合法返回 422。
  • 速度:Mac CPU 上单题约 0.15 秒;同一请求里多道题共用一次图片编码。

适合做什么

用概率做阈值,没把握的转给人或更强的模型;阈值请在自己的数据上验证。

  • 适合:有没有某物、有几个(用选择题问)、是什么类别、颜色材质、室内室外、照片里的上下左右(用选择题问)。
  • 不适合:示意图、图表、地图上比较两处;相对位置的是非题;图中小字(输入 256×256);非英文、多张图。

效果

v0.2 与 laya-vision 201M 在同一批题上逐题比较(差值 95% 区间按图片重采样):

评测集 题数 laya-vision deVision v0.2 差值
POPE random / popular / adversarial 3 × 3,000 0.836 / 0.819 / 0.777 0.891 / 0.868 / 0.791 +5.5 / +4.9 / +1.4
VQAv2 是非题 4,887 0.717 0.725 +0.8 [−0.9, +2.3]
A-OKVQA 1,138 0.598 0.626 +2.7 [−0.6, +6.0]
ScienceQA(带图题) 2,097 0.824 0.766 −5.8 [−7.9, −3.6]

完整结果和每一轮的训练记录见 docs/training-log.md,模型结构和设计见 docs/spec/vision-decision-mvp.md。

训练

uv run devision-pipeline configs/example.yaml    # 用示例数据跑通一遍,CPU 上一两分钟
bash scripts/data/build_all.sh data              # 从公开数据集生成训练数据(几十 GB、几个小时)
uv run devision-pipeline configs/scratch.yaml    # 从头训练

每一轮训练是 configs/ 里的一个 YAML,再跑同一个 YAML 是续跑。数据格式见 examples/train/,发布版 v0.2 的配置是 configs/v12-ext.yaml。

许可

代码和权重为 Apache-2.0。训练数据各有条款,部分非商用(如 ScienceQA),请按用途自行核对。

Metadata

Release files for devision 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for devision 0.2.1
File Size Uploaded Provenance
devision-0.2.1.tar.gz 66.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for devision 0.2.1
File Interpreter ABI Platform
devision-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 141.3 kB

Release files / devision-0.2.1.tar.gz

Download URL devision-0.2.1.tar.gz
Size 66.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a20e3d3bbb5fb5508913db8f48ba7c77c7d2fb3331a4bb0c5cca367b9eabf17a
BLAKE2b-256 checksum
How to use checksums
10d89ee486ce69e584dd4fe3871d83d592f5c54964bd029e3401291cd8598849
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Release files / devision-0.2.1-py3-none-any.whl

Download URL devision-0.2.1-py3-none-any.whl
Size 74.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e695bf3ae31dab7d33b37d845ba7f1123a049ce90dda31f25bbe14b6dbbfc0e0
BLAKE2b-256 checksum
How to use checksums
503d414c35bd2ae67cdfd2e1997b8d8aa80f19c5ad3b0fa396d5bc1eb0911d9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

Security for devision 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for devision-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 7, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page