formless 0.7.0__tar.gz → 0.8.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.
Potentially problematic release.
This version of formless might be problematic. Click here for more details.
- {formless-0.7.0 → formless-0.8.0}/.gitignore +1 -0
- formless-0.8.0/Makefile +10 -0
- formless-0.8.0/PKG-INFO +295 -0
- formless-0.8.0/README.md +251 -0
- {formless-0.7.0 → formless-0.8.0}/api/app.py +92 -84
- {formless-0.7.0 → formless-0.8.0}/db/migrations/env.py +9 -3
- {formless-0.7.0 → formless-0.8.0}/frontend/app.py +111 -115
- {formless-0.7.0 → formless-0.8.0}/pyproject.toml +33 -16
- {formless-0.7.0 → formless-0.8.0}/src/formless/__init__.py +1 -1
- {formless-0.7.0 → formless-0.8.0}/training/dataset_info.json +11 -0
- formless-0.8.0/training/etl.py +530 -0
- {formless-0.7.0 → formless-0.8.0}/training/quantize.py +3 -9
- {formless-0.7.0 → formless-0.8.0}/training/qwen2vl_full_sft.yaml +1 -1
- formless-0.8.0/training/qwen2vl_lora_dpo_merge.yaml +14 -0
- formless-0.8.0/training/qwen2vl_lora_dpo_train.yaml +43 -0
- {formless-0.7.0 → formless-0.8.0}/training/train.py +50 -38
- {formless-0.7.0 → formless-0.8.0}/utils.py +8 -4
- formless-0.8.0/uv.lock +2998 -0
- formless-0.7.0/Makefile +0 -16
- formless-0.7.0/PKG-INFO +0 -202
- formless-0.7.0/README.md +0 -178
- formless-0.7.0/training/etl.py +0 -388
- formless-0.7.0/uv.lock +0 -1623
- {formless-0.7.0 → formless-0.8.0}/.github/workflows/pre-commit.yml +0 -0
- {formless-0.7.0 → formless-0.8.0}/.pre-commit-config.yaml +0 -0
- {formless-0.7.0 → formless-0.8.0}/LICENSE +0 -0
- {formless-0.7.0 → formless-0.8.0}/api/eg.png +0 -0
- {formless-0.7.0 → formless-0.8.0}/db/migrations/README +0 -0
- {formless-0.7.0 → formless-0.8.0}/db/migrations/alembic.ini +0 -0
- {formless-0.7.0 → formless-0.8.0}/db/migrations/script.py.mako +0 -0
- {formless-0.7.0 → formless-0.8.0}/db/models.py +0 -0
- {formless-0.7.0 → formless-0.8.0}/frontend/favicon.ico +0 -0
- {formless-0.7.0 → formless-0.8.0}/training/__init__.py +0 -0
- {formless-0.7.0 → formless-0.8.0}/training/ds_z3_config.json +0 -0
- {formless-0.7.0 → formless-0.8.0}/training/model.py +0 -0
formless-0.8.0/Makefile
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
SHELL := /bin/bash
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
env ?= dev
|
|
5
|
+
message ?=
|
|
6
|
+
|
|
7
|
+
migrate:
|
|
8
|
+
uv run alembic -x env=$(env) -c db/migrations/alembic.ini stamp head
|
|
9
|
+
uv run alembic -x env=$(env) -c db/migrations/alembic.ini revision --autogenerate -m "$(message)" --version-path db/migrations/versions/$(env)
|
|
10
|
+
uv run alembic -x env=$(env) -c db/migrations/alembic.ini upgrade head
|
formless-0.8.0/PKG-INFO
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: formless
|
|
3
|
+
Version: 0.8.0
|
|
4
|
+
Summary: Handwritten + image OCR.
|
|
5
|
+
License-File: LICENSE
|
|
6
|
+
Requires-Python: >=3.12
|
|
7
|
+
Requires-Dist: accelerate>=1.2.1
|
|
8
|
+
Requires-Dist: alembic>=1.14.0
|
|
9
|
+
Requires-Dist: blobfile>=3.0.0
|
|
10
|
+
Requires-Dist: datasketch==1.6.5
|
|
11
|
+
Requires-Dist: deepspeed==0.15.4
|
|
12
|
+
Requires-Dist: fastapi==0.115.6
|
|
13
|
+
Requires-Dist: hf-transfer==0.1.8
|
|
14
|
+
Requires-Dist: imagehash==4.3.1
|
|
15
|
+
Requires-Dist: modal>=0.64.178
|
|
16
|
+
Requires-Dist: ninja==1.11.1
|
|
17
|
+
Requires-Dist: packaging==23.1
|
|
18
|
+
Requires-Dist: pillow>=10.4.0
|
|
19
|
+
Requires-Dist: pre-commit>=4.0.1
|
|
20
|
+
Requires-Dist: psycopg2-binary==2.9.10
|
|
21
|
+
Requires-Dist: psycopg2==2.9.10
|
|
22
|
+
Requires-Dist: pycairo==1.27.0
|
|
23
|
+
Requires-Dist: pydantic==2.10.4
|
|
24
|
+
Requires-Dist: pyspark==3.5.4
|
|
25
|
+
Requires-Dist: python-dotenv>=1.0.1
|
|
26
|
+
Requires-Dist: python-fasthtml==0.6.10
|
|
27
|
+
Requires-Dist: requests==2.32.3
|
|
28
|
+
Requires-Dist: safetensors>=0.5.1
|
|
29
|
+
Requires-Dist: simpleicons==7.21.0
|
|
30
|
+
Requires-Dist: sqlite-minutils==4.0.3
|
|
31
|
+
Requires-Dist: sqlmodel==0.0.22
|
|
32
|
+
Requires-Dist: stripe==11.1.0
|
|
33
|
+
Requires-Dist: term-image==0.7.2
|
|
34
|
+
Requires-Dist: tiktoken>=0.7.0
|
|
35
|
+
Requires-Dist: torch==2.5.1
|
|
36
|
+
Requires-Dist: torchao>=0.7.0
|
|
37
|
+
Requires-Dist: torchvision>=0.20.1
|
|
38
|
+
Requires-Dist: tqdm==4.67.1
|
|
39
|
+
Requires-Dist: transformers>=4.47.1
|
|
40
|
+
Requires-Dist: validators==0.34.0
|
|
41
|
+
Requires-Dist: vllm==0.6.5
|
|
42
|
+
Requires-Dist: wheel==0.41.2
|
|
43
|
+
Description-Content-Type: text/markdown
|
|
44
|
+
|
|
45
|
+
# formless
|
|
46
|
+
|
|
47
|
+
Hard handwriting understanding.
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
Use the web app:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
https://bit.ly/formless-fe
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Or hit the API:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
curl -X POST -H "Content-Type: application/json" -d '{"image_url": "<image-url>"}' https://bit.ly/formless-api
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Or use the CLI:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
uv run formless -i <image-url> [-v]
|
|
67
|
+
or
|
|
68
|
+
uv run formless -p <local-image-path> [-v]
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Or use in Python:
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from formless import scan
|
|
75
|
+
scan(image_url="<image-url>", verbose=1)
|
|
76
|
+
scan(image_path="<local-image-path>", verbose=1)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Development
|
|
80
|
+
|
|
81
|
+
### Set Up
|
|
82
|
+
|
|
83
|
+
Set up the environment:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
sudo apt install libpq-dev libcairo2-dev libjpeg-dev libgif-dev openjdk-11-jdk
|
|
87
|
+
uv sync --all-extras --dev
|
|
88
|
+
uv run pre-commit install
|
|
89
|
+
modal setup
|
|
90
|
+
modal config set-environment dev
|
|
91
|
+
git clone git@github.com:Len-Stevens/Python-Antivirus.git frontend/Python-Antivirus
|
|
92
|
+
curl -C - -O --retry 5 --retry-delay 10 --retry-max-time 60 -L https://storage.googleapis.com/mathwriting_data/mathwriting-2024.tgz
|
|
93
|
+
tar xzf mathwriting-2024.tgz
|
|
94
|
+
mv mathwriting-2024 training/artifacts/mathwriting-2024
|
|
95
|
+
rm mathwriting-2024.tgz
|
|
96
|
+
echo "alias modal='uv run modal'" >> ~/.bashrc
|
|
97
|
+
echo "export PYTHONPATH=.:$PYTHONPATH" >> ~/.bashrc
|
|
98
|
+
echo "export TOKENIZERS_PARALLELISM=false" >> ~/.bashrc
|
|
99
|
+
echo "export HF_HUB_ENABLE_HF_TRANSFER=1" >> ~/.bashrc
|
|
100
|
+
source ~/.bashrc
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Create a `.env` (+ `.env.dev`):
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
HF_TOKEN=
|
|
107
|
+
|
|
108
|
+
POSTGRES_URL=
|
|
109
|
+
POSTGRES_PRISMA_URL=
|
|
110
|
+
SUPABASE_URL=
|
|
111
|
+
NEXT_PUBLIC_SUPABASE_URL=
|
|
112
|
+
POSTGRES_URL_NON_POOLING=
|
|
113
|
+
SUPABASE_JWT_SECRET=
|
|
114
|
+
POSTGRES_USER=
|
|
115
|
+
NEXT_PUBLIC_SUPABASE_ANON_KEY=
|
|
116
|
+
POSTGRES_PASSWORD=
|
|
117
|
+
POSTGRES_DATABASE=
|
|
118
|
+
SUPABASE_SERVICE_ROLE_KEY=
|
|
119
|
+
POSTGRES_HOST=
|
|
120
|
+
SUPABASE_ANON_KEY=
|
|
121
|
+
|
|
122
|
+
LIVE=
|
|
123
|
+
DEBUG=
|
|
124
|
+
STRIPE_PUBLISHABLE_KEY=
|
|
125
|
+
STRIPE_SECRET_KEY=
|
|
126
|
+
STRIPE_WEBHOOK_SECRET=
|
|
127
|
+
DOMAIN=
|
|
128
|
+
API_URL=
|
|
129
|
+
|
|
130
|
+
WANDB_API_KEY=
|
|
131
|
+
WANDB_ENTITY=
|
|
132
|
+
|
|
133
|
+
AWS_ACCESS_KEY_ID=
|
|
134
|
+
AWS_SECRET_ACCESS_KEY=
|
|
135
|
+
AWS_REGION=
|
|
136
|
+
OPENAI_API_KEY=
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Useful Commands
|
|
140
|
+
|
|
141
|
+
Lint and format:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
uv run pre-commit run --all-files
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Migrate db (do before running the frontend/api):
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
make migrate env=<env> message=<message>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Repository Structure
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
.
|
|
157
|
+
├── api # API.
|
|
158
|
+
├── frontend # frontend.
|
|
159
|
+
├── src/formless # python bindings.
|
|
160
|
+
├── training # training.
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### API
|
|
164
|
+
|
|
165
|
+
Test the API with an example input:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
modal run api/app.py
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
Serve the API locally:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
uv run api/app.py
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Serve the API on Modal:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
modal serve api/app.py
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Deploy on dev:
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
modal deploy api/app.py
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Deploy on main:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
modal deploy --env=main api/app.py
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Frontend
|
|
196
|
+
|
|
197
|
+
Serve the web app locally:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
uv run frontend/app.py
|
|
201
|
+
stripe listen --forward-to <url>/webhook
|
|
202
|
+
# update API_URL, STRIPE_WEBHOOK_SECRET, and DOMAIN in .env.dev
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
Serve the web app on Modal:
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
modal serve frontend/app.py
|
|
209
|
+
stripe listen --forward-to <url>/webhook
|
|
210
|
+
# update API_URL, STRIPE_WEBHOOK_SECRET, and DOMAIN in .env.dev
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
Deploy on dev:
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
modal deploy frontend/app.py
|
|
217
|
+
# update API_URL, STRIPE_WEBHOOK_SECRET, and DOMAIN in .env.dev
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Deploy on main:
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
modal deploy --env=main frontend/app.py
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### PyPI
|
|
227
|
+
|
|
228
|
+
Run the package:
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
uv run formless -v
|
|
232
|
+
# update API_URL in src/formless/__init__.py
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Build the package:
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
uvx --from build pyproject-build --installer uv
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Upload the package:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
uvx twine upload dist/*
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Test the uploaded package:
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
uv run --with formless --no-project -- formless -v
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Training
|
|
254
|
+
|
|
255
|
+
Label subset of data (~1000 samples) to train writing quality classifier:
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
modal run training/etl.py --cls
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Run classifier training:
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
modal run training/train.py --cls
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Use trained classifier to filter train/val/test data (down to ~10k samples) to train VLM using full SFT and eval:
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
modal run training/etl.py --sft
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Run SFT:
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
modal run training/train.py --sft
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Run trained VLM on val data and collect/manually label worst examples (~50 samples) for DPO training:
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
modal run training/etl.py --dpo
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
Run DPO:
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
modal run training/train.py --dpo
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
Quantize the DPO model:
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
modal run training/quantize.py
|
|
295
|
+
```
|
formless-0.8.0/README.md
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
# formless
|
|
2
|
+
|
|
3
|
+
Hard handwriting understanding.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
Use the web app:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
https://bit.ly/formless-fe
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or hit the API:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
curl -X POST -H "Content-Type: application/json" -d '{"image_url": "<image-url>"}' https://bit.ly/formless-api
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Or use the CLI:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
uv run formless -i <image-url> [-v]
|
|
23
|
+
or
|
|
24
|
+
uv run formless -p <local-image-path> [-v]
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or use in Python:
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from formless import scan
|
|
31
|
+
scan(image_url="<image-url>", verbose=1)
|
|
32
|
+
scan(image_path="<local-image-path>", verbose=1)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Development
|
|
36
|
+
|
|
37
|
+
### Set Up
|
|
38
|
+
|
|
39
|
+
Set up the environment:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
sudo apt install libpq-dev libcairo2-dev libjpeg-dev libgif-dev openjdk-11-jdk
|
|
43
|
+
uv sync --all-extras --dev
|
|
44
|
+
uv run pre-commit install
|
|
45
|
+
modal setup
|
|
46
|
+
modal config set-environment dev
|
|
47
|
+
git clone git@github.com:Len-Stevens/Python-Antivirus.git frontend/Python-Antivirus
|
|
48
|
+
curl -C - -O --retry 5 --retry-delay 10 --retry-max-time 60 -L https://storage.googleapis.com/mathwriting_data/mathwriting-2024.tgz
|
|
49
|
+
tar xzf mathwriting-2024.tgz
|
|
50
|
+
mv mathwriting-2024 training/artifacts/mathwriting-2024
|
|
51
|
+
rm mathwriting-2024.tgz
|
|
52
|
+
echo "alias modal='uv run modal'" >> ~/.bashrc
|
|
53
|
+
echo "export PYTHONPATH=.:$PYTHONPATH" >> ~/.bashrc
|
|
54
|
+
echo "export TOKENIZERS_PARALLELISM=false" >> ~/.bashrc
|
|
55
|
+
echo "export HF_HUB_ENABLE_HF_TRANSFER=1" >> ~/.bashrc
|
|
56
|
+
source ~/.bashrc
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Create a `.env` (+ `.env.dev`):
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
HF_TOKEN=
|
|
63
|
+
|
|
64
|
+
POSTGRES_URL=
|
|
65
|
+
POSTGRES_PRISMA_URL=
|
|
66
|
+
SUPABASE_URL=
|
|
67
|
+
NEXT_PUBLIC_SUPABASE_URL=
|
|
68
|
+
POSTGRES_URL_NON_POOLING=
|
|
69
|
+
SUPABASE_JWT_SECRET=
|
|
70
|
+
POSTGRES_USER=
|
|
71
|
+
NEXT_PUBLIC_SUPABASE_ANON_KEY=
|
|
72
|
+
POSTGRES_PASSWORD=
|
|
73
|
+
POSTGRES_DATABASE=
|
|
74
|
+
SUPABASE_SERVICE_ROLE_KEY=
|
|
75
|
+
POSTGRES_HOST=
|
|
76
|
+
SUPABASE_ANON_KEY=
|
|
77
|
+
|
|
78
|
+
LIVE=
|
|
79
|
+
DEBUG=
|
|
80
|
+
STRIPE_PUBLISHABLE_KEY=
|
|
81
|
+
STRIPE_SECRET_KEY=
|
|
82
|
+
STRIPE_WEBHOOK_SECRET=
|
|
83
|
+
DOMAIN=
|
|
84
|
+
API_URL=
|
|
85
|
+
|
|
86
|
+
WANDB_API_KEY=
|
|
87
|
+
WANDB_ENTITY=
|
|
88
|
+
|
|
89
|
+
AWS_ACCESS_KEY_ID=
|
|
90
|
+
AWS_SECRET_ACCESS_KEY=
|
|
91
|
+
AWS_REGION=
|
|
92
|
+
OPENAI_API_KEY=
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Useful Commands
|
|
96
|
+
|
|
97
|
+
Lint and format:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
uv run pre-commit run --all-files
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Migrate db (do before running the frontend/api):
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
make migrate env=<env> message=<message>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Repository Structure
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
.
|
|
113
|
+
├── api # API.
|
|
114
|
+
├── frontend # frontend.
|
|
115
|
+
├── src/formless # python bindings.
|
|
116
|
+
├── training # training.
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### API
|
|
120
|
+
|
|
121
|
+
Test the API with an example input:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
modal run api/app.py
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Serve the API locally:
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
uv run api/app.py
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Serve the API on Modal:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
modal serve api/app.py
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Deploy on dev:
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
modal deploy api/app.py
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Deploy on main:
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
modal deploy --env=main api/app.py
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Frontend
|
|
152
|
+
|
|
153
|
+
Serve the web app locally:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
uv run frontend/app.py
|
|
157
|
+
stripe listen --forward-to <url>/webhook
|
|
158
|
+
# update API_URL, STRIPE_WEBHOOK_SECRET, and DOMAIN in .env.dev
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Serve the web app on Modal:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
modal serve frontend/app.py
|
|
165
|
+
stripe listen --forward-to <url>/webhook
|
|
166
|
+
# update API_URL, STRIPE_WEBHOOK_SECRET, and DOMAIN in .env.dev
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Deploy on dev:
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
modal deploy frontend/app.py
|
|
173
|
+
# update API_URL, STRIPE_WEBHOOK_SECRET, and DOMAIN in .env.dev
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Deploy on main:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
modal deploy --env=main frontend/app.py
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### PyPI
|
|
183
|
+
|
|
184
|
+
Run the package:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
uv run formless -v
|
|
188
|
+
# update API_URL in src/formless/__init__.py
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Build the package:
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
uvx --from build pyproject-build --installer uv
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Upload the package:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
uvx twine upload dist/*
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Test the uploaded package:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
uv run --with formless --no-project -- formless -v
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Training
|
|
210
|
+
|
|
211
|
+
Label subset of data (~1000 samples) to train writing quality classifier:
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
modal run training/etl.py --cls
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Run classifier training:
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
modal run training/train.py --cls
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Use trained classifier to filter train/val/test data (down to ~10k samples) to train VLM using full SFT and eval:
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
modal run training/etl.py --sft
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Run SFT:
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
modal run training/train.py --sft
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Run trained VLM on val data and collect/manually label worst examples (~50 samples) for DPO training:
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
modal run training/etl.py --dpo
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Run DPO:
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
modal run training/train.py --dpo
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Quantize the DPO model:
|
|
248
|
+
|
|
249
|
+
```bash
|
|
250
|
+
modal run training/quantize.py
|
|
251
|
+
```
|