Luna4682 commited on
Commit
045e936
·
verified ·
1 Parent(s): cc92d77

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +143 -0
README.md CHANGED
@@ -1,3 +1,146 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ language:
4
+ - zh
5
+ base_model: Qwen/Qwen2.5-1.5B-Instruct
6
+ library_name: gguf
7
+ pipeline_tag: text-generation
8
+ tags:
9
+ - gguf
10
+ - qwen2
11
+ - information-extraction
12
+ - structured-output
13
+ - json
14
+ - memory
15
+ - chinese
16
+ - edge
17
  ---
18
+
19
+ Sentence2json — 中文单句 → 结构化事实(GGUF, Q8_0)
20
+
21
+ 1.说明
22
+
23
+ 这是一个把用户的一句话抽取成结构化事实的中文小模型;输出严格 JSON 行,只做"抽事实"这一件事,不做对话
24
+ 一般用于辅助Character.AI 类、AI 伴侣、视觉小说 NPC、桌宠、语音助手的人格记忆
25
+ 本模型完全在本地运行,不联网。您的私密对话、信息不会上传到云服务器
26
+
27
+ 基座:Qwen2.5-1.5B-Instruct 量化:Q8_0
28
+
29
+ 文件:fact-r8-q8_0.gguf(模型本体)
30
+ system_prompt.txt(系统提示词,不可更换,否则指标会崩)
31
+ SHA256SUMS.txt(校验码)
32
+ README.txt(本文件)
33
+
34
+ 2.用法
35
+
36
+ 推荐使用llama.cpp(也支持Ollama,可自行选择)
37
+
38
+ 示例:
39
+ 先确认llama-server可用
40
+ 起服务:
41
+ llama-server -m fact-r8-q8_0.gguf --host 127.0.0.1 --port 8091 -c 2048 -np 1 -ngl 99 --alias r8
42
+
43
+ 调用(OpenAI 兼容):
44
+ 注意:一次请求发一句话,不要成批输入
45
+ curl http://127.0.0.1:8091/v1/chat/completions -H "Content-Type: application/json" -d '{
46
+ "model": "r8", "temperature": 0, "max_tokens": 256,"repeat_penalty": 1.0,
47
+ "messages": [
48
+ {"role": "system", "content": "<system_prompt.txt 全文>"},
49
+ {"role": "user", "content": "<你要输入的原文>"}
50
+ ]
51
+ }'
52
+
53
+ 注意:调用时temperature一律建议手动设为0,否则模型会明显退化
54
+ max_tokens设256够用,经测试99%的输出在60token内
55
+ repeat_penalty建议设为1.0,调高可能会出现坏json(若你的客户端不认这个字段,可在启动参数里加 --repeat-penalty 1.0,两种写法等效。)
56
+ repeat_penalty 为 llama.cpp 扩展参数,换到其它后端时删除该项即可
57
+
58
+ 3.输出格式
59
+
60
+ 一行一个 JSON 对象。共三种形态:
61
+
62
+ // 形态 1:不自足(指代 / 省略 / 确认词 / 废话)
63
+ {"has_info": false, "self_contained": false}
64
+
65
+ // 形态 2/3:自足但没有关于"我"的可记信息(第三人称、反问、评价、玩笑…)
66
+ {"has_info": false, "self_contained": true, "certainty": "explicit"}
67
+
68
+ // 正例:全部字段
69
+ {"has_info": true, "self_contained": true, "subject_raw": "我",
70
+ "predicate": "对", "object_raw": "花生过敏", "polarity": 1,
71
+ "kind": "attribute", "certainty": "explicit", "time_expression": null}
72
+
73
+
74
+ 字段:has_info, self_contained, subject_raw, predicate, object_raw, polarity, kind, certainty, time_expression
75
+
76
+ 4.评测
77
+
78
+ 测试时采用真实聊天记录289条(大量指代不明,省略)+手写句子100条(大多是完整句子)
79
+ r8:
80
+ 真实记录289,含27条正事实:json合法率100%,负事实判正率0.8%(2条),正事实丢失率25.9%(7条),字段准确率95.7%
81
+ 手写句子100,含56条正事实:json合法率100%,负事实判正率0%(0条),正事实丢失率5.4%(3条),字段准确率98.9%
82
+ 本地Vulkan,单句延迟≈0.65s,单句成本0
83
+
84
+ 对比DeepSeekv4.1flash(相同提示词,额外提供1419字符规则文本):
85
+ 真实记录289,含27条正事实:json合法率100%,负事实判正率14.1%(37条),正事实丢失率7.4%(2条),字段准确率86.9%
86
+ 手写句子100,含56条正事实:json合法率100%,负事实判正率31.8%(14条),正事实丢失率1.8%(1条),字段准确率85.5%
87
+ 单句延迟≈1.0s(含网络),单句成本约 800 tokens
88
+
89
+ 对比Qwen3.8Max(相同提示词,额外提供1419字符规则文本):
90
+ 真实记录289,含27条正事实:json合法率100%,负事实判正率7.3%(19条),正事实丢失率22.2%(6条),字段准确率88.4%
91
+ 手写句子100,含56条正事实:我没跑,太贵了(目移)跑完289条就花了十块多
92
+ 单句延迟≈10.8s(含网络),单句成本约 1400 tokens
93
+
94
+
95
+ 5.已知限制
96
+
97
+ 中文为主,支持简单英文(但未系统实测)
98
+ 设计为“只记录与说话人直接相关的、有记录价值的事实,拿不准就判负”,尽量保持数据入库时“宁可漏不可错”
99
+ 为了方便抽取,设计为只抽取句子中出现的原话(除部分句式可以补“是”“有”来保证谓语行非空缺),但经过实测,模型仍有极小概率自己造字,不可完全信赖。使用时需要有后端逻辑兜底
100
+ 本模型每次只抽取第一个关于说话人本身的事实分句,多事实句会舍弃超出第一个的部分,如有需要,请将句子切分后再喂给模型
101
+ 在第一人称自述上训练:第三人称、反问、元话语、纯情绪会被判负,这是设计而非缺陷。
102
+
103
+ 6.许可
104
+
105
+ 权重与基座同为 Apache-2.0(Qwen2.5-1.5B-Instruct LICENSE:https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct/blob/main/LICENSE)
106
+ 训练数据为自建中文语料,不含基座模型输出以外的第三方数据。
107
+
108
+ 7.字段含义
109
+
110
+ "has_info": {"type": "boolean", "desc": "这句话里有没有关于“我”的可记事实"},
111
+ "self_contained": {"type": "boolean", "desc": "单拿出来看不看得懂(看不懂=不自足)"},
112
+ "subject_raw": {"type": "string", "desc": "只写第一人称(我/我们/咱们…),不还原、不补全"},
113
+ "predicate": {"type": "string", "desc": "从原句取;必要时补“是”“有”;体标记(了/过/着)紧跟谓语就归谓语"},
114
+ "object_raw": {"type": "string|null", "desc": "谓语后到第一个分句标点为止;没有就 null"},
115
+ "polarity": {"type": "integer", "enum": [1, -1],"desc": "肯定为1,否定为-1"},
116
+ "kind": {"type": "string", "enum": ["preference", "attribute", "event", "commitment", "relationship"]},
117
+ "certainty": {"type": "string", "enum": ["explicit", "speculation", "joke"]},
118
+ "time_expression": {"type": "string|null", "desc": "时间/频率的原话,不归一化"}
119
+
120
+ kind字段解释:
121
+ preference:偏好,喜好
122
+ attribute:状态,习惯,属性,特质
123
+ event:做过的事情
124
+ commitment:将要做的事情
125
+ relationship:拥有,持有关系
126
+ 注意:很多句子的kind比较特殊,无法准确归类,因此该字段只能用作参考
127
+
128
+ 8.简单单句示例
129
+
130
+ in : 我对花生过敏
131
+ out: {"has_info": true, "self_contained": true, "subject_raw": "我", "predicate": "对","object_raw": "花生过敏", "polarity": 1, "kind": "attribute","certainty": "explicit", "time_expression": null}
132
+
133
+ in : 我有个弟弟
134
+ out: {"has_info": true, "self_contained": true, "subject_raw": "我", "predicate": "有","object_raw": "个弟弟", "polarity": 1, "kind": "relationship","certainty": "explicit", "time_expression": null}
135
+
136
+ in:我不太喜欢公司的氛围
137
+ out:{"has_info": true, "self_contained": true, "subject_raw": "我", "predicate": "喜欢", "object_raw": "公司的氛围", "polarity": -1, "kind": "preference", "certainty": "explicit", "time_expression": null}
138
+
139
+ in : 你连这都知道,真牛逼啊
140
+ out: {"has_info": false, "self_contained": false}
141
+
142
+ in : 不,我的意思是,你知道这意味着什么吗
143
+ out: {"has_info": false, "self_contained": false}
144
+
145
+ in : 我昨天还想今天去医院来着,不过今天突然说是有课
146
+ out: {"has_info": false, "self_contained": true, "certainty": "explicit"}