---
title: Prism-v3-exp
canonical_url: "https://www.modelscope.cn/models/hcymcweb/Prism-v3-exp"
md_url: "https://www.modelscope.cn/models/hcymcweb/Prism-v3-exp.md"
repository: hcymcweb/Prism-v3-exp
chinese_name: Prism-v3-exp
last_updated: 2026-11-20
license: apache-2.0
pipeline_tag: text-classification
tasks:
  - text-classification
library_name:
  - pytorch
  - onnx
language:
  - zh
downloads: 4
stars: 1
tags:
  - chinese
  - domain-classification
  - text-classification
  - from-scratch
  - small-language-model
  - onnx
---

# Prism-v3-exp

> Prism-v3-exp - hcymcweb 在 ModelScope 开源的模型。一个在8G显存显卡上从零训练的中文小语言分类模型，31个领域输出，使用BAAI/IndustryCorpus2开源数据集

hcymcweb/Prism-v3-exp 是 ModelScope 魔搭社区上的text-classification模型，采用 apache-2.0 许可。

- **Repository**: hcymcweb/Prism-v3-exp
- **License**: apache-2.0
- **Tasks**: text-classification
- **Tags**: chinese, domain-classification, text-classification, from-scratch, small-language-model, onnx
- **Downloads**: 4
- **Stars**: 1
- **Last updated**: 2026-11-20

Source: https://www.modelscope.cn/models/hcymcweb/Prism-v3-exp

---

<p align="center">
<img alt="Prism logo" src="https://raw.githubusercontent.com/hcymc/Prism/main/assets/logo/prism-logo.svg" width="160" height="160">
<h1 align="center">Prism-v3-exp</h1>
</p>

<p>
<img alt="version" src="https://img.shields.io/badge/version-v3-blue">
<img alt="status" src="https://img.shields.io/badge/status-experimental_preview-orange">
<img alt="model" src="https://img.shields.io/badge/model-prism__v3__exp-green">
<img alt="params" src="https://img.shields.io/badge/params-33.35M-blueviolet">
<img alt="license" src="https://img.shields.io/badge/license-Apache--2.0-lightgrey">
</p>

**一个从零训练的中文小语言模型：一边猜下一个字，一边把整段文字拆成 31 个行业的概率光谱。**

代码、训练脚本、网页与文档都在 GitHub：**https://github.com/hcymc/Prism**
在线体验（不用装环境）：**https://model.hcy.ink**

一束白光穿过棱镜散成光谱，一段文字穿过 8 层散成 31 路概率。
输入一段中文（≤512 字），输出一个 31 维的行业分布——不是给你一个标签，是给你一整条光谱。

- 33,353,760 参数 · 8 层 decoder-only · d=512 · 8 头 · FFN 2048 · RoPE · 字符级词表 15,341
- 从随机初始化开始，在 IndustryCorpus2 的 3.56 亿字上训 129,600 步（单卡 2080 SUPER，约 6 小时）
- 手写 PyTorch，不依赖 `transformers` / `datasets`

**实验预览，不是可直接用的打标工具。** 短文本差、不会说「不确定」、类目重叠是硬天花板，
详见下面的「已知限制」。

## 文件

| 文件 | 体积 | 说明 |
| --- | --- | --- |
| `prism-v3-exp.pt` | 79 MB | 完整权重（fp16），带 `config / vocab / domains / step` |
| `domain_int8.onnx` | 40 MB | 动态量化 int8，只含领域出口，**推理不需要 torch** |
| `domain_fp32.onnx` | 136 MB | 未量化 ONNX，与 torch 输出逐位相同 |
| `model_meta.json` | 200 KB | 词表 + 31 个类名 + `max_len` + 训练步数 |

## 用法

### torch

```python
import torch
from model import TinyDomainLM          # 来自 GitHub 仓库的 src/

ck = torch.load("prism-v3-exp.pt", map_location="cpu")
model = TinyDomainLM(**ck["config"]).eval()
model.load_state_dict(ck["model"])      # fp16 载入 fp32 模型会自动转换
vocab, domains = ck["vocab"], ck["domains"]

text = "央行今日下调中期借贷便利利率十个基点，市场普遍预期后续还有降准空间。"
ids = [vocab[c] for c in text if c in vocab][:512]
ids = (ids * ((512 + len(ids) - 1) // len(ids)))[:512]      # 短文本重复补齐到 512
x = torch.tensor([ids])

with torch.no_grad():
    p = torch.softmax(model(x, lm_weight=0.0)["domain_logits"].float(), -1)[0]
top = p.topk(5)
for i, v in zip(top.indices.tolist(), top.values.tolist()):
    print(f"{domains[i]:<20} {v*100:.1f}%")
```

### ONNX（不装 torch，2 核 2G 也能跑）

```python
import json, numpy as np, onnxruntime as ort

sess = ort.InferenceSession("domain_int8.onnx", providers=["CPUExecutionProvider"])
meta = json.load(open("model_meta.json", encoding="utf-8"))
vocab, domains = meta["vocab"], meta["domains"]
# ……同上，先归一化全角标点并补齐到 512……
logits = sess.run(None, {"ids": np.asarray([ids], dtype=np.int64)})[0][0]
```

### 输入两条必须做的事

1. **全角标点转半角**。训练语料的逗号句号全是半角，词表里只有一个中文标点 `·`；
   不转的话每个 `，` 都变成 `<unk>`，置信度会稳定低 0.03~0.06（命中率影响在噪声内）。
2. **短文本重复补齐到 512 字**。训练时永远见 512 字，30 字直接判只有 44%，补齐后 62.5%。

参考实现：GitHub 仓库的 `src/textproc.py` 与 `src/serve_onnx.py`。

## 指标

| 项目 | 值 |
| --- | --- |
| 类均衡召回（每类 20 篇，600 篇） | **85.2%** |
| 自然分布（2000 篇） | 88.45% |
| 512 字输入 | 82–88% |
| 300 / 150 / 80 / 30 字 | 72.2% / 56.7% / 51.1% / 44.4% |
| int8 vs fp32 同判率 | 99.7%（300 篇） |

按类看：航空航天、计算机编程 100%；计算机_通信 50%、其他制造 / 科技_科学研究 / 石油化工 60%、
电力能源 65%（这几类边界本身就重叠）。

## 已知限制

- **短文本不可用**：30 字 44%，靠重复补齐能到 62.5%，仍远低于长文。
- **不会说「不确定」**：31 个槽位里第 31 格「其他」没有训练样本，模糊文本只能硬选一个真类，
  而且常常很有信心。例如一篇写「城市一天」的散文被判成 `住宿_餐饮_酒店` 95.4%。
- **类目重叠是硬天花板**：不是分类头不会分，是那几堆向量本来就没分开。
- **输出不是真的软标签**：目标是「真类 0.95 + 其余均摊」，分布形状由标签平滑决定，
  不代表真实的领域共存比例；当权重用之前请做温度校准。
- **换一批文本掉 20 个点**：同类语料 85%，外部模型写的 150 篇只有 64%。
- **只训过中文**，英文和其他语言没有兜底。

## 相关链接

| | |
| --- | --- |
| 在线体验（推理网页） | https://model.hcy.ink |
| GitHub（代码 / 训练脚本 / 网页 / 文档） | https://github.com/hcymc/Prism |
| HuggingFace | https://huggingface.co/hcy-ai/prism-v3-exp |
| ModelScope | https://www.modelscope.cn/models/hcymcweb/Prism-v3-exp |

## 许可

- 权重：**Apache-2.0**（继承上游数据集条款）
- 训练数据：`BAAI/IndustryCorpus2`，Apache-2.0
- 代码：MIT（GitHub 仓库）
- 本模型与 IndustryCorpus2 的发布方无隶属关系
