初始化项目,由ModelHub XC社区提供模型

Model: xuanwulab/HaS_Text_0209_0.6B
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-07-01 16:57:01 +08:00
commit 4dc78f3859
11 changed files with 152387 additions and 0 deletions

40
.gitattributes vendored Normal file
View File

@@ -0,0 +1,40 @@
*.7z filter=lfs diff=lfs merge=lfs -text
*.arrow filter=lfs diff=lfs merge=lfs -text
*.bin filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.ckpt filter=lfs diff=lfs merge=lfs -text
*.ftz filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.h5 filter=lfs diff=lfs merge=lfs -text
*.joblib filter=lfs diff=lfs merge=lfs -text
*.lfs.* filter=lfs diff=lfs merge=lfs -text
*.mlmodel filter=lfs diff=lfs merge=lfs -text
*.model filter=lfs diff=lfs merge=lfs -text
*.msgpack filter=lfs diff=lfs merge=lfs -text
*.npy filter=lfs diff=lfs merge=lfs -text
*.npz filter=lfs diff=lfs merge=lfs -text
*.onnx filter=lfs diff=lfs merge=lfs -text
*.ot filter=lfs diff=lfs merge=lfs -text
*.parquet filter=lfs diff=lfs merge=lfs -text
*.pb filter=lfs diff=lfs merge=lfs -text
*.pickle filter=lfs diff=lfs merge=lfs -text
*.pkl filter=lfs diff=lfs merge=lfs -text
*.pt filter=lfs diff=lfs merge=lfs -text
*.pth filter=lfs diff=lfs merge=lfs -text
*.rar filter=lfs diff=lfs merge=lfs -text
*.safetensors filter=lfs diff=lfs merge=lfs -text
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
*.tar.* filter=lfs diff=lfs merge=lfs -text
*.tar filter=lfs diff=lfs merge=lfs -text
*.tflite filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.wasm filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text
*tfevents* filter=lfs diff=lfs merge=lfs -text
Figure1.png filter=lfs diff=lfs merge=lfs -text
Table1.png filter=lfs diff=lfs merge=lfs -text
Table2.png filter=lfs diff=lfs merge=lfs -text
Table3.png filter=lfs diff=lfs merge=lfs -text
tokenizer.json filter=lfs diff=lfs merge=lfs -text

560
README.md Normal file
View File

@@ -0,0 +1,560 @@
---
license: mit
language:
- zh
- en
- pt
- fr
- es
- de
- ko
- ja
tags:
- privacy
- anonymization
- ner
- pii
- hide-and-seek
- on-device
- qwen3
base_model: Qwen/Qwen3-0.6B-Base
pipeline_tag: text-generation
---
# HaS Text Model (Full Precision)
**HaS (Hide and Seek)** is an on-device privacy model providing a complete pipeline from entity recognition to anonymization and restoration.
- 📦 **0.6B parameters**, full precision (FP16), 1.2 GB
- 🔒 **Data never leaves device** — local inference, no network required
- 🌍 **8 languages natively supported**: Chinese, English, Portuguese, French, Spanish, German, Korean, Japanese
-**Apple M4 Pro benchmark**: prefill ~4,900 tok/s (llama.cpp), decode ~156 tok/s (mlx_lm)
> This is the **full-precision base model** for fine-tuning and research. For production deployment, use the quantized versions: [Q8_0](https://huggingface.co/xuanwulab/HaS_Text_0209_0.6B_Q8) (recommended) or [Q4_K_M](https://huggingface.co/xuanwulab/HaS_Text_0209_0.6B_Q4).
## 1. Core Capabilities
Traditional anonymization (regex, Presidio, etc.) only does pattern matching. HaS is an **on-device Agentic privacy pipeline** — a set of composable atomic capabilities that solve multi-turn consistency, reversible restoration, and post-anonymization data usability.
| Capability | Description |
|------------|-------------|
| **3-Level Semantic Tags** | Instead of `[REDACTED]`, produces tags like `<Amount[1].ContractAmount.NumberSymbol>` — LLMs understand "this is a contract amount", preserving data usability |
| **Coreference Resolution** | "CloudGenius Inc.", "CloudGenius", "云创智能" → all unified as `<Organization[1].Company.Name>`. Different forms, same ID |
| **Multi-turn Consistency** | Carries historical mapping dictionaries for incremental anonymization. Entity IDs stay consistent across turns. Same mechanism supports recursive chunking for long documents |
| **Reversible Restoration** | Anonymized text can be processed by cloud LLMs (translation, rewriting, etc.), then Seek restores the tags back to original values |
| **Open-set Entity Types** | Trained on ~70,000 entity types. Users can freely specify any type name without being limited to predefined categories |
| **Public/Private Distinction** | "Industrial and Commercial Bank of China" preserved, "Li Hong 138-xxxx" anonymized — only redacts what should be redacted |
## 2. Six Atomic Capabilities
| # | Capability | Description |
|---|------------|-------------|
| 1 | **NER** | Recognize named entities of specified types |
| 2 | **Hide_with** | Anonymize using an existing mapping dictionary (maintains cross-text consistency) |
| 3 | **Hide_without** | First-time anonymization (no mapping, model generates tags autonomously) |
| 4 | **Pair** | Extract mapping relationships from original and anonymized text pairs |
| 5 | **Split** | Split composite tags into atomic single-entity mappings |
| 6 | **Seek** | Restore tagged text using a mapping dictionary |
## 3. Structured Semantic Tags & Coreference Resolution
### 3-Level Semantic Tags
Tags use a `<EntityType[ID].Category.Attribute>` three-level structure:
```
<Address[1].City.CityName> ← identifies this as a city name
<Address[2].StreetAddress.FullAddress> ← identifies this as a detailed address
<Amount[1].ContractAmount.NumberSymbol> ← identifies this as a contract amount
<Phone[1].Mobile.FullNumber> ← identifies this as a mobile number
```
Comparison with traditional approaches:
| Traditional | HaS 3-Level Tag |
|-------------|-----------------|
| `[ADDRESS]` | `<Address[1].City.CityName>` |
| `[ADDRESS]` | `<Address[2].StreetAddress.FullAddress>` |
| `[MONEY]` | `<Amount[1].ContractAmount.NumberSymbol>` |
### Coreference Resolution
The same entity often appears in multiple forms. HaS automatically recognizes they refer to the same object and unifies them under one ID:
```
Original forms Unified tag
─────────────────── ───────────────────────
CloudGenius Inc. → <Organization[1].Company.Name>
CloudGenius → <Organization[1].Company.Name>
云创智能 → <Organization[1].Company.Name>
CG → <Organization[1].Company.Name>
```
This ensures anonymized text remains logically coherent — LLMs seeing multiple `<Organization[1]>` know it's the same company. Critical for multi-turn conversations and long document chunking: entity IDs remain globally consistent across turns and chunks.
## 4. Quick Start
Recommended deployment with llama.cpp:
```bash
llama-server -m has_text_model.gguf -ngl 999 -c 8192 -np 1 -fa on
```
- Listens on `http://127.0.0.1:8080/v1` by default
- OpenAI Chat Completions compatible API
- ~**2.4 GB** total memory with default settings
## 5. Usage Scenarios
The 6 atomic capabilities can be composed into various privacy pipelines:
| Scenario | Description | Capabilities Used |
|----------|-------------|-------------------|
| **Redacted Sharing** | Auto-anonymize files, emails, code before sending; retain mapping for restoration | Hide → Pair |
| **Privacy Scanning** | Scan files/directories, list all sensitive entities, assess exposure risk | NER |
| **Privacy Knowledge Base** | Anonymize documents before ingestion; restore query results via mapping | Hide → Pair (write), Seek (read) |
| **Log Redaction** | Batch-anonymize ops logs before handing to support teams | Hide → Pair |
| **Secure Cloud Chat** | Anonymize text before sending to cloud LLM; restore LLM responses | NER → Hide → Pair → Seek |
| **AI Memory Privacy** | Store Agent long-term memory in anonymized form; restore on demand | Hide → Pair (store), Seek (recall) |
## 6. Prompt Templates
> ⚠️ **Templates must match character-for-character** — the model was trained on these exact templates. Any deviation may degrade output quality.
### NER
```
Recognize the following entity types in the text.
Specified types:{types_json_array}
<text>{text}</text>
```
### Hide_with (with mapping)
**Turn 1**: Same as NER template
**Turn 2**:
```
Replace the above-mentioned entity types in the text according to the existing mapping pairs:{mapping_json}
```
### Hide_without (without mapping)
**Turn 1**: Same as NER template
**Turn 2** (fixed text, no variables):
```
Replace the above-mentioned entity types in the text.
```
### Pair
```
<original>{original_text}</original>
<anonymized>{anonymized_text}</anonymized>
Extract the mapping from anonymized entities to original entities.
```
### Split
```
Split each composite anonymized key into atomic keys.
Composite mapping:
{composite_mapping_json_array}
```
### Seek
```
The mapping from anonymized entities to original entities:
{mapping_json}
Restore the original text based on the above mapping:
{text_with_tags}
```
## 7. Speed Benchmarks
Test platform: Apple M4 Pro (48 GB RAM)
| Metric | llama.cpp | mlx_lm | mlc_llm |
|--------|:---------:|:------:|:-------:|
| **FP16 model size** | 1.2 GB | 1.2 GB | 1.2 GB |
| **FP16 prefill (tok/s)** | **4,904** | 4,272 | 1,818 |
| **FP16 decode (tok/s)** | 128 | **156** | 118 |
| **Q4 model size** | 0.4 GB | 0.4 GB | 0.4 GB |
| **Q4 prefill (tok/s)** | **4,828** | 3,183 | 2,236 |
| **Q4 decode (tok/s)** | 238 | **345** | 172 |
> All performance figures are rounded. **Bold** indicates best in class.
## 8. Quantization Versions
| Version | Quantization | File Size | Runtime Memory | Notes |
|---------|:---:|:---:|:---:|-------|
| **Full Precision** | FP16 | 1.2 GB | ~2.4 GB | Base model for fine-tuning and research |
| [Q8_0](https://huggingface.co/xuanwulab/HaS_Text_0209_0.6B_Q8) | 8.50 BPW | 639 MB | ~1.56 GB | **Recommended for production**, best output quality |
| [Q4_K_M](https://huggingface.co/xuanwulab/HaS_Text_0209_0.6B_Q4) | 5.24 BPW | 397 MB | ~1.29 GB | Faster inference, lower memory, for resource-constrained environments |
---
<details>
<summary><b>中文版</b></summary>
# HaS Text Model全量模型
**HaSHide and Seek** 是一个端侧部署的隐私模型,提供从实体识别到脱敏还原的完整管线。
- 📦 **0.6B 参数**全精度FP161.2 GB
- 🔒 **数据不出设备**,本地推理,无需联网
- 🌍 **8 语言原生支持**:中、英、葡、法、西、德、韩、日
-**Apple M4 Pro 实测**prefill ~4,900 tok/sllama.cppdecode ~156 tok/smlx_lm
> 这是**全精度基座模型**,适用于微调和研究。生产部署请使用量化版本:[Q8_0](https://huggingface.co/xuanwulab/HaS_Text_0209_0.6B_Q8)(推荐)或 [Q4_K_M](https://huggingface.co/xuanwulab/HaS_Text_0209_0.6B_Q4)。
## 一、核心能力
传统脱敏方案正则、Presidio 等只做模式匹配。HaS 的定位是**端侧 Agentic 隐私管线**——用一组可组合的原子能力解决多轮一致、可逆还原和脱敏后数据可用性的问题。
| 能力 | 说明 |
|------|------|
| **三级语义标签** | 脱敏后不是 `[REDACTED]`,而是 `<金额[1].合同金额.数字符号>` 这样携带语义的标签——LLM 一看就知道"这是一笔合同金额",保持脱敏后数据可用性 |
| **指代消解** | "云创智能有限公司"、"云创智能"、"CloudGenius"→ 全部归为 `<组织[1].企业.名称>`。不同写法,同一编号 |
| **多轮一致** | 携带历史映射字典做增量脱敏,跨轮次实体编号一致。同一机制支持递归分块处理超长文档 |
| **可逆还原** | 脱敏后的文本可先交给云端 LLM 处理翻译、改写等Seek 能对处理后文本中的标签进行还原 |
| **开集指定** | 训练覆盖约 7 万种实体类型,用户可自由指定任意类型名称,不受预定义类别限制 |
| **公私区分** | "中国工商银行"保留,"李红 138-xxxx"脱敏——只脱该脱的,不过度脱敏 |
## 二、6 个原子能力
| # | 能力 | 说明 |
|---|------|------|
| 1 | **NER** | 识别指定类型的命名实体 |
| 2 | **Hide_with** | 使用已有映射字典脱敏(保持跨文本一致) |
| 3 | **Hide_without** | 首次脱敏(无映射,模型自主生成标签) |
| 4 | **Pair** | 从原文和脱敏文本对中提取映射关系 |
| 5 | **Split** | 拆分复合标签为原子单实体映射 |
| 6 | **Seek** | 根据映射字典还原含标签的文本 |
## 三、结构化语义标签与指代消解
### 三级语义标签
脱敏后的标签采用 `<实体类型[编号].分类.属性>` 三级结构:
```
<地址[1].城市.市名> ← 知道这是一个城市名
<地址[2].街道门牌.完整地址> ← 知道这是一个详细地址
<金额[1].合同金额.数字符号> ← 知道这是一笔合同金额,不只是普通数字
<电话[1].手机号.完整号码> ← 知道这是手机号,不是座机或传真
```
对比传统脱敏方案:
| 传统方案 | HaS 三级标签 |
|---------|-------------|
| `[ADDRESS]` | `<地址[1].城市.市名>` |
| `[ADDRESS]` | `<地址[2].街道门牌.完整地址>` |
| `[MONEY]` | `<金额[1].合同金额.数字符号>` |
### 指代消解
同一实体在文本中往往以多种形式出现。HaS 会自动识别它们指向同一对象,统一归为同一编号:
```
原文中的写法 脱敏后统一为
─────────────────── ───────────────────────
云创智能科技有限公司 → <组织[1].企业.名称>
云创智能 → <组织[1].企业.名称>
CloudGenius → <组织[1].企业.名称>
云创 → <组织[1].企业.名称>
```
这确保了脱敏后的文本逻辑自洽——LLM 看到多处 `<组织[1]>` 就知道是同一家公司,而不会误以为是不同实体。在多轮对话和长文档分块中尤为关键:跨轮次、跨分块的实体编号全局一致。
## 四、快速开始
推荐使用 llama.cpp 推理框架:
```bash
llama-server -m has_text_model.gguf -ngl 999 -c 8192 -np 1 -fa on
```
- 默认监听 `http://127.0.0.1:8080/v1`
- API 兼容 OpenAI Chat Completions 格式
- 默认配置下总内存约 **2.4 GB**
## 五、使用场景
6 个原子能力可以组合成多种隐私管线:
| 场景 | 说明 | 使用能力 |
|------|------|----------|
| **脱敏分享** | 文件、邮件、代码在外发前自动脱敏,保留映射表可随时还原 | Hide → Pair |
| **全量隐私扫描** | 扫描文件或目录,列出所有敏感实体,评估泄露风险 | NER |
| **隐私知识库** | 文档先脱敏再入库,查询结果通过映射表还原原文 | Hide → Pair写入、Seek读取 |
| **日志脱敏** | 运维日志在交给支持团队前批量脱敏 | Hide → Pair |
| **安全云端对话** | 脱敏后文本发给云端 LLM 处理LLM 返回结果再还原 | NER → Hide → Pair → Seek |
| **AI 记忆隐私** | Agent 的长期记忆以脱敏形式存储,使用时按需还原 | Hide → Pair存储、Seek召回 |
## 六、提示词模板
> ⚠️ **模板必须逐字符精确匹配**,模型基于这些模板训练。任何偏差(空格、换行、标点)都可能降低输出质量。
### NER
```
Recognize the following entity types in the text.
Specified types:{types_json_array}
<text>{text}</text>
```
### Hide_with带映射脱敏
**第 1 轮**:与 NER 模板相同
**第 2 轮**
```
Replace the above-mentioned entity types in the text according to the existing mapping pairs:{mapping_json}
```
### Hide_without无映射脱敏
**第 1 轮**:与 NER 模板相同
**第 2 轮**(固定文本,无变量):
```
Replace the above-mentioned entity types in the text.
```
### Pair提取映射
```
<original>{original_text}</original>
<anonymized>{anonymized_text}</anonymized>
Extract the mapping from anonymized entities to original entities.
```
### Split拆分复合标签
```
Split each composite anonymized key into atomic keys.
Composite mapping:
{composite_mapping_json_array}
```
### Seek还原
```
The mapping from anonymized entities to original entities:
{mapping_json}
Restore the original text based on the above mapping:
{text_with_tags}
```
## 7. Speed Benchmarks
Test platform: Apple M4 Pro (48 GB RAM)
| Metric | llama.cpp | mlx_lm | mlc_llm |
|--------|:---------:|:------:|:-------:|
| **FP16 model size** | 1.2 GB | 1.2 GB | 1.2 GB |
| **FP16 prefill (tok/s)** | **4,904** | 4,272 | 1,818 |
| **FP16 decode (tok/s)** | 128 | **156** | 118 |
| **Q4 model size** | 0.4 GB | 0.4 GB | 0.4 GB |
| **Q4 prefill (tok/s)** | **4,828** | 3,183 | 2,236 |
| **Q4 decode (tok/s)** | 238 | **345** | 172 |
> All performance figures are rounded. **Bold** indicates best in class.
## 8. Quantization Versions
| Version | Quantization | File Size | Runtime Memory | Notes |
|---------|:---:|:---:|:---:|-------|
| **Full Precision** | FP16 | 1.2 GB | ~2.4 GB | Base model for fine-tuning and research |
| [Q8_0](https://huggingface.co/xuanwulab/HaS_Text_0209_0.6B_Q8) | 8.50 BPW | 639 MB | ~1.56 GB | **Recommended for production**, best output quality |
| [Q4_K_M](https://huggingface.co/xuanwulab/HaS_Text_0209_0.6B_Q4) | 5.24 BPW | 397 MB | ~1.29 GB | Faster inference, lower memory, for resource-constrained environments |
---
<details>
<summary><b>中文版</b></summary>
# HaS Text Model全量模型
**HaSHide and Seek** 是一个端侧部署的隐私模型,提供从实体识别到脱敏还原的完整管线。
- 📦 **0.6B 参数**全精度FP161.2 GB
- 🔒 **数据不出设备**,本地推理,无需联网
- 🌍 **8 语言原生支持**:中、英、葡、法、西、德、韩、日
-**Apple M4 Pro 实测**prefill ~4,900 tok/sllama.cppdecode ~156 tok/smlx_lm
> 这是**全精度基座模型**,适用于微调和研究。生产部署请使用量化版本:[Q8_0](https://huggingface.co/xuanwulab/HaS_Text_0209_0.6B_Q8)(推荐)或 [Q4_K_M](https://huggingface.co/xuanwulab/HaS_Text_0209_0.6B_Q4)。
## 一、核心能力
传统脱敏方案正则、Presidio 等只做模式匹配。HaS 的定位是**端侧 Agentic 隐私管线**——用一组可组合的原子能力解决多轮一致、可逆还原和脱敏后数据可用性的问题。
| 能力 | 说明 |
|------|------|
| **三级语义标签** | 脱敏后不是 `[REDACTED]`,而是 `<金额[1].合同金额.数字符号>` 这样携带语义的标签——LLM 一看就知道"这是一笔合同金额",保持脱敏后数据可用性 |
| **指代消解** | "云创智能有限公司"、"云创智能"、"CloudGenius"→ 全部归为 `<组织[1].企业.名称>`。不同写法,同一编号 |
| **多轮一致** | 携带历史映射字典做增量脱敏,跨轮次实体编号一致。同一机制支持递归分块处理超长文档 |
| **可逆还原** | 脱敏后的文本可先交给云端 LLM 处理翻译、改写等Seek 能对处理后文本中的标签进行还原 |
| **开集指定** | 训练覆盖约 7 万种实体类型,用户可自由指定任意类型名称,不受预定义类别限制 |
| **公私区分** | "中国工商银行"保留,"李红 138-xxxx"脱敏——只脱该脱的,不过度脱敏 |
## 二、6 个原子能力
| # | 能力 | 说明 |
|---|------|------|
| 1 | **NER** | 识别指定类型的命名实体 |
| 2 | **Hide_with** | 使用已有映射字典脱敏(保持跨文本一致) |
| 3 | **Hide_without** | 首次脱敏(无映射,模型自主生成标签) |
| 4 | **Pair** | 从原文和脱敏文本对中提取映射关系 |
| 5 | **Split** | 拆分复合标签为原子单实体映射 |
| 6 | **Seek** | 根据映射字典还原含标签的文本 |
## 三、结构化语义标签与指代消解
### 三级语义标签
脱敏后的标签采用 `<实体类型[编号].分类.属性>` 三级结构:
```
<地址[1].城市.市名> ← 知道这是一个城市名
<地址[2].街道门牌.完整地址> ← 知道这是一个详细地址
<金额[1].合同金额.数字符号> ← 知道这是一笔合同金额,不只是普通数字
<电话[1].手机号.完整号码> ← 知道这是手机号,不是座机或传真
```
对比传统脱敏方案:
| 传统方案 | HaS 三级标签 |
|---------|-------------|
| `[ADDRESS]` | `<地址[1].城市.市名>` |
| `[ADDRESS]` | `<地址[2].街道门牌.完整地址>` |
| `[MONEY]` | `<金额[1].合同金额.数字符号>` |
### 指代消解
同一实体在文本中往往以多种形式出现。HaS 会自动识别它们指向同一对象,统一归为同一编号:
```
原文中的写法 脱敏后统一为
─────────────────── ───────────────────────
云创智能科技有限公司 → <组织[1].企业.名称>
云创智能 → <组织[1].企业.名称>
CloudGenius → <组织[1].企业.名称>
云创 → <组织[1].企业.名称>
```
这确保了脱敏后的文本逻辑自洽——LLM 看到多处 `<组织[1]>` 就知道是同一家公司,而不会误以为是不同实体。
## 四、快速开始
推荐使用 llama.cpp 推理框架:
```bash
llama-server -m has_text_model.gguf -ngl 999 -c 8192 -np 1 -fa on
```
- 默认监听 `http://127.0.0.1:8080/v1`
- API 兼容 OpenAI Chat Completions 格式
- 默认配置下总内存约 **2.4 GB**
## 五、使用场景
6 个原子能力可以组合成多种隐私管线:
| 场景 | 说明 | 使用能力 |
|------|------|----------|
| **脱敏分享** | 文件、邮件、代码在外发前自动脱敏,保留映射表可随时还原 | Hide → Pair |
| **全量隐私扫描** | 扫描文件或目录,列出所有敏感实体,评估泄露风险 | NER |
| **隐私知识库** | 文档先脱敏再入库,查询结果通过映射表还原原文 | Hide → Pair写入、Seek读取 |
| **日志脱敏** | 运维日志在交给支持团队前批量脱敏 | Hide → Pair |
| **安全云端对话** | 脱敏后文本发给云端 LLM 处理LLM 返回结果再还原 | NER → Hide → Pair → Seek |
| **AI 记忆隐私** | Agent 的长期记忆以脱敏形式存储,使用时按需还原 | Hide → Pair存储、Seek召回 |
## 六、提示词模板
> ⚠️ **模板必须逐字符精确匹配**,模型基于这些模板训练。任何偏差(空格、换行、标点)都可能降低输出质量。
### NER
```
Recognize the following entity types in the text.
Specified types:{types_json_array}
<text>{text}</text>
```
### Hide_with带映射脱敏
**第 1 轮**:与 NER 模板相同
**第 2 轮**
```
Replace the above-mentioned entity types in the text according to the existing mapping pairs:{mapping_json}
```
### Hide_without无映射脱敏
**第 1 轮**:与 NER 模板相同
**第 2 轮**(固定文本,无变量):
```
Replace the above-mentioned entity types in the text.
```
### Pair提取映射
```
<original>{original_text}</original>
<anonymized>{anonymized_text}</anonymized>
Extract the mapping from anonymized entities to original entities.
```
### Split拆分复合标签
```
Split each composite anonymized key into atomic keys.
Composite mapping:
{composite_mapping_json_array}
```
### Seek还原
```
The mapping from anonymized entities to original entities:
{mapping_json}
Restore the original text based on the above mapping:
{text_with_tags}
```
## 七、速度评估
测试平台Apple M4 Pro48 GB 内存)
| 指标 | llama.cpp | mlx_lm | mlc_llm |
|------|:---------:|:------:|:-------:|
| **FP16 模型大小** | 1.2 GB | 1.2 GB | 1.2 GB |
| **FP16 prefilltok/s** | **4,904** | 4,272 | 1,818 |
| **FP16 decodetok/s** | 128 | **156** | 118 |
| **Q4 模型大小** | 0.4 GB | 0.4 GB | 0.4 GB |
| **Q4 prefilltok/s** | **4,828** | 3,183 | 2,236 |
| **Q4 decodetok/s** | 238 | **345** | 172 |
> 所有性能数据均已取整。**粗体**表示该项最佳表现。
## 八、量化版本
| 版本 | 量化 | 文件大小 | 运行内存 | 说明 |
|------|:---:|:---:|:---:|------|
| **全量模型** | FP16 | 1.2 GB | ~2.4 GB | 基座模型,适用于微调和研究 |
| [Q8_0](https://huggingface.co/xuanwulab/HaS_Text_0209_0.6B_Q8) | 8.50 BPW | 639 MB | ~1.56 GB | **推荐生产使用**,输出质量最佳 |
| [Q4_K_M](https://huggingface.co/xuanwulab/HaS_Text_0209_0.6B_Q4) | 5.24 BPW | 397 MB | ~1.29 GB | 推理更快,内存更省,适合资源受限场景 |
</details>

85
chat_template.jinja Normal file
View File

@@ -0,0 +1,85 @@
{%- if tools %}
{{- '<|im_start|>system\n' }}
{%- if messages[0].role == 'system' %}
{{- messages[0].content + '\n\n' }}
{%- endif %}
{{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
{%- for tool in tools %}
{{- "\n" }}
{{- tool | tojson }}
{%- endfor %}
{{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
{%- else %}
{%- if messages[0].role == 'system' %}
{{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
{%- endif %}
{%- endif %}
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
{%- for message in messages[::-1] %}
{%- set index = (messages|length - 1) - loop.index0 %}
{%- if ns.multi_step_tool and message.role == "user" and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
{%- set ns.multi_step_tool = false %}
{%- set ns.last_query_index = index %}
{%- endif %}
{%- endfor %}
{%- for message in messages %}
{%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
{{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
{%- elif message.role == "assistant" %}
{%- set content = message.content %}
{%- set reasoning_content = '' %}
{%- if message.reasoning_content is defined and message.reasoning_content is not none %}
{%- set reasoning_content = message.reasoning_content %}
{%- else %}
{%- if '</think>' in message.content %}
{%- set content = message.content.split('</think>')[-1].lstrip('\n') %}
{%- set reasoning_content = message.content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
{%- endif %}
{%- endif %}
{%- if loop.index0 > ns.last_query_index %}
{%- if loop.last or (not loop.last and reasoning_content) %}
{{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
{%- else %}
{{- '<|im_start|>' + message.role + '\n' + content }}
{%- endif %}
{%- else %}
{{- '<|im_start|>' + message.role + '\n' + content }}
{%- endif %}
{%- if message.tool_calls %}
{%- for tool_call in message.tool_calls %}
{%- if (loop.first and content) or (not loop.first) %}
{{- '\n' }}
{%- endif %}
{%- if tool_call.function %}
{%- set tool_call = tool_call.function %}
{%- endif %}
{{- '<tool_call>\n{"name": "' }}
{{- tool_call.name }}
{{- '", "arguments": ' }}
{%- if tool_call.arguments is string %}
{{- tool_call.arguments }}
{%- else %}
{{- tool_call.arguments | tojson }}
{%- endif %}
{{- '}\n</tool_call>' }}
{%- endfor %}
{%- endif %}
{{- '<|im_end|>\n' }}
{%- elif message.role == "tool" %}
{%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
{{- '<|im_start|>user' }}
{%- endif %}
{{- '\n<tool_response>\n' }}
{{- message.content }}
{{- '\n</tool_response>' }}
{%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
{{- '<|im_end|>\n' }}
{%- endif %}
{%- endif %}
{%- endfor %}
{%- if add_generation_prompt %}
{{- '<|im_start|>assistant\n' }}
{%- if enable_thinking is defined and enable_thinking is false %}
{{- '<think>\n\n</think>\n\n' }}
{%- endif %}
{%- endif %}

30
config.json Normal file
View File

@@ -0,0 +1,30 @@
{
"architectures": [
"Qwen3ForCausalLM"
],
"attention_bias": false,
"attention_dropout": 0.0,
"bos_token_id": 151643,
"eos_token_id": 151643,
"head_dim": 128,
"hidden_act": "silu",
"hidden_size": 1024,
"initializer_range": 0.02,
"intermediate_size": 3072,
"max_position_embeddings": 32768,
"max_window_layers": 28,
"model_type": "qwen3",
"num_attention_heads": 16,
"num_hidden_layers": 28,
"num_key_value_heads": 8,
"rms_norm_eps": 1e-06,
"rope_scaling": null,
"rope_theta": 1000000,
"sliding_window": null,
"tie_word_embeddings": true,
"torch_dtype": "bfloat16",
"transformers_version": "4.52.3",
"use_cache": false,
"use_sliding_window": false,
"vocab_size": 151936
}

6
generation_config.json Normal file
View File

@@ -0,0 +1,6 @@
{
"bos_token_id": 151643,
"eos_token_id": 151643,
"max_new_tokens": 2048,
"transformers_version": "4.52.3"
}

151388
merges.txt Normal file

File diff suppressed because it is too large Load Diff

3
model.safetensors Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:c507df88475199370d85d89e37d098e6dd7395aa5e16e8dd7cf57120cc54bb06
size 1192135096

31
special_tokens_map.json Normal file
View File

@@ -0,0 +1,31 @@
{
"additional_special_tokens": [
"<|im_start|>",
"<|im_end|>",
"<|object_ref_start|>",
"<|object_ref_end|>",
"<|box_start|>",
"<|box_end|>",
"<|quad_start|>",
"<|quad_end|>",
"<|vision_start|>",
"<|vision_end|>",
"<|vision_pad|>",
"<|image_pad|>",
"<|video_pad|>"
],
"eos_token": {
"content": "<|im_end|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false
},
"pad_token": {
"content": "<|endoftext|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false
}
}

BIN
tokenizer.json (Stored with Git LFS) Normal file

Binary file not shown.

240
tokenizer_config.json Normal file
View File

@@ -0,0 +1,240 @@
{
"add_bos_token": false,
"add_prefix_space": false,
"added_tokens_decoder": {
"151643": {
"content": "<|endoftext|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151644": {
"content": "<|im_start|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151645": {
"content": "<|im_end|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151646": {
"content": "<|object_ref_start|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151647": {
"content": "<|object_ref_end|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151648": {
"content": "<|box_start|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151649": {
"content": "<|box_end|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151650": {
"content": "<|quad_start|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151651": {
"content": "<|quad_end|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151652": {
"content": "<|vision_start|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151653": {
"content": "<|vision_end|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151654": {
"content": "<|vision_pad|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151655": {
"content": "<|image_pad|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151656": {
"content": "<|video_pad|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": true
},
"151657": {
"content": "<tool_call>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151658": {
"content": "</tool_call>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151659": {
"content": "<|fim_prefix|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151660": {
"content": "<|fim_middle|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151661": {
"content": "<|fim_suffix|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151662": {
"content": "<|fim_pad|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151663": {
"content": "<|repo_name|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151664": {
"content": "<|file_sep|>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151665": {
"content": "<tool_response>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151666": {
"content": "</tool_response>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151667": {
"content": "<think>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
},
"151668": {
"content": "</think>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false,
"special": false
}
},
"additional_special_tokens": [
"<|im_start|>",
"<|im_end|>",
"<|object_ref_start|>",
"<|object_ref_end|>",
"<|box_start|>",
"<|box_end|>",
"<|quad_start|>",
"<|quad_end|>",
"<|vision_start|>",
"<|vision_end|>",
"<|vision_pad|>",
"<|image_pad|>",
"<|video_pad|>"
],
"bos_token": null,
"clean_up_tokenization_spaces": false,
"eos_token": "<|im_end|>",
"errors": "replace",
"extra_special_tokens": {},
"model_max_length": 131072,
"pad_token": "<|endoftext|>",
"padding_side": "right",
"split_special_tokens": false,
"tokenizer_class": "Qwen2Tokenizer",
"unk_token": null
}

1
vocab.json Normal file

File diff suppressed because one or more lines are too long