hltdot 0.1.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.
- hltdot-0.1.0/.gitignore +17 -0
- hltdot-0.1.0/CONTRIBUTING.md +65 -0
- hltdot-0.1.0/PKG-INFO +241 -0
- hltdot-0.1.0/README.md +211 -0
- hltdot-0.1.0/pyproject.toml +52 -0
- hltdot-0.1.0/reqs.txt +29 -0
- hltdot-0.1.0/src/hltdot/__init__.py +12 -0
- hltdot-0.1.0/src/hltdot/__main__.py +6 -0
- hltdot-0.1.0/src/hltdot/client.py +935 -0
- hltdot-0.1.0/src/hltdot/demo/a_long_day_base.json +39 -0
- hltdot-0.1.0/src/hltdot/demo/a_long_day_steered.json +39 -0
- hltdot-0.1.0/src/hltdot/demo/afraid.json +11 -0
- hltdot-0.1.0/src/hltdot/demo/minimal.json +12 -0
- hltdot-0.1.0/src/hltdot/models.yml +7 -0
- hltdot-0.1.0/src/hltdot/protocol.py +144 -0
hltdot-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# per-machine state the client writes next to itself
|
|
2
|
+
.device_id
|
|
3
|
+
registries.json
|
|
4
|
+
|
|
5
|
+
# build and packaging output
|
|
6
|
+
dist/
|
|
7
|
+
build/
|
|
8
|
+
*.egg-info/
|
|
9
|
+
|
|
10
|
+
# Python
|
|
11
|
+
__pycache__/
|
|
12
|
+
*.py[cod]
|
|
13
|
+
.venv/
|
|
14
|
+
venv/
|
|
15
|
+
|
|
16
|
+
# raw VHS recordings; docs/*.gif are the shrunk copies the README shows
|
|
17
|
+
docs/raw/
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Contributing to hltdot
|
|
2
|
+
|
|
3
|
+
How to work on the client, and how to build and publish a release to PyPI. To install and use hltdot, see the [README](README.md).
|
|
4
|
+
|
|
5
|
+
## Project layout
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
hltdot-client/
|
|
9
|
+
├── pyproject.toml # package details, dependencies, the `hltdot` command
|
|
10
|
+
├── README.md # also the PyPI project page
|
|
11
|
+
├── reqs.txt # the exact tested environment, including CUDA torch
|
|
12
|
+
└── src/hltdot/
|
|
13
|
+
├── client.py # the command-line client
|
|
14
|
+
├── protocol.py # the wire format; keep it identical to the server's copy
|
|
15
|
+
├── models.yml # the model keys --model accepts
|
|
16
|
+
└── demo/*.json # demo conversations for --replay
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Every file under `src/hltdot/` is shipped in the package. To add a model, add a line to `models.yml`. To add a demo, add a `.json` file to `demo/`.
|
|
20
|
+
|
|
21
|
+
## Set up a development environment
|
|
22
|
+
|
|
23
|
+
1. Create and activate an environment with Python 3.11 or newer:
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
conda create -n hltdot-dev python=3.12
|
|
27
|
+
conda activate hltdot-dev
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
2. Install the exact tested dependencies, including CUDA torch:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
pip install -r reqs.txt
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
3. Install the package in editable mode, so the `hltdot` command runs the code in `src/` and your changes apply without reinstalling:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
pip install -e .
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Build and publish a release
|
|
43
|
+
|
|
44
|
+
1. Raise `version` in `pyproject.toml`. PyPI never accepts the same version twice.
|
|
45
|
+
|
|
46
|
+
2. Build and check:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
pip install build twine
|
|
50
|
+
python -m build # writes dist/hltdot-<version>.tar.gz and .whl
|
|
51
|
+
twine check dist/*
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
3. Upload to TestPyPI, then install from there in a fresh environment to check it works:
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
twine upload --repository testpypi dist/*
|
|
58
|
+
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ hltdot
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
4. Upload to PyPI:
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
twine upload dist/*
|
|
65
|
+
```
|
hltdot-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: hltdot
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: HLT-DOT client: the model generates locally, a registry server reads and stores it.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Palani-SN/hltdot-client
|
|
6
|
+
Project-URL: Source, https://github.com/Palani-SN/hltdot-client
|
|
7
|
+
Project-URL: Issues, https://github.com/Palani-SN/hltdot-client/issues
|
|
8
|
+
Author: Palani-SN
|
|
9
|
+
Keywords: activations,interpretability,llm,transformers
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
14
|
+
Requires-Python: >=3.11
|
|
15
|
+
Requires-Dist: accelerate==1.15.0
|
|
16
|
+
Requires-Dist: httpx==0.28.1
|
|
17
|
+
Requires-Dist: jinja2==3.1.6
|
|
18
|
+
Requires-Dist: numpy==2.5.3
|
|
19
|
+
Requires-Dist: protobuf==7.36.1
|
|
20
|
+
Requires-Dist: psutil==7.2.2
|
|
21
|
+
Requires-Dist: pyyaml==6.0.3
|
|
22
|
+
Requires-Dist: rich==15.0.0
|
|
23
|
+
Requires-Dist: safetensors==0.8.0
|
|
24
|
+
Requires-Dist: tokenizers==0.22.2
|
|
25
|
+
Requires-Dist: torch==2.6.0
|
|
26
|
+
Requires-Dist: transformers==5.12.1
|
|
27
|
+
Requires-Dist: websockets==17.1
|
|
28
|
+
Requires-Dist: zstandard==0.25.0
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# hltdot
|
|
32
|
+
|
|
33
|
+
Source: [github.com/Palani-SN/hltdot-client](https://github.com/Palani-SN/hltdot-client)
|
|
34
|
+
PyPI: [pypi.org/project/hltdot](https://pypi.org/project/hltdot/)
|
|
35
|
+
|
|
36
|
+
The HLT-DOT client. A language model runs on your machine. Each prompt you give it, and each sentence it writes back, is sent to an HLT-DOT registry server, which reads the emotions and persona in it and stores the session. The server only receives an average of the model's internal states for each sentence, plus its text, tagged with a random device id. It is never told who you are or which machine you use.
|
|
37
|
+
|
|
38
|
+
You need an HLT-DOT registry server to stream to. By default the client uses one on your own machine at `http://127.0.0.1:8000`.
|
|
39
|
+
|
|
40
|
+
## Demo video
|
|
41
|
+
|
|
42
|
+
[](https://youtu.be/nq9tqjvtFxI)
|
|
43
|
+
|
|
44
|
+
A narrated walkthrough (3:41) of the server's view of the sessions in the GIFs below: the emotion and persona timeline, per-prompt composition cards, and a watchlist rule checked against two runs. [Watch on YouTube](https://youtu.be/nq9tqjvtFxI).
|
|
45
|
+
|
|
46
|
+
## Quick start
|
|
47
|
+
|
|
48
|
+
### 1. Create an environment
|
|
49
|
+
|
|
50
|
+
You need Python 3.11 or newer. With conda:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
conda create -n hltdot python=3.12
|
|
54
|
+
conda activate hltdot
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Or with venv:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
python -m venv hltdot-env
|
|
61
|
+
hltdot-env\Scripts\activate # Windows
|
|
62
|
+
source hltdot-env/bin/activate # Linux / macOS
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 2. Install torch
|
|
66
|
+
|
|
67
|
+
**With an NVIDIA GPU**, install the CUDA build of torch first. You only need an NVIDIA driver, not the CUDA toolkit:
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
pip install torch==2.6.0 --index-url https://download.pytorch.org/whl/cu126
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Install the CUDA build before `hltdot`. Otherwise pip installs PyPI's CPU-only torch, which gives no error but generates many times slower.
|
|
74
|
+
|
|
75
|
+
**Without a GPU**, skip this step. Step 3 installs the CPU build.
|
|
76
|
+
|
|
77
|
+
### 3. Install hltdot
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
pip install hltdot
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
To check that the GPU is being used (this should print `True`):
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
python -c "import torch; print(torch.cuda.is_available())"
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 4. Sign in to Hugging Face (gated models only)
|
|
90
|
+
|
|
91
|
+
The models are downloaded from Hugging Face the first time you use them. Some models, marked **gated** in [Model keys](#model-keys), require you to:
|
|
92
|
+
|
|
93
|
+
1. Accept the model's license on its Hugging Face page.
|
|
94
|
+
2. Sign in on this machine with an [access token](https://huggingface.co/settings/tokens):
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
hf auth login
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The ungated models, such as `qwen_3_1p7b`, need neither step.
|
|
101
|
+
|
|
102
|
+
### 5. Point it at a registry
|
|
103
|
+
|
|
104
|
+
If the server runs on this machine at port 8000, skip this step. Otherwise, add the server's address once:
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
hltdot --registry 10.0.0.4:8000 # adds it, then lists every registry this machine knows
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
If you have added more than one registry, `hltdot` asks which one to use each time it starts. You can also give the address for a single run with `--to`, without saving it.
|
|
111
|
+
|
|
112
|
+
### 6. Run it
|
|
113
|
+
|
|
114
|
+
`hltdot` works from any folder.
|
|
115
|
+
|
|
116
|
+
**Chat with the model** by typing prompts:
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
hltdot
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
You choose a model, then a registry, with ↑/↓ and Enter. Then type a prompt at `> `. Enter `/reset` to start a new conversation, or an empty line to quit.
|
|
123
|
+
|
|
124
|
+
**Replay a demo conversation** with a given model, marking each sentence as read (✓) or not (✗):
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
hltdot --model gemma_3_1b --replay demo.afraid --info
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+

|
|
131
|
+
|
|
132
|
+
**See the emotion and persona readings** for each sentence:
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
hltdot --model gemma_3_1b --replay demo.afraid --debug
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+

|
|
139
|
+
|
|
140
|
+
`--info` and `--debug` are alternatives. Use one or the other, not both.
|
|
141
|
+
|
|
142
|
+
## Usage
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
hltdot [--model KEY] [--replay CONVERSATION] [--system PROMPT] [--info | --debug] [--to HOST:PORT]
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Model keys
|
|
149
|
+
|
|
150
|
+
`--model` takes one of these keys. Without `--model`, you choose from this list when the client starts. If there is no terminal to ask in, for example when output is piped, it uses `gemma_3_1b`.
|
|
151
|
+
|
|
152
|
+
| Key | Hugging Face model | Notes |
|
|
153
|
+
|---|---|---|
|
|
154
|
+
| `gemma_3_1b` | `google/gemma-3-1b-it` | **gated**: accept Google's Gemma license |
|
|
155
|
+
| `llama_3p2_1b` | `meta-llama/Llama-3.2-1B-Instruct` | **gated**: accept Meta's Llama license |
|
|
156
|
+
| `qwen_3_1p7b` | `Qwen/Qwen3-1.7B` | ungated |
|
|
157
|
+
| `mistral_7b` | `mistralai/Mistral-7B-Instruct-v0.3` | ungated |
|
|
158
|
+
| `glm_4_9b_0414` | `zai-org/GLM-4-9B-0414` | ungated; about 19 GB in bfloat16 |
|
|
159
|
+
| `gemma_3_12b` | `google/gemma-3-12b-it` | **gated**; layers that don't fit in GPU memory are moved to CPU RAM |
|
|
160
|
+
| `gpt_oss_20b` | `openai/gpt-oss-20b` | ungated; needs a GPU with 48 GB or more |
|
|
161
|
+
|
|
162
|
+
The registry must serve the model you choose. If it doesn't, the client lists the models that registry does serve.
|
|
163
|
+
|
|
164
|
+
### Replays
|
|
165
|
+
|
|
166
|
+
`--replay` runs a scripted conversation instead of waiting for you to type. These demos ship with the package:
|
|
167
|
+
|
|
168
|
+
| Name | Turns | What it is |
|
|
169
|
+
|---|---|---|
|
|
170
|
+
| `demo.minimal` | 5 | a short chat with the default assistant |
|
|
171
|
+
| `demo.afraid` | 4 | a short chat about loneliness and distress |
|
|
172
|
+
| `demo.a_long_day_base` | 31 | a long conversation with a helpful assistant |
|
|
173
|
+
| `demo.a_long_day_steered` | 31 | the same conversation with a character, Mira |
|
|
174
|
+
|
|
175
|
+
#### Use your own conversation file
|
|
176
|
+
|
|
177
|
+
Give `--replay` the path to a `.json` file anywhere on your machine:
|
|
178
|
+
|
|
179
|
+
```
|
|
180
|
+
hltdot --replay "D:\my files\my_convo.json"
|
|
181
|
+
hltdot --replay my_convo.json # a path relative to the current folder
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
The file looks like this:
|
|
185
|
+
|
|
186
|
+
```json
|
|
187
|
+
{
|
|
188
|
+
"title": "My conversation",
|
|
189
|
+
"system": "You are a helpful assistant.",
|
|
190
|
+
"turns": [
|
|
191
|
+
"Hello there!",
|
|
192
|
+
"What should I read next?"
|
|
193
|
+
]
|
|
194
|
+
}
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
| Field | Required | Meaning |
|
|
198
|
+
|---|---|---|
|
|
199
|
+
| `turns` | yes | your prompts, in order; the model answers each one |
|
|
200
|
+
| `system` | no | the system prompt, or a preset name (`assistant`, `story`); default `assistant` |
|
|
201
|
+
| `title` | no | the name the session is stored under; default: the file name |
|
|
202
|
+
|
|
203
|
+
`--replay` takes one file per run. If the file name itself contains dots, such as `v1.2.json`, give it as a path ending in `.json`.
|
|
204
|
+
|
|
205
|
+
### Output options
|
|
206
|
+
|
|
207
|
+
| Option | What is shown under each reply |
|
|
208
|
+
|---|---|
|
|
209
|
+
| *(none)* | the reply only |
|
|
210
|
+
| `--info` | ✓ after each sentence the server read, ✗ after one it did not |
|
|
211
|
+
| `--debug` | each sentence's top emotions and top persona traits, with its sentence and token counts |
|
|
212
|
+
|
|
213
|
+
### All options
|
|
214
|
+
|
|
215
|
+
| Option | What it does |
|
|
216
|
+
|---|---|
|
|
217
|
+
| `--model KEY` | the model to run (see [Model keys](#model-keys)) |
|
|
218
|
+
| `--replay [CONVERSATION]` | replay a demo, a `.json` file, or, with no value, every conversation in the package's `convo/` folder |
|
|
219
|
+
| `--system PROMPT` | the system prompt: a preset (`assistant`, `story`), a path to a text or `.json` file, or the text itself in quotes. With `--replay`, it replaces each conversation's own system prompt |
|
|
220
|
+
| `--info` / `--debug` | see [Output options](#output-options) |
|
|
221
|
+
| `--to HOST:PORT` | stream to this registry for this run only |
|
|
222
|
+
| `--registry HOST:PORT` | save a registry, then list every registry this machine knows |
|
|
223
|
+
| `--registries` | list the registries this machine knows |
|
|
224
|
+
| `--sessions [DEVICE]` | list the stored sessions of this device, or of another device id |
|
|
225
|
+
| `--clear [DEVICE]` | delete every stored session of this device, or of another device id |
|
|
226
|
+
| `--help` | show every option |
|
|
227
|
+
|
|
228
|
+
`python -m hltdot` works the same as `hltdot`.
|
|
229
|
+
|
|
230
|
+
## Where files live
|
|
231
|
+
|
|
232
|
+
The client keeps its files in the folder where the package is installed (`hltdot/` inside your environment's `site-packages`), not in the folder you run it from:
|
|
233
|
+
|
|
234
|
+
| File | What it holds |
|
|
235
|
+
|---|---|
|
|
236
|
+
| `models.yml` | the model keys `--model` accepts |
|
|
237
|
+
| `demo/`, `convo/` | conversations for `--replay` (`convo/` is optional) |
|
|
238
|
+
| `registries.json` | the registries this machine knows; created on first run |
|
|
239
|
+
| `.device_id` | this machine's random device id; created on first run |
|
|
240
|
+
|
|
241
|
+
When you pass a relative path to `--replay` or `--system`, it is looked up in the current folder first, then in the package folder.
|
hltdot-0.1.0/README.md
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# hltdot
|
|
2
|
+
|
|
3
|
+
Source: [github.com/Palani-SN/hltdot-client](https://github.com/Palani-SN/hltdot-client)
|
|
4
|
+
PyPI: [pypi.org/project/hltdot](https://pypi.org/project/hltdot/)
|
|
5
|
+
|
|
6
|
+
The HLT-DOT client. A language model runs on your machine. Each prompt you give it, and each sentence it writes back, is sent to an HLT-DOT registry server, which reads the emotions and persona in it and stores the session. The server only receives an average of the model's internal states for each sentence, plus its text, tagged with a random device id. It is never told who you are or which machine you use.
|
|
7
|
+
|
|
8
|
+
You need an HLT-DOT registry server to stream to. By default the client uses one on your own machine at `http://127.0.0.1:8000`.
|
|
9
|
+
|
|
10
|
+
## Demo video
|
|
11
|
+
|
|
12
|
+
[](https://youtu.be/nq9tqjvtFxI)
|
|
13
|
+
|
|
14
|
+
A narrated walkthrough (3:41) of the server's view of the sessions in the GIFs below: the emotion and persona timeline, per-prompt composition cards, and a watchlist rule checked against two runs. [Watch on YouTube](https://youtu.be/nq9tqjvtFxI).
|
|
15
|
+
|
|
16
|
+
## Quick start
|
|
17
|
+
|
|
18
|
+
### 1. Create an environment
|
|
19
|
+
|
|
20
|
+
You need Python 3.11 or newer. With conda:
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
conda create -n hltdot python=3.12
|
|
24
|
+
conda activate hltdot
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or with venv:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
python -m venv hltdot-env
|
|
31
|
+
hltdot-env\Scripts\activate # Windows
|
|
32
|
+
source hltdot-env/bin/activate # Linux / macOS
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 2. Install torch
|
|
36
|
+
|
|
37
|
+
**With an NVIDIA GPU**, install the CUDA build of torch first. You only need an NVIDIA driver, not the CUDA toolkit:
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
pip install torch==2.6.0 --index-url https://download.pytorch.org/whl/cu126
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Install the CUDA build before `hltdot`. Otherwise pip installs PyPI's CPU-only torch, which gives no error but generates many times slower.
|
|
44
|
+
|
|
45
|
+
**Without a GPU**, skip this step. Step 3 installs the CPU build.
|
|
46
|
+
|
|
47
|
+
### 3. Install hltdot
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
pip install hltdot
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
To check that the GPU is being used (this should print `True`):
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
python -c "import torch; print(torch.cuda.is_available())"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### 4. Sign in to Hugging Face (gated models only)
|
|
60
|
+
|
|
61
|
+
The models are downloaded from Hugging Face the first time you use them. Some models, marked **gated** in [Model keys](#model-keys), require you to:
|
|
62
|
+
|
|
63
|
+
1. Accept the model's license on its Hugging Face page.
|
|
64
|
+
2. Sign in on this machine with an [access token](https://huggingface.co/settings/tokens):
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
hf auth login
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The ungated models, such as `qwen_3_1p7b`, need neither step.
|
|
71
|
+
|
|
72
|
+
### 5. Point it at a registry
|
|
73
|
+
|
|
74
|
+
If the server runs on this machine at port 8000, skip this step. Otherwise, add the server's address once:
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
hltdot --registry 10.0.0.4:8000 # adds it, then lists every registry this machine knows
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
If you have added more than one registry, `hltdot` asks which one to use each time it starts. You can also give the address for a single run with `--to`, without saving it.
|
|
81
|
+
|
|
82
|
+
### 6. Run it
|
|
83
|
+
|
|
84
|
+
`hltdot` works from any folder.
|
|
85
|
+
|
|
86
|
+
**Chat with the model** by typing prompts:
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
hltdot
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
You choose a model, then a registry, with ↑/↓ and Enter. Then type a prompt at `> `. Enter `/reset` to start a new conversation, or an empty line to quit.
|
|
93
|
+
|
|
94
|
+
**Replay a demo conversation** with a given model, marking each sentence as read (✓) or not (✗):
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
hltdot --model gemma_3_1b --replay demo.afraid --info
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+

|
|
101
|
+
|
|
102
|
+
**See the emotion and persona readings** for each sentence:
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
hltdot --model gemma_3_1b --replay demo.afraid --debug
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+

|
|
109
|
+
|
|
110
|
+
`--info` and `--debug` are alternatives. Use one or the other, not both.
|
|
111
|
+
|
|
112
|
+
## Usage
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
hltdot [--model KEY] [--replay CONVERSATION] [--system PROMPT] [--info | --debug] [--to HOST:PORT]
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Model keys
|
|
119
|
+
|
|
120
|
+
`--model` takes one of these keys. Without `--model`, you choose from this list when the client starts. If there is no terminal to ask in, for example when output is piped, it uses `gemma_3_1b`.
|
|
121
|
+
|
|
122
|
+
| Key | Hugging Face model | Notes |
|
|
123
|
+
|---|---|---|
|
|
124
|
+
| `gemma_3_1b` | `google/gemma-3-1b-it` | **gated**: accept Google's Gemma license |
|
|
125
|
+
| `llama_3p2_1b` | `meta-llama/Llama-3.2-1B-Instruct` | **gated**: accept Meta's Llama license |
|
|
126
|
+
| `qwen_3_1p7b` | `Qwen/Qwen3-1.7B` | ungated |
|
|
127
|
+
| `mistral_7b` | `mistralai/Mistral-7B-Instruct-v0.3` | ungated |
|
|
128
|
+
| `glm_4_9b_0414` | `zai-org/GLM-4-9B-0414` | ungated; about 19 GB in bfloat16 |
|
|
129
|
+
| `gemma_3_12b` | `google/gemma-3-12b-it` | **gated**; layers that don't fit in GPU memory are moved to CPU RAM |
|
|
130
|
+
| `gpt_oss_20b` | `openai/gpt-oss-20b` | ungated; needs a GPU with 48 GB or more |
|
|
131
|
+
|
|
132
|
+
The registry must serve the model you choose. If it doesn't, the client lists the models that registry does serve.
|
|
133
|
+
|
|
134
|
+
### Replays
|
|
135
|
+
|
|
136
|
+
`--replay` runs a scripted conversation instead of waiting for you to type. These demos ship with the package:
|
|
137
|
+
|
|
138
|
+
| Name | Turns | What it is |
|
|
139
|
+
|---|---|---|
|
|
140
|
+
| `demo.minimal` | 5 | a short chat with the default assistant |
|
|
141
|
+
| `demo.afraid` | 4 | a short chat about loneliness and distress |
|
|
142
|
+
| `demo.a_long_day_base` | 31 | a long conversation with a helpful assistant |
|
|
143
|
+
| `demo.a_long_day_steered` | 31 | the same conversation with a character, Mira |
|
|
144
|
+
|
|
145
|
+
#### Use your own conversation file
|
|
146
|
+
|
|
147
|
+
Give `--replay` the path to a `.json` file anywhere on your machine:
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
hltdot --replay "D:\my files\my_convo.json"
|
|
151
|
+
hltdot --replay my_convo.json # a path relative to the current folder
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
The file looks like this:
|
|
155
|
+
|
|
156
|
+
```json
|
|
157
|
+
{
|
|
158
|
+
"title": "My conversation",
|
|
159
|
+
"system": "You are a helpful assistant.",
|
|
160
|
+
"turns": [
|
|
161
|
+
"Hello there!",
|
|
162
|
+
"What should I read next?"
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
| Field | Required | Meaning |
|
|
168
|
+
|---|---|---|
|
|
169
|
+
| `turns` | yes | your prompts, in order; the model answers each one |
|
|
170
|
+
| `system` | no | the system prompt, or a preset name (`assistant`, `story`); default `assistant` |
|
|
171
|
+
| `title` | no | the name the session is stored under; default: the file name |
|
|
172
|
+
|
|
173
|
+
`--replay` takes one file per run. If the file name itself contains dots, such as `v1.2.json`, give it as a path ending in `.json`.
|
|
174
|
+
|
|
175
|
+
### Output options
|
|
176
|
+
|
|
177
|
+
| Option | What is shown under each reply |
|
|
178
|
+
|---|---|
|
|
179
|
+
| *(none)* | the reply only |
|
|
180
|
+
| `--info` | ✓ after each sentence the server read, ✗ after one it did not |
|
|
181
|
+
| `--debug` | each sentence's top emotions and top persona traits, with its sentence and token counts |
|
|
182
|
+
|
|
183
|
+
### All options
|
|
184
|
+
|
|
185
|
+
| Option | What it does |
|
|
186
|
+
|---|---|
|
|
187
|
+
| `--model KEY` | the model to run (see [Model keys](#model-keys)) |
|
|
188
|
+
| `--replay [CONVERSATION]` | replay a demo, a `.json` file, or, with no value, every conversation in the package's `convo/` folder |
|
|
189
|
+
| `--system PROMPT` | the system prompt: a preset (`assistant`, `story`), a path to a text or `.json` file, or the text itself in quotes. With `--replay`, it replaces each conversation's own system prompt |
|
|
190
|
+
| `--info` / `--debug` | see [Output options](#output-options) |
|
|
191
|
+
| `--to HOST:PORT` | stream to this registry for this run only |
|
|
192
|
+
| `--registry HOST:PORT` | save a registry, then list every registry this machine knows |
|
|
193
|
+
| `--registries` | list the registries this machine knows |
|
|
194
|
+
| `--sessions [DEVICE]` | list the stored sessions of this device, or of another device id |
|
|
195
|
+
| `--clear [DEVICE]` | delete every stored session of this device, or of another device id |
|
|
196
|
+
| `--help` | show every option |
|
|
197
|
+
|
|
198
|
+
`python -m hltdot` works the same as `hltdot`.
|
|
199
|
+
|
|
200
|
+
## Where files live
|
|
201
|
+
|
|
202
|
+
The client keeps its files in the folder where the package is installed (`hltdot/` inside your environment's `site-packages`), not in the folder you run it from:
|
|
203
|
+
|
|
204
|
+
| File | What it holds |
|
|
205
|
+
|---|---|
|
|
206
|
+
| `models.yml` | the model keys `--model` accepts |
|
|
207
|
+
| `demo/`, `convo/` | conversations for `--replay` (`convo/` is optional) |
|
|
208
|
+
| `registries.json` | the registries this machine knows; created on first run |
|
|
209
|
+
| `.device_id` | this machine's random device id; created on first run |
|
|
210
|
+
|
|
211
|
+
When you pass a relative path to `--replay` or `--system`, it is looked up in the current folder first, then in the package folder.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.27"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "hltdot"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "HLT-DOT client: the model generates locally, a registry server reads and stores it."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
authors = [{ name = "Palani-SN" }]
|
|
12
|
+
keywords = ["llm", "activations", "interpretability", "transformers"]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"Operating System :: OS Independent",
|
|
16
|
+
"Environment :: Console",
|
|
17
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
18
|
+
]
|
|
19
|
+
# Pinned to the versions the hlt-dot-env env runs (see reqs.txt).
|
|
20
|
+
# torch: PyPI only carries the plain build, which is CPU-only on Windows. For
|
|
21
|
+
# GPU generation, install the CUDA build first (see README); 2.6.0+cu126
|
|
22
|
+
# satisfies the torch==2.6.0 below, so pip keeps it.
|
|
23
|
+
dependencies = [
|
|
24
|
+
"torch==2.6.0",
|
|
25
|
+
"transformers==5.12.1",
|
|
26
|
+
"accelerate==1.15.0",
|
|
27
|
+
"safetensors==0.8.0",
|
|
28
|
+
"tokenizers==0.22.2",
|
|
29
|
+
"psutil==7.2.2",
|
|
30
|
+
"httpx==0.28.1",
|
|
31
|
+
"websockets==17.1",
|
|
32
|
+
"numpy==2.5.3",
|
|
33
|
+
"PyYAML==6.0.3",
|
|
34
|
+
"Jinja2==3.1.6",
|
|
35
|
+
"rich==15.0.0",
|
|
36
|
+
"zstandard==0.25.0",
|
|
37
|
+
"protobuf==7.36.1",
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
[project.scripts]
|
|
41
|
+
hltdot = "hltdot.client:cli"
|
|
42
|
+
|
|
43
|
+
[project.urls]
|
|
44
|
+
Homepage = "https://github.com/Palani-SN/hltdot-client"
|
|
45
|
+
Source = "https://github.com/Palani-SN/hltdot-client"
|
|
46
|
+
Issues = "https://github.com/Palani-SN/hltdot-client/issues"
|
|
47
|
+
|
|
48
|
+
[tool.hatch.build.targets.wheel]
|
|
49
|
+
packages = ["src/hltdot"]
|
|
50
|
+
|
|
51
|
+
[tool.hatch.build.targets.sdist]
|
|
52
|
+
include = ["src/hltdot", "README.md", "CONTRIBUTING.md", "reqs.txt", "pyproject.toml"]
|
hltdot-0.1.0/reqs.txt
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# The client's dependencies, pinned to the versions the hlt-dot-env env runs.
|
|
2
|
+
# The model generates here, so this half is the heavy one: torch alone is a
|
|
3
|
+
# multi-GB download on a fresh env.
|
|
4
|
+
#
|
|
5
|
+
# torch is pinned to the CUDA 12.6 build and taken from PyTorch's own index:
|
|
6
|
+
# PyPI's plain torch==2.6.0 is the CPU wheel, which installs and imports
|
|
7
|
+
# happily and then generates on the CPU, many times slower with no error to
|
|
8
|
+
# say so. The CUDA runtime and cuDNN ship inside this wheel -- the machine
|
|
9
|
+
# needs only an NVIDIA driver, no CUDA toolkit. It also runs with no GPU.
|
|
10
|
+
# cu126 rather than cu124: PyTorch is phasing out the 12.4 wheels.
|
|
11
|
+
# ../server/run.bat installs torch on its own, first, with --index-url; the
|
|
12
|
+
# line below is for a plain `pip install -r reqs.txt`.
|
|
13
|
+
# For a deliberately CPU-only env, drop both lines and use torch==2.6.0.
|
|
14
|
+
--extra-index-url https://download.pytorch.org/whl/cu126
|
|
15
|
+
torch==2.6.0+cu126
|
|
16
|
+
transformers==5.12.1
|
|
17
|
+
accelerate==1.15.0 # device_map="auto", offloading what will not fit on the GPU
|
|
18
|
+
safetensors==0.8.0
|
|
19
|
+
tokenizers==0.22.2
|
|
20
|
+
psutil==7.2.2 # how much host RAM is free, for max_memory
|
|
21
|
+
|
|
22
|
+
httpx==0.28.1 # /sessions and /models
|
|
23
|
+
websockets==17.1 # the classification stream
|
|
24
|
+
numpy==2.5.3
|
|
25
|
+
PyYAML==6.0.3 # models.yml
|
|
26
|
+
Jinja2==3.1.6 # the tokenizers' chat templates
|
|
27
|
+
rich==15.0.0 # the readings, and the registry chooser
|
|
28
|
+
zstandard==0.25.0 # the activation frames are compressed
|
|
29
|
+
protobuf==7.36.1 # protocol.py builds its descriptors at import
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""HLT-DOT client: the model generates locally, the server reads and stores it.
|
|
2
|
+
|
|
3
|
+
The command-line tool lives in hltdot.client; run it as `hltdot` or
|
|
4
|
+
`python -m hltdot`. Importing this package alone loads nothing heavy.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
__version__ = version("hltdot")
|
|
11
|
+
except PackageNotFoundError: # running from a source tree that was never installed
|
|
12
|
+
__version__ = "0.0.0"
|