quyet 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- quyet-1.0.0/.gitignore +7 -0
- quyet-1.0.0/LICENSE +202 -0
- quyet-1.0.0/NOTICE +29 -0
- quyet-1.0.0/PKG-INFO +120 -0
- quyet-1.0.0/README.md +89 -0
- quyet-1.0.0/pyproject.toml +51 -0
- quyet-1.0.0/src/quyet/__init__.py +6 -0
- quyet-1.0.0/src/quyet/__main__.py +5 -0
- quyet-1.0.0/src/quyet/answers.py +31 -0
- quyet-1.0.0/src/quyet/base.py +47 -0
- quyet-1.0.0/src/quyet/calibration.py +19 -0
- quyet-1.0.0/src/quyet/cli.py +39 -0
- quyet-1.0.0/src/quyet/encoder/__init__.py +0 -0
- quyet-1.0.0/src/quyet/encoder/inputs.py +114 -0
- quyet-1.0.0/src/quyet/encoder/modeling.py +123 -0
- quyet-1.0.0/src/quyet/encoder/runtime.py +75 -0
- quyet-1.0.0/src/quyet/errors.py +2 -0
- quyet-1.0.0/src/quyet/hub.py +49 -0
- quyet-1.0.0/src/quyet/llm/__init__.py +0 -0
- quyet-1.0.0/src/quyet/llm/prompt.py +83 -0
- quyet-1.0.0/src/quyet/llm/runtime.py +110 -0
- quyet-1.0.0/src/quyet/questions.py +80 -0
- quyet-1.0.0/tests/conftest.py +75 -0
- quyet-1.0.0/tests/test_answers.py +27 -0
- quyet-1.0.0/tests/test_calibration.py +25 -0
- quyet-1.0.0/tests/test_cli.py +16 -0
- quyet-1.0.0/tests/test_encoder_inputs.py +98 -0
- quyet-1.0.0/tests/test_encoder_runtime.py +65 -0
- quyet-1.0.0/tests/test_hub.py +20 -0
- quyet-1.0.0/tests/test_llm.py +120 -0
- quyet-1.0.0/tests/test_packaging.py +54 -0
- quyet-1.0.0/tests/test_questions.py +76 -0
quyet-1.0.0/.gitignore
ADDED
quyet-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
quyet-1.0.0/NOTICE
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Quyet by Chinh Nguyen
|
|
2
|
+
Copyright 2026 Chinh Nguyen
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (see LICENSE). Redistributions of this work or of derivative works must keep this NOTICE, including the credit line above.
|
|
5
|
+
|
|
6
|
+
This work includes or derives from:
|
|
7
|
+
- Gemma 4 by Google (Apache-2.0): https://huggingface.co/google/gemma-4-31B-it (revision 842da3794eaa)
|
|
8
|
+
- Qwen3.5 by Alibaba Cloud (Apache-2.0): https://huggingface.co/Qwen/Qwen3.5-4B (revision 851bf6e806ef)
|
|
9
|
+
- SEA-LION-ModernBERT-300M by AI Singapore (MIT; Copyright 2023 AI Singapore): https://huggingface.co/aisingapore/SEA-LION-ModernBERT-300M (revision e3d70b810769)
|
|
10
|
+
|
|
11
|
+
MIT License text for aisingapore/SEA-LION-ModernBERT-300M:
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
14
|
+
|
|
15
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
18
|
+
- ModernBERT-base by Answer.AI and LightOn (Apache-2.0): https://huggingface.co/answerdotai/ModernBERT-base (revision 8949b909ec90)
|
|
19
|
+
- mmBERT-small by the mmBERT authors, JHU CLSP (MIT); first 16 of its 22 layers: https://huggingface.co/jhu-clsp/mmBERT-small (revision abc32620dd4f)
|
|
20
|
+
|
|
21
|
+
MIT License text for jhu-clsp/mmBERT-small:
|
|
22
|
+
|
|
23
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
24
|
+
|
|
25
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
26
|
+
|
|
27
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
|
+
|
|
29
|
+
The encoder models' option rendering and the refinement head of Quyet-1.0-Small follow Laya by Convai Innovations (https://huggingface.co/convaiinnovations/laya, Apache-2.0); this code was modified. No Laya weights are used.
|
quyet-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: quyet
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Quyet decision models: pick one option for a state and a question, with calibrated probabilities.
|
|
5
|
+
Project-URL: Homepage, https://huggingface.co/chinhnc
|
|
6
|
+
Project-URL: Source, https://github.com/ncchinh/quyet
|
|
7
|
+
Project-URL: Issues, https://github.com/ncchinh/quyet/issues
|
|
8
|
+
Author: Chinh Nguyen
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
License-File: NOTICE
|
|
12
|
+
Keywords: calibration,classification,decision model,encoder,llm
|
|
13
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Requires-Dist: huggingface-hub>=0.34
|
|
22
|
+
Requires-Dist: numpy>=1.26
|
|
23
|
+
Requires-Dist: safetensors>=0.4
|
|
24
|
+
Requires-Dist: torch>=2.4
|
|
25
|
+
Requires-Dist: transformers>=5.17
|
|
26
|
+
Provides-Extra: multi-gpu
|
|
27
|
+
Requires-Dist: accelerate>=1.0; extra == 'multi-gpu'
|
|
28
|
+
Provides-Extra: test
|
|
29
|
+
Requires-Dist: pytest>=8; extra == 'test'
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# Quyet
|
|
33
|
+
|
|
34
|
+
Quyet is a family of **decision models**. Give it a state (any text, JSON or conversation) and
|
|
35
|
+
one or more typed questions; it picks one option per question and returns calibrated probabilities. Nothing is
|
|
36
|
+
generated: every answer is a probability distribution over the options you supplied.
|
|
37
|
+
|
|
38
|
+
This package is the runtime for all Quyet 1.0 models. The weights are on Hugging Face.
|
|
39
|
+
|
|
40
|
+
The models are built for English and also tuned for Vietnamese; other languages work, with lower accuracy. Small-EN is
|
|
41
|
+
trained on English only.
|
|
42
|
+
|
|
43
|
+
| model | kind | parameters |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
| [Quyet-1.0-Large](https://huggingface.co/chinhnc/Quyet-1.0-Large) | LLM (GPU) | 31.3B (30.7B text) |
|
|
46
|
+
| [Quyet-1.0-Medium](https://huggingface.co/chinhnc/Quyet-1.0-Medium) | LLM (GPU) | 4.66B (4.21B text) |
|
|
47
|
+
| [Quyet-1.0-Small](https://huggingface.co/chinhnc/Quyet-1.0-Small) | encoder (CPU or GPU) | 328M |
|
|
48
|
+
| [Quyet-1.0-Small-EN](https://huggingface.co/chinhnc/Quyet-1.0-Small-EN) | encoder (CPU or GPU) | 153M |
|
|
49
|
+
| [Quyet-1.0-Tiny](https://huggingface.co/chinhnc/Quyet-1.0-Tiny) | encoder (CPU or GPU) | 183M |
|
|
50
|
+
|
|
51
|
+
## Install
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pip install quyet # CPU or single GPU
|
|
55
|
+
pip install "quyet[multi-gpu]" # spread Quyet-1.0-Large over several GPUs (device_map="auto")
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Python 3.10 or newer. The first `quyet.load` downloads the weights from Hugging Face.
|
|
59
|
+
|
|
60
|
+
## Use
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
import quyet
|
|
64
|
+
|
|
65
|
+
m = quyet.load("chinhnc/Quyet-1.0-Small")
|
|
66
|
+
r = m.predict(
|
|
67
|
+
{"message": "Please close my card, I lost it yesterday."},
|
|
68
|
+
{"intent": {"type": "choice", "instructions": "What does the customer want?",
|
|
69
|
+
"criteria": {"cancel": "close the card", "limit": "change the limit", "other": None}},
|
|
70
|
+
"urgent": {"type": "noul", "instructions": "The request is urgent."},
|
|
71
|
+
"mood": {"type": "score", "instructions": "How upset is the customer?", "criteria": ["calm", "annoyed", "angry"]}},
|
|
72
|
+
)
|
|
73
|
+
print(r["answers"])
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`quyet.load(name_or_path, device=None, revision=None, dtype=None, device_map=None)` accepts a Hugging Face repo id or a
|
|
77
|
+
local directory. `predict_many` answers a list of requests; `raw_probabilities` returns the uncalibrated distributions.
|
|
78
|
+
|
|
79
|
+
### Question types and answers
|
|
80
|
+
|
|
81
|
+
Answers follow the TypeSafe `/v1/systemone` shape:
|
|
82
|
+
|
|
83
|
+
- `choice`: pick one label from `criteria` (a dict of label to description, or a list of labels). Answer: `choice`,
|
|
84
|
+
`confidence`, `probabilities`.
|
|
85
|
+
- `score`: an ordered scale given as a list of levels. Answer: expected level `score`, `probabilities`, `legend`.
|
|
86
|
+
- `noul`: a statement that is true or false. Answer: `noul` = P(true).
|
|
87
|
+
|
|
88
|
+
Probabilities are temperature-calibrated per question type and option count.
|
|
89
|
+
|
|
90
|
+
### Command line
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
quyet predict chinhnc/Quyet-1.0-Small < requests.jsonl > answers.jsonl
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Each input line is `{"state": ..., "questions": {...}}`; each output line is the response or `{"error": ...}`.
|
|
97
|
+
Options: `--input FILE`, `--device cpu|cuda|cuda:1`, `--strict` (fail instead of truncating a long state).
|
|
98
|
+
|
|
99
|
+
## Limits
|
|
100
|
+
|
|
101
|
+
- At most 10 options per question; more are rejected, not truncated.
|
|
102
|
+
- Only the state is ever truncated: conversation lists keep their most recent turns, other states keep their
|
|
103
|
+
beginning. Encoders read 8,192 tokens; the LLMs keep up to 6,000 state tokens.
|
|
104
|
+
- Not evaluated for safety, bias or adversarial robustness; do not use as the only control for high-stakes decisions.
|
|
105
|
+
|
|
106
|
+
## Licence and credit
|
|
107
|
+
|
|
108
|
+
Apache-2.0 for the code and the weights. Keep the [NOTICE](NOTICE) file, which starts with "Quyet by Chinh Nguyen",
|
|
109
|
+
when you redistribute this package, a model, or anything derived from them.
|
|
110
|
+
|
|
111
|
+
```bibtex
|
|
112
|
+
@misc{quyet2026,
|
|
113
|
+
title = {Quyet 1.0: calibrated decision models},
|
|
114
|
+
author = {Chinh Nguyen},
|
|
115
|
+
year = {2026},
|
|
116
|
+
url = {https://github.com/ncchinh/quyet}
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Questions and issues: [GitHub issues](https://github.com/ncchinh/quyet/issues) or email@chinh.com.
|
quyet-1.0.0/README.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Quyet
|
|
2
|
+
|
|
3
|
+
Quyet is a family of **decision models**. Give it a state (any text, JSON or conversation) and
|
|
4
|
+
one or more typed questions; it picks one option per question and returns calibrated probabilities. Nothing is
|
|
5
|
+
generated: every answer is a probability distribution over the options you supplied.
|
|
6
|
+
|
|
7
|
+
This package is the runtime for all Quyet 1.0 models. The weights are on Hugging Face.
|
|
8
|
+
|
|
9
|
+
The models are built for English and also tuned for Vietnamese; other languages work, with lower accuracy. Small-EN is
|
|
10
|
+
trained on English only.
|
|
11
|
+
|
|
12
|
+
| model | kind | parameters |
|
|
13
|
+
|---|---|---|
|
|
14
|
+
| [Quyet-1.0-Large](https://huggingface.co/chinhnc/Quyet-1.0-Large) | LLM (GPU) | 31.3B (30.7B text) |
|
|
15
|
+
| [Quyet-1.0-Medium](https://huggingface.co/chinhnc/Quyet-1.0-Medium) | LLM (GPU) | 4.66B (4.21B text) |
|
|
16
|
+
| [Quyet-1.0-Small](https://huggingface.co/chinhnc/Quyet-1.0-Small) | encoder (CPU or GPU) | 328M |
|
|
17
|
+
| [Quyet-1.0-Small-EN](https://huggingface.co/chinhnc/Quyet-1.0-Small-EN) | encoder (CPU or GPU) | 153M |
|
|
18
|
+
| [Quyet-1.0-Tiny](https://huggingface.co/chinhnc/Quyet-1.0-Tiny) | encoder (CPU or GPU) | 183M |
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install quyet # CPU or single GPU
|
|
24
|
+
pip install "quyet[multi-gpu]" # spread Quyet-1.0-Large over several GPUs (device_map="auto")
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Python 3.10 or newer. The first `quyet.load` downloads the weights from Hugging Face.
|
|
28
|
+
|
|
29
|
+
## Use
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
import quyet
|
|
33
|
+
|
|
34
|
+
m = quyet.load("chinhnc/Quyet-1.0-Small")
|
|
35
|
+
r = m.predict(
|
|
36
|
+
{"message": "Please close my card, I lost it yesterday."},
|
|
37
|
+
{"intent": {"type": "choice", "instructions": "What does the customer want?",
|
|
38
|
+
"criteria": {"cancel": "close the card", "limit": "change the limit", "other": None}},
|
|
39
|
+
"urgent": {"type": "noul", "instructions": "The request is urgent."},
|
|
40
|
+
"mood": {"type": "score", "instructions": "How upset is the customer?", "criteria": ["calm", "annoyed", "angry"]}},
|
|
41
|
+
)
|
|
42
|
+
print(r["answers"])
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`quyet.load(name_or_path, device=None, revision=None, dtype=None, device_map=None)` accepts a Hugging Face repo id or a
|
|
46
|
+
local directory. `predict_many` answers a list of requests; `raw_probabilities` returns the uncalibrated distributions.
|
|
47
|
+
|
|
48
|
+
### Question types and answers
|
|
49
|
+
|
|
50
|
+
Answers follow the TypeSafe `/v1/systemone` shape:
|
|
51
|
+
|
|
52
|
+
- `choice`: pick one label from `criteria` (a dict of label to description, or a list of labels). Answer: `choice`,
|
|
53
|
+
`confidence`, `probabilities`.
|
|
54
|
+
- `score`: an ordered scale given as a list of levels. Answer: expected level `score`, `probabilities`, `legend`.
|
|
55
|
+
- `noul`: a statement that is true or false. Answer: `noul` = P(true).
|
|
56
|
+
|
|
57
|
+
Probabilities are temperature-calibrated per question type and option count.
|
|
58
|
+
|
|
59
|
+
### Command line
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
quyet predict chinhnc/Quyet-1.0-Small < requests.jsonl > answers.jsonl
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Each input line is `{"state": ..., "questions": {...}}`; each output line is the response or `{"error": ...}`.
|
|
66
|
+
Options: `--input FILE`, `--device cpu|cuda|cuda:1`, `--strict` (fail instead of truncating a long state).
|
|
67
|
+
|
|
68
|
+
## Limits
|
|
69
|
+
|
|
70
|
+
- At most 10 options per question; more are rejected, not truncated.
|
|
71
|
+
- Only the state is ever truncated: conversation lists keep their most recent turns, other states keep their
|
|
72
|
+
beginning. Encoders read 8,192 tokens; the LLMs keep up to 6,000 state tokens.
|
|
73
|
+
- Not evaluated for safety, bias or adversarial robustness; do not use as the only control for high-stakes decisions.
|
|
74
|
+
|
|
75
|
+
## Licence and credit
|
|
76
|
+
|
|
77
|
+
Apache-2.0 for the code and the weights. Keep the [NOTICE](NOTICE) file, which starts with "Quyet by Chinh Nguyen",
|
|
78
|
+
when you redistribute this package, a model, or anything derived from them.
|
|
79
|
+
|
|
80
|
+
```bibtex
|
|
81
|
+
@misc{quyet2026,
|
|
82
|
+
title = {Quyet 1.0: calibrated decision models},
|
|
83
|
+
author = {Chinh Nguyen},
|
|
84
|
+
year = {2026},
|
|
85
|
+
url = {https://github.com/ncchinh/quyet}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Questions and issues: [GitHub issues](https://github.com/ncchinh/quyet/issues) or email@chinh.com.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.25"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "quyet"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "Quyet decision models: pick one option for a state and a question, with calibrated probabilities."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "Apache-2.0"
|
|
11
|
+
license-files = ["LICENSE", "NOTICE"]
|
|
12
|
+
authors = [{name = "Chinh Nguyen"}]
|
|
13
|
+
keywords = ["decision model", "classification", "calibration", "llm", "encoder"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 5 - Production/Stable",
|
|
16
|
+
"License :: OSI Approved :: Apache Software License",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.10",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
22
|
+
]
|
|
23
|
+
requires-python = ">=3.10"
|
|
24
|
+
dependencies = [
|
|
25
|
+
"torch>=2.4",
|
|
26
|
+
"transformers>=5.17",
|
|
27
|
+
"safetensors>=0.4",
|
|
28
|
+
"huggingface_hub>=0.34",
|
|
29
|
+
"numpy>=1.26",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
Homepage = "https://huggingface.co/chinhnc"
|
|
34
|
+
Source = "https://github.com/ncchinh/quyet"
|
|
35
|
+
Issues = "https://github.com/ncchinh/quyet/issues"
|
|
36
|
+
|
|
37
|
+
[project.optional-dependencies]
|
|
38
|
+
test = ["pytest>=8"]
|
|
39
|
+
multi-gpu = ["accelerate>=1.0"]
|
|
40
|
+
|
|
41
|
+
[project.scripts]
|
|
42
|
+
quyet = "quyet.cli:main"
|
|
43
|
+
|
|
44
|
+
[tool.hatch.build.targets.wheel]
|
|
45
|
+
packages = ["src/quyet"]
|
|
46
|
+
|
|
47
|
+
[tool.hatch.build.targets.sdist]
|
|
48
|
+
include = ["src/quyet", "tests", "README.md", "LICENSE", "NOTICE", "pyproject.toml"]
|
|
49
|
+
|
|
50
|
+
[tool.pytest.ini_options]
|
|
51
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""Probabilities -> Jev-format answers (the shape of TypeSafe's /v1/systemone)."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def _r(x):
|
|
6
|
+
return round(float(x), 4)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def format_answer(d, probs, truncated=False):
|
|
10
|
+
"""probs: floats aligned with d.labels, summing to 1."""
|
|
11
|
+
if d.type == "choice":
|
|
12
|
+
i = max(range(len(probs)), key=probs.__getitem__)
|
|
13
|
+
a = {"type": "choice", "choice": d.labels[i], "confidence": _r(probs[i]),
|
|
14
|
+
"probabilities": {k: _r(p) for k, p in zip(d.labels, probs)}}
|
|
15
|
+
elif d.type == "score":
|
|
16
|
+
a = {"type": "score", "score": _r(sum(i * p for i, p in enumerate(probs))), "confidence": _r(max(probs)),
|
|
17
|
+
"legend": {k: (t if t is not None else k) for k, t in zip(d.labels, d.texts)},
|
|
18
|
+
"probabilities": {k: _r(p) for k, p in zip(d.labels, probs)}}
|
|
19
|
+
else:
|
|
20
|
+
a = {"type": "noul", "noul": _r(probs[0]), "confidence": _r(max(probs[0], 1 - probs[0]))}
|
|
21
|
+
if truncated:
|
|
22
|
+
a["truncated"] = True
|
|
23
|
+
return a
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def build_response(model_name, decisions, probs, truncated, input_tokens, warnings):
|
|
27
|
+
"""decisions / probs / truncated: dicts keyed by question id, in request order."""
|
|
28
|
+
return {"model": model_name,
|
|
29
|
+
"answers": {qid: format_answer(d, probs[qid], truncated[qid]) for qid, d in decisions.items()},
|
|
30
|
+
"usage": {"input_tokens": int(input_tokens), "output_tokens": 0},
|
|
31
|
+
"warnings": list(warnings)}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""Shared model interface: predict / predict_many / raw_probabilities over Jev-format requests."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
from dataclasses import dataclass, field
|
|
5
|
+
|
|
6
|
+
from .answers import build_response
|
|
7
|
+
from .errors import QuestionError
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@dataclass
|
|
11
|
+
class Result:
|
|
12
|
+
decisions: dict # qid -> Decision
|
|
13
|
+
probs: dict # qid -> list[float] aligned with Decision.labels
|
|
14
|
+
truncated: dict # qid -> bool
|
|
15
|
+
input_tokens: int
|
|
16
|
+
warnings: list = field(default_factory=list)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def check_state(state):
|
|
20
|
+
if not isinstance(state, (str, dict, list)):
|
|
21
|
+
raise QuestionError(f"state must be a string, object or list, got {type(state).__name__}")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def truncation_warning(state, total, kept):
|
|
25
|
+
return {"code": "state_truncated", "state_tokens": int(total), "kept_tokens": int(kept),
|
|
26
|
+
"kept": "tail" if isinstance(state, list) else "head"}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class QuyetModel:
|
|
30
|
+
name = "quyet"
|
|
31
|
+
kind = ""
|
|
32
|
+
|
|
33
|
+
def _run(self, requests, strict):
|
|
34
|
+
raise NotImplementedError
|
|
35
|
+
|
|
36
|
+
def predict(self, state, questions, *, strict=False):
|
|
37
|
+
"""One request -> {"model", "answers", "usage", "warnings"}. strict=True raises instead of truncating."""
|
|
38
|
+
return self.predict_many([{"state": state, "questions": questions}], strict=strict)[0]
|
|
39
|
+
|
|
40
|
+
def predict_many(self, requests, *, strict=False):
|
|
41
|
+
"""Several requests batched together; any invalid request raises QuestionError for the whole call."""
|
|
42
|
+
return [build_response(self.name, r.decisions, r.probs, r.truncated, r.input_tokens, r.warnings)
|
|
43
|
+
for r in self._run(list(requests), strict)]
|
|
44
|
+
|
|
45
|
+
def raw_probabilities(self, requests, *, strict=False):
|
|
46
|
+
"""Unrounded probabilities per question id, aligned with the answer labels."""
|
|
47
|
+
return [r.probs for r in self._run(list(requests), strict)]
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""Per-bucket temperature scaling. Encoder temperatures are keyed "<type>:<size>" (e.g. "choice:3-5"); LLM
|
|
2
|
+
temperatures are keyed by type. A missing key means 1.0 (uncalibrated)."""
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import numpy as np
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def size_bucket(k):
|
|
9
|
+
return "2" if k <= 2 else "3-5" if k <= 5 else "6-10" if k <= 10 else "11+"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def temperature(temps, qtype, k):
|
|
13
|
+
return float(temps.get(f"{qtype}:{size_bucket(k)}", temps.get(qtype, 1.0)))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def softmax_t(logits, t):
|
|
17
|
+
z = np.asarray(logits, np.float64) / t
|
|
18
|
+
p = np.exp(z - z.max())
|
|
19
|
+
return (p / p.sum()).tolist()
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""quyet predict MODEL: JSON lines {"state", "questions"} in, one JSON response (or {"error"}) per line out."""
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
|
|
4
|
+
import argparse
|
|
5
|
+
import json
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
from .errors import QuestionError
|
|
9
|
+
from .hub import load
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def main(argv=None):
|
|
13
|
+
ap = argparse.ArgumentParser(prog="quyet", description="Run a Quyet decision model.")
|
|
14
|
+
sub = ap.add_subparsers(dest="cmd", required=True)
|
|
15
|
+
p = sub.add_parser("predict", help="answer JSON-lines requests {state, questions}")
|
|
16
|
+
p.add_argument("model", help="Hugging Face repo id (e.g. chinhnc/Quyet-1.0-Small) or local directory")
|
|
17
|
+
p.add_argument("--input", help="JSON-lines file (default: stdin)")
|
|
18
|
+
p.add_argument("--device", help="cpu, cuda, cuda:1, ... (default: cuda if available)")
|
|
19
|
+
p.add_argument("--strict", action="store_true", help="fail instead of truncating a long state")
|
|
20
|
+
a = ap.parse_args(argv)
|
|
21
|
+
model = load(a.model, device=a.device)
|
|
22
|
+
failed = False
|
|
23
|
+
src = open(a.input, encoding="utf8") if a.input else sys.stdin
|
|
24
|
+
with src:
|
|
25
|
+
for line in src:
|
|
26
|
+
if not line.strip():
|
|
27
|
+
continue
|
|
28
|
+
try:
|
|
29
|
+
req = json.loads(line)
|
|
30
|
+
out = model.predict(req["state"], req["questions"], strict=a.strict)
|
|
31
|
+
except (QuestionError, KeyError, TypeError, json.JSONDecodeError) as e:
|
|
32
|
+
failed = True
|
|
33
|
+
out = {"error": f"{type(e).__name__}: {e}"}
|
|
34
|
+
print(json.dumps(out, ensure_ascii=False), flush=True)
|
|
35
|
+
return 1 if failed else 0
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
if __name__ == "__main__":
|
|
39
|
+
sys.exit(main())
|
|
File without changes
|