mostlyai-engine 2.7.3__tar.gz → 2.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.
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/PKG-INFO +40 -39
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/README.md +33 -32
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/__init__.py +5 -5
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_common.py +19 -6
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_encoding_types/language/categorical.py +1 -1
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_encoding_types/language/datetime.py +1 -1
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_encoding_types/language/numeric.py +1 -1
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_encoding_types/tabular/categorical.py +2 -2
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_encoding_types/tabular/character.py +2 -2
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_encoding_types/tabular/datetime.py +8 -1
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_encoding_types/tabular/itt.py +2 -2
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_encoding_types/tabular/lat_long.py +3 -3
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_encoding_types/tabular/numeric.py +5 -5
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_language/engine/base.py +0 -1
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_language/engine/hf_engine.py +18 -18
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_language/engine/vllm_engine.py +10 -10
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_language/generation.py +4 -5
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_language/interface.py +2 -2
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_language/lstm.py +1 -1
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_language/training.py +2 -3
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_memory.py +1 -1
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_tabular/argn.py +18 -18
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_tabular/encoding.py +1 -1
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_tabular/generation.py +20 -7
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_tabular/interface.py +2 -2
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_tabular/probability.py +3 -3
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_tabular/training.py +1 -7
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_workspace.py +1 -1
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/analysis.py +1 -1
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/splitting.py +9 -9
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/pyproject.toml +18 -10
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/.gitignore +0 -0
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/LICENSE +0 -0
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_dtypes.py +0 -0
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_encoding_types/__init__.py +0 -0
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_encoding_types/language/__init__.py +0 -0
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_encoding_types/language/text.py +0 -0
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_encoding_types/tabular/__init__.py +0 -0
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_language/__init__.py +0 -0
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_language/common.py +0 -0
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_language/encoding.py +0 -0
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_language/engine/__init__.py +0 -0
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_language/tokenizer_utils.py +0 -0
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_language/xgrammar_hf_logits.py +0 -0
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_language/xgrammar_utils.py +0 -0
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_tabular/__init__.py +0 -0
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_tabular/common.py +0 -0
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_tabular/fairness.py +0 -0
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_training_utils.py +0 -0
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/domain.py +0 -0
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/encoding.py +0 -0
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/generation.py +0 -0
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/logging.py +0 -0
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/random_state.py +0 -0
- {mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/training.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: mostlyai-engine
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.8.0
|
|
4
4
|
Summary: Synthetic Data Engine
|
|
5
5
|
Project-URL: homepage, https://github.com/mostly-ai/mostlyai-engine
|
|
6
6
|
Project-URL: repository, https://github.com/mostly-ai/mostlyai-engine
|
|
@@ -35,16 +35,16 @@ Requires-Dist: peft>=0.18.2
|
|
|
35
35
|
Requires-Dist: psutil<6,>=5.9.5
|
|
36
36
|
Requires-Dist: pyarrow>=16.0.0
|
|
37
37
|
Requires-Dist: scikit-learn>=1.4.0
|
|
38
|
-
Requires-Dist: tokenizers>=0.
|
|
39
|
-
Requires-Dist: torch<2.
|
|
38
|
+
Requires-Dist: tokenizers>=0.23.3
|
|
39
|
+
Requires-Dist: torch<2.15.0,>=2.14.0
|
|
40
40
|
Requires-Dist: torchaudio<2.12.0,>=2.11.0
|
|
41
|
-
Requires-Dist: torchvision<0.
|
|
42
|
-
Requires-Dist: transformers>=5.
|
|
43
|
-
Requires-Dist: xgrammar<1.0.0,>=0.2.
|
|
41
|
+
Requires-Dist: torchvision<0.30.0,>=0.29.0
|
|
42
|
+
Requires-Dist: transformers>=5.16.1
|
|
43
|
+
Requires-Dist: xgrammar<1.0.0,>=0.2.8
|
|
44
44
|
Provides-Extra: gpu
|
|
45
45
|
Requires-Dist: bitsandbytes==0.42.0; (sys_platform == 'darwin') and extra == 'gpu'
|
|
46
46
|
Requires-Dist: bitsandbytes>=0.45.5; (sys_platform == 'linux') and extra == 'gpu'
|
|
47
|
-
Requires-Dist: vllm==0.
|
|
47
|
+
Requires-Dist: vllm==0.34.0; (sys_platform == 'linux') and extra == 'gpu'
|
|
48
48
|
Description-Content-Type: text/markdown
|
|
49
49
|
|
|
50
50
|
# Synthetic Data Engine 💎
|
|
@@ -155,10 +155,7 @@ Generate new synthetic samples conditionally:
|
|
|
155
155
|
|
|
156
156
|
```python
|
|
157
157
|
# prepare seed
|
|
158
|
-
seed_data = pd.DataFrame({
|
|
159
|
-
"age": [25, 50],
|
|
160
|
-
"education": ["Bachelors", "HS-grad"]
|
|
161
|
-
})
|
|
158
|
+
seed_data = pd.DataFrame({"age": [25, 50], "education": ["Bachelors", "HS-grad"]})
|
|
162
159
|
|
|
163
160
|
# conditional sampling
|
|
164
161
|
argn.sample(seed_data=seed_data)
|
|
@@ -180,7 +177,6 @@ data_imputed = argn.impute(data_with_missings)
|
|
|
180
177
|
|
|
181
178
|
# impute missing values each with their point estimates
|
|
182
179
|
data_imputed = argn.impute(data_with_missings, n_draws=100)
|
|
183
|
-
|
|
184
180
|
```
|
|
185
181
|
|
|
186
182
|
### Predictions / Classification
|
|
@@ -226,28 +222,29 @@ Assess any marginal conditional probability, for one or more target columns:
|
|
|
226
222
|
```python
|
|
227
223
|
# extract class probabilities for a categorical
|
|
228
224
|
argn.predict_proba(
|
|
229
|
-
X=pd.DataFrame(
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
225
|
+
X=pd.DataFrame(
|
|
226
|
+
{
|
|
227
|
+
"age": [25, 30, 35],
|
|
228
|
+
"sex": ["Male", "Female", "Male"],
|
|
229
|
+
}
|
|
230
|
+
),
|
|
231
|
+
target="income",
|
|
234
232
|
)
|
|
235
233
|
|
|
236
234
|
# extract bin probabilities for a numerical
|
|
237
235
|
argn.predict_proba(
|
|
238
|
-
X=pd.DataFrame(
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
236
|
+
X=pd.DataFrame(
|
|
237
|
+
{
|
|
238
|
+
# "age": [25, 30, 35],
|
|
239
|
+
"sex": ["Male", "Female", "Male"],
|
|
240
|
+
"occupation": ["Craft-repair", "Craft-repair", "Craft-repair"],
|
|
241
|
+
}
|
|
242
|
+
),
|
|
243
|
+
target="capital_gain",
|
|
244
244
|
)
|
|
245
245
|
|
|
246
246
|
# extract two-way marginals
|
|
247
|
-
argn.predict_proba(
|
|
248
|
-
X=data_test[["age", "race"]],
|
|
249
|
-
target=["sex", "income"]
|
|
250
|
-
)
|
|
247
|
+
argn.predict_proba(X=data_test[["age", "race"]], target=["sex", "income"])
|
|
251
248
|
```
|
|
252
249
|
|
|
253
250
|
### Log Probability
|
|
@@ -297,13 +294,15 @@ argn.sample(n_samples=5)
|
|
|
297
294
|
Generate new synthetic samples conditionally (using custom context and seed):
|
|
298
295
|
|
|
299
296
|
```python
|
|
300
|
-
ctx_data = pd.DataFrame(
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
297
|
+
ctx_data = pd.DataFrame(
|
|
298
|
+
{
|
|
299
|
+
"id": ["Player1", "Player2"],
|
|
300
|
+
"weight": [170, 160],
|
|
301
|
+
"height": [70, 68],
|
|
302
|
+
"bats": ["R", "L"],
|
|
303
|
+
"throws": ["R", "L"],
|
|
304
|
+
}
|
|
305
|
+
)
|
|
307
306
|
argn.sample(ctx_data=ctx_data)
|
|
308
307
|
```
|
|
309
308
|
|
|
@@ -328,8 +327,8 @@ data = pd.read_csv("https://github.com/user-attachments/files/23486562/airbnb20k
|
|
|
328
327
|
lm = LanguageModel(
|
|
329
328
|
model="MOSTLY_AI/LSTMFromScratch-3m",
|
|
330
329
|
tgt_encoding_types={
|
|
331
|
-
|
|
332
|
-
|
|
330
|
+
"neighbourhood": "LANGUAGE_CATEGORICAL",
|
|
331
|
+
"title": "LANGUAGE_TEXT",
|
|
333
332
|
},
|
|
334
333
|
max_training_time=10, # 10 minutes
|
|
335
334
|
verbose=1,
|
|
@@ -351,9 +350,11 @@ lm.sample(
|
|
|
351
350
|
|
|
352
351
|
```python
|
|
353
352
|
# prepare seed
|
|
354
|
-
seed_data = pd.DataFrame(
|
|
355
|
-
|
|
356
|
-
|
|
353
|
+
seed_data = pd.DataFrame(
|
|
354
|
+
{
|
|
355
|
+
"neighbourhood": ["Westminster", "Hackney"],
|
|
356
|
+
}
|
|
357
|
+
)
|
|
357
358
|
|
|
358
359
|
# conditional sampling with seed values
|
|
359
360
|
lm.sample(
|
|
@@ -106,10 +106,7 @@ Generate new synthetic samples conditionally:
|
|
|
106
106
|
|
|
107
107
|
```python
|
|
108
108
|
# prepare seed
|
|
109
|
-
seed_data = pd.DataFrame({
|
|
110
|
-
"age": [25, 50],
|
|
111
|
-
"education": ["Bachelors", "HS-grad"]
|
|
112
|
-
})
|
|
109
|
+
seed_data = pd.DataFrame({"age": [25, 50], "education": ["Bachelors", "HS-grad"]})
|
|
113
110
|
|
|
114
111
|
# conditional sampling
|
|
115
112
|
argn.sample(seed_data=seed_data)
|
|
@@ -131,7 +128,6 @@ data_imputed = argn.impute(data_with_missings)
|
|
|
131
128
|
|
|
132
129
|
# impute missing values each with their point estimates
|
|
133
130
|
data_imputed = argn.impute(data_with_missings, n_draws=100)
|
|
134
|
-
|
|
135
131
|
```
|
|
136
132
|
|
|
137
133
|
### Predictions / Classification
|
|
@@ -177,28 +173,29 @@ Assess any marginal conditional probability, for one or more target columns:
|
|
|
177
173
|
```python
|
|
178
174
|
# extract class probabilities for a categorical
|
|
179
175
|
argn.predict_proba(
|
|
180
|
-
X=pd.DataFrame(
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
176
|
+
X=pd.DataFrame(
|
|
177
|
+
{
|
|
178
|
+
"age": [25, 30, 35],
|
|
179
|
+
"sex": ["Male", "Female", "Male"],
|
|
180
|
+
}
|
|
181
|
+
),
|
|
182
|
+
target="income",
|
|
185
183
|
)
|
|
186
184
|
|
|
187
185
|
# extract bin probabilities for a numerical
|
|
188
186
|
argn.predict_proba(
|
|
189
|
-
X=pd.DataFrame(
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
187
|
+
X=pd.DataFrame(
|
|
188
|
+
{
|
|
189
|
+
# "age": [25, 30, 35],
|
|
190
|
+
"sex": ["Male", "Female", "Male"],
|
|
191
|
+
"occupation": ["Craft-repair", "Craft-repair", "Craft-repair"],
|
|
192
|
+
}
|
|
193
|
+
),
|
|
194
|
+
target="capital_gain",
|
|
195
195
|
)
|
|
196
196
|
|
|
197
197
|
# extract two-way marginals
|
|
198
|
-
argn.predict_proba(
|
|
199
|
-
X=data_test[["age", "race"]],
|
|
200
|
-
target=["sex", "income"]
|
|
201
|
-
)
|
|
198
|
+
argn.predict_proba(X=data_test[["age", "race"]], target=["sex", "income"])
|
|
202
199
|
```
|
|
203
200
|
|
|
204
201
|
### Log Probability
|
|
@@ -248,13 +245,15 @@ argn.sample(n_samples=5)
|
|
|
248
245
|
Generate new synthetic samples conditionally (using custom context and seed):
|
|
249
246
|
|
|
250
247
|
```python
|
|
251
|
-
ctx_data = pd.DataFrame(
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
248
|
+
ctx_data = pd.DataFrame(
|
|
249
|
+
{
|
|
250
|
+
"id": ["Player1", "Player2"],
|
|
251
|
+
"weight": [170, 160],
|
|
252
|
+
"height": [70, 68],
|
|
253
|
+
"bats": ["R", "L"],
|
|
254
|
+
"throws": ["R", "L"],
|
|
255
|
+
}
|
|
256
|
+
)
|
|
258
257
|
argn.sample(ctx_data=ctx_data)
|
|
259
258
|
```
|
|
260
259
|
|
|
@@ -279,8 +278,8 @@ data = pd.read_csv("https://github.com/user-attachments/files/23486562/airbnb20k
|
|
|
279
278
|
lm = LanguageModel(
|
|
280
279
|
model="MOSTLY_AI/LSTMFromScratch-3m",
|
|
281
280
|
tgt_encoding_types={
|
|
282
|
-
|
|
283
|
-
|
|
281
|
+
"neighbourhood": "LANGUAGE_CATEGORICAL",
|
|
282
|
+
"title": "LANGUAGE_TEXT",
|
|
284
283
|
},
|
|
285
284
|
max_training_time=10, # 10 minutes
|
|
286
285
|
verbose=1,
|
|
@@ -302,9 +301,11 @@ lm.sample(
|
|
|
302
301
|
|
|
303
302
|
```python
|
|
304
303
|
# prepare seed
|
|
305
|
-
seed_data = pd.DataFrame(
|
|
306
|
-
|
|
307
|
-
|
|
304
|
+
seed_data = pd.DataFrame(
|
|
305
|
+
{
|
|
306
|
+
"neighbourhood": ["Westminster", "Hackney"],
|
|
307
|
+
}
|
|
308
|
+
)
|
|
308
309
|
|
|
309
310
|
# conditional sampling with seed values
|
|
310
311
|
lm.sample(
|
|
@@ -24,17 +24,17 @@ from mostlyai.engine.splitting import split
|
|
|
24
24
|
from mostlyai.engine.training import train
|
|
25
25
|
|
|
26
26
|
__all__ = [
|
|
27
|
-
"
|
|
27
|
+
"LanguageModel",
|
|
28
|
+
"TabularARGN",
|
|
28
29
|
"analyze",
|
|
29
30
|
"encode",
|
|
30
|
-
"train",
|
|
31
31
|
"generate",
|
|
32
32
|
"init_logging",
|
|
33
33
|
"set_random_state",
|
|
34
|
-
"
|
|
35
|
-
"
|
|
34
|
+
"split",
|
|
35
|
+
"train",
|
|
36
36
|
]
|
|
37
|
-
__version__ = "2.
|
|
37
|
+
__version__ = "2.8.0"
|
|
38
38
|
|
|
39
39
|
# suppress specific warning related to os.fork() in multi-threaded processes
|
|
40
40
|
warnings.filterwarnings("ignore", category=DeprecationWarning, message=".*multi-threaded.*fork.*")
|
|
@@ -369,7 +369,7 @@ def get_sub_columns_nested(
|
|
|
369
369
|
"tables": PREFIX_COLUMN,
|
|
370
370
|
"columns": PREFIX_SUB_COLUMN,
|
|
371
371
|
}[groupby]
|
|
372
|
-
out: dict[str, list[str]] =
|
|
372
|
+
out: dict[str, list[str]] = {}
|
|
373
373
|
for sub_col in sub_columns:
|
|
374
374
|
key = sub_col.split(splitby)[0]
|
|
375
375
|
out[key] = out.get(key, []) + [sub_col]
|
|
@@ -461,7 +461,7 @@ def find_distinct_bins(x: list[Any], n: int, n_max: int = 1_000) -> list[Any]:
|
|
|
461
461
|
"""
|
|
462
462
|
# return immediately if we have less distinct values than `n`
|
|
463
463
|
if len(x) <= n or len(set(x)) <= n:
|
|
464
|
-
return
|
|
464
|
+
return sorted(set(x))
|
|
465
465
|
no_of_quantiles = n
|
|
466
466
|
# increase quantiles until we have found `n` distinct bins
|
|
467
467
|
while no_of_quantiles <= n_max:
|
|
@@ -470,7 +470,7 @@ def find_distinct_bins(x: list[Any], n: int, n_max: int = 1_000) -> list[Any]:
|
|
|
470
470
|
no_of_distinct_quantiles = len(set(qs))
|
|
471
471
|
# return if we have found `n` distinct quantiles
|
|
472
472
|
if no_of_distinct_quantiles >= n + 1:
|
|
473
|
-
bins =
|
|
473
|
+
bins = sorted(set(qs))
|
|
474
474
|
if len(bins) > n + 1:
|
|
475
475
|
# handle edge case where we have more than `n` + 1 bins; this can happen if we have a eg 100 bins for
|
|
476
476
|
# no_of_quantiles=200, but then 102 bins for no_of_quantiles=201.
|
|
@@ -479,10 +479,19 @@ def find_distinct_bins(x: list[Any], n: int, n_max: int = 1_000) -> list[Any]:
|
|
|
479
479
|
# we need to increase at least by number of missing quantiles to acchieve `n` distinct quantiles
|
|
480
480
|
no_of_quantiles += 1 + max(0, n - no_of_distinct_quantiles)
|
|
481
481
|
# in case we fail to find `n` distinct bins before `n_max` we return largest set of bins
|
|
482
|
-
return
|
|
482
|
+
return sorted(set(qs))
|
|
483
483
|
|
|
484
484
|
|
|
485
485
|
def apply_encoding_type_dtypes(df: pd.DataFrame, encoding_types: dict[str, ModelEncodingType]) -> pd.DataFrame:
|
|
486
|
+
if len(df) == 0:
|
|
487
|
+
# DataFrame.apply may skip empty columns or discard their converted dtypes.
|
|
488
|
+
return pd.DataFrame(
|
|
489
|
+
{
|
|
490
|
+
name: _get_type_converter(encoding_types[name])(df[name]) if name in encoding_types else df[name]
|
|
491
|
+
for name in df.columns
|
|
492
|
+
},
|
|
493
|
+
index=df.index,
|
|
494
|
+
)
|
|
486
495
|
return df.apply(lambda x: _get_type_converter(encoding_types[x.name])(x) if x.name in encoding_types else x)
|
|
487
496
|
|
|
488
497
|
|
|
@@ -514,7 +523,7 @@ def skip_if_error(func: Callable) -> Callable:
|
|
|
514
523
|
def skip_if_error_wrapper(*args, **kwargs) -> Any:
|
|
515
524
|
try:
|
|
516
525
|
return func(*args, **kwargs)
|
|
517
|
-
except Exception as e:
|
|
526
|
+
except Exception as e: # noqa: BLE001
|
|
518
527
|
_LOG.warning(f"{func.__qualname__} failed with {type(e)}: {e}")
|
|
519
528
|
|
|
520
529
|
return skip_if_error_wrapper
|
|
@@ -540,7 +549,11 @@ def decode_positional_column(df_encoded: pd.DataFrame, max_seq_len: int, prefix:
|
|
|
540
549
|
else:
|
|
541
550
|
# decode positional column as numeric_digit
|
|
542
551
|
n_digits = len(str(max_seq_len))
|
|
543
|
-
|
|
552
|
+
# Promote before multiplying: int32 can wrap even when the place
|
|
553
|
+
# value itself fits. Very large DP bounds also need Python integers
|
|
554
|
+
# when the full encoded decimal range no longer fits in int64.
|
|
555
|
+
dtype = "int64" if n_digits < 19 else "object"
|
|
556
|
+
vals = sum(df_encoded[f"{prefix}E{d}"].astype(dtype) * 10**d for d in range(n_digits))
|
|
544
557
|
return vals
|
|
545
558
|
|
|
546
559
|
|
|
@@ -35,7 +35,7 @@ def analyze_reduce_language_categorical(
|
|
|
35
35
|
) -> dict:
|
|
36
36
|
stats = analyze_reduce_categorical(stats_list, value_protection, value_protection_epsilon)
|
|
37
37
|
stats["categories"] = list(stats["codes"].keys())
|
|
38
|
-
if any(
|
|
38
|
+
if any(j["has_nan"] for j in stats_list):
|
|
39
39
|
# when has_nan, tabular stats are like [CATEGORICAL_UNKNOWN_TOKEN, CATEGORICAL_NULL_TOKEN, ...]
|
|
40
40
|
# and we need to replace CATEGORICAL_NULL_TOKEN with None for language
|
|
41
41
|
stats["categories"][1] = None
|
{mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_encoding_types/language/datetime.py
RENAMED
|
@@ -55,7 +55,7 @@ def analyze_reduce_language_datetime(
|
|
|
55
55
|
value_protection_epsilon: float | None = None,
|
|
56
56
|
) -> dict:
|
|
57
57
|
# check if there are missing values
|
|
58
|
-
has_nan = any(
|
|
58
|
+
has_nan = any(j["has_nan"] for j in stats_list)
|
|
59
59
|
reduced_min_n = sorted([v for min_n in [j["min_n"] for j in stats_list] for v in min_n], reverse=False)
|
|
60
60
|
reduced_max_n = sorted([v for max_n in [j["max_n"] for j in stats_list] for v in max_n], reverse=True)
|
|
61
61
|
if value_protection:
|
{mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_encoding_types/language/numeric.py
RENAMED
|
@@ -69,7 +69,7 @@ def analyze_reduce_language_numeric(
|
|
|
69
69
|
value_protection_epsilon: float | None = None,
|
|
70
70
|
) -> dict:
|
|
71
71
|
# check for occurrence of NaN values
|
|
72
|
-
has_nan = any(
|
|
72
|
+
has_nan = any(j["has_nan"] for j in stats_list)
|
|
73
73
|
|
|
74
74
|
# determine max scale
|
|
75
75
|
max_scale = max([j["max_scale"] for j in stats_list])
|
|
@@ -86,7 +86,7 @@ def analyze_reduce_categorical(
|
|
|
86
86
|
categories = known_categories
|
|
87
87
|
no_of_rare_categories = len(known_categories) - len(categories)
|
|
88
88
|
# add special token for MISSING categories, if any are present
|
|
89
|
-
if any(
|
|
89
|
+
if any(j["has_nan"] for j in stats_list):
|
|
90
90
|
categories = [CATEGORICAL_NULL_TOKEN] + categories
|
|
91
91
|
# add special token for UNKNOWN categories at first position
|
|
92
92
|
categories = [CATEGORICAL_UNKNOWN_TOKEN] + categories
|
|
@@ -101,7 +101,7 @@ def analyze_reduce_categorical(
|
|
|
101
101
|
def encode_categorical(values: pd.Series, stats: dict, _: pd.Series | None = None) -> pd.DataFrame:
|
|
102
102
|
# ensure a safe representation of values: 1. string dtype; 2. escape reserved tokens
|
|
103
103
|
values = safe_categorical_escape(safe_convert_string(values))
|
|
104
|
-
known_categories = [str(k) for k in stats["codes"]
|
|
104
|
+
known_categories = [str(k) for k in stats["codes"]]
|
|
105
105
|
values = values.copy()
|
|
106
106
|
if CATEGORICAL_NULL_TOKEN in known_categories:
|
|
107
107
|
values[values.isna()] = CATEGORICAL_NULL_TOKEN
|
{mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_encoding_types/tabular/character.py
RENAMED
|
@@ -81,7 +81,7 @@ def analyze_reduce_character(
|
|
|
81
81
|
codes[pos] = {categories[i]: i for i in range(len(categories))}
|
|
82
82
|
# determine cardinalities
|
|
83
83
|
cardinalities = {}
|
|
84
|
-
has_nan = any(
|
|
84
|
+
has_nan = any(s["has_nan"] for s in stats_list)
|
|
85
85
|
if has_nan:
|
|
86
86
|
cardinalities["nan"] = 2 # binary
|
|
87
87
|
for sub_col, sub_col_codes in codes.items():
|
|
@@ -155,7 +155,7 @@ def decode_character(df_encoded: pd.DataFrame, stats: dict) -> pd.Series:
|
|
|
155
155
|
pd.Categorical.from_codes(df_encoded[sub_col], categories=stats["codes"][sub_col]),
|
|
156
156
|
dtype="string",
|
|
157
157
|
)
|
|
158
|
-
for sub_col in stats["codes"]
|
|
158
|
+
for sub_col in stats["codes"]
|
|
159
159
|
},
|
|
160
160
|
)
|
|
161
161
|
values = df_decoded.apply(lambda item: "".join(item), axis=1, result_type="reduce").astype(
|
{mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_encoding_types/tabular/datetime.py
RENAMED
|
@@ -88,7 +88,7 @@ def analyze_reduce_datetime(
|
|
|
88
88
|
value_protection_epsilon: float | None = None,
|
|
89
89
|
) -> dict:
|
|
90
90
|
# check if there are missing values
|
|
91
|
-
has_nan = any(
|
|
91
|
+
has_nan = any(j["has_nan"] for j in stats_list)
|
|
92
92
|
# determine min/max values for each part
|
|
93
93
|
keys = stats_list[0]["min_values"].keys()
|
|
94
94
|
min_values = {k: min([j["min_values"][k] for j in stats_list]) for k in keys}
|
|
@@ -115,6 +115,13 @@ def analyze_reduce_datetime(
|
|
|
115
115
|
log_hist = [sum(bin) for bin in zip(*[j["log_hist"] for j in stats_list])]
|
|
116
116
|
reduced_min, reduced_max = dp_approx_bounds(log_hist, value_protection_epsilon)
|
|
117
117
|
if reduced_min is not None and reduced_max is not None:
|
|
118
|
+
# DP noise can select histogram bins outside the decoder's
|
|
119
|
+
# nanosecond range. Use fixed bounds (DP post-processing),
|
|
120
|
+
# rounded inward to whole days to support date-only columns.
|
|
121
|
+
min_us = pd.Timestamp.min.ceil("D").value // 1_000
|
|
122
|
+
max_us = pd.Timestamp.max.floor("D").value // 1_000
|
|
123
|
+
reduced_min = min(max(reduced_min, min_us), max_us)
|
|
124
|
+
reduced_max = min(max(reduced_max, min_us), max_us)
|
|
118
125
|
# convert back to the original string format
|
|
119
126
|
reduced_min = pd.to_datetime(int(reduced_min), unit="us").strftime(dt_format)
|
|
120
127
|
reduced_max = pd.to_datetime(int(reduced_max), unit="us").strftime(dt_format)
|
{mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_encoding_types/tabular/itt.py
RENAMED
|
@@ -102,9 +102,9 @@ def analyze_reduce_itt(
|
|
|
102
102
|
value_protection_epsilon: float | None = None,
|
|
103
103
|
) -> dict:
|
|
104
104
|
# check if there are missing values
|
|
105
|
-
has_nan = any(
|
|
105
|
+
has_nan = any(j["has_nan"] for j in stats_list)
|
|
106
106
|
# check if there are negative values
|
|
107
|
-
has_neg = any(
|
|
107
|
+
has_neg = any(j["has_neg"] for j in stats_list)
|
|
108
108
|
# determine min/max values for each part
|
|
109
109
|
keys = stats_list[0]["min_values"].keys()
|
|
110
110
|
min_values = {k: min([j["min_values"][k] for j in stats_list]) for k in keys}
|
{mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_encoding_types/tabular/lat_long.py
RENAMED
|
@@ -141,7 +141,7 @@ def _binary_to_latlong(data: pd.Series) -> pd.Series:
|
|
|
141
141
|
Transform from a quadtile to its (lat, long) float representation
|
|
142
142
|
For example: '-+AAAAAABCCBBBDADBBCCADDCBCCBB' -> (30.87, 133.11331)
|
|
143
143
|
"""
|
|
144
|
-
if not quadtile or
|
|
144
|
+
if not quadtile or len(quadtile) != len(PLACEHOLDER_QUADTILE_ENTRY):
|
|
145
145
|
return None, None
|
|
146
146
|
|
|
147
147
|
latitude_sign = 1 if quadtile[0] == "+" else -1
|
|
@@ -278,7 +278,7 @@ def analyze_reduce_latlong(
|
|
|
278
278
|
value_protection_epsilon: float | None = None,
|
|
279
279
|
) -> dict:
|
|
280
280
|
# check if there are missing values
|
|
281
|
-
has_nan = any(
|
|
281
|
+
has_nan = any(j["has_nan"] for j in stats_list)
|
|
282
282
|
unk_cat_aliases = [""] # na / unknown (unseen) category
|
|
283
283
|
|
|
284
284
|
quads = list(stats_list[0]["quad_codes"].keys()) if len(stats_list) else []
|
|
@@ -300,7 +300,7 @@ def analyze_reduce_latlong(
|
|
|
300
300
|
rare_min = get_stochastic_rare_threshold(
|
|
301
301
|
min_threshold=RARE_CATEGORY_THRESHOLD
|
|
302
302
|
) # FIXME: should this be 20 + noise?
|
|
303
|
-
categories = [k for k in cnt_values
|
|
303
|
+
categories = [k for k in cnt_values if cnt_values[k] >= rare_min]
|
|
304
304
|
categories = ([CATEGORICAL_UNKNOWN_TOKEN] + [cat for cat in categories if cat not in unk_cat_aliases])[
|
|
305
305
|
:MAX_UNIQUE_VALUES_PER_QUAD
|
|
306
306
|
] # UNK + remaining possible values
|
{mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_encoding_types/tabular/numeric.py
RENAMED
|
@@ -245,9 +245,9 @@ def analyze_reduce_numeric(
|
|
|
245
245
|
encoding_type: ModelEncodingType | None = ModelEncodingType.tabular_numeric_auto,
|
|
246
246
|
) -> dict:
|
|
247
247
|
# check for occurrence of NaN values
|
|
248
|
-
has_nan = any(
|
|
248
|
+
has_nan = any(j["has_nan"] for j in stats_list)
|
|
249
249
|
# check if there are negative values
|
|
250
|
-
has_neg = any(
|
|
250
|
+
has_neg = any(j["has_neg"] for j in stats_list)
|
|
251
251
|
# determine precision to apply rounding of sampled values during generation
|
|
252
252
|
keys = sorted({k for stats in stats_list for k in stats["max_digits"]}, key=lambda k: int(k[1:]), reverse=True)
|
|
253
253
|
min_digits = {k: min([j["min_digits"].get(k, 0) for j in stats_list]) for k in keys}
|
|
@@ -280,12 +280,12 @@ def analyze_reduce_numeric(
|
|
|
280
280
|
else:
|
|
281
281
|
max_decimal = 0
|
|
282
282
|
# don't allow more digits than the capped value for it
|
|
283
|
-
decimal_cap =
|
|
283
|
+
decimal_cap = next(d[1:] for d in keys)
|
|
284
284
|
decimal_cap = int(decimal_cap) if decimal_cap.isnumeric() else NUMERIC_DIGIT_MAX_DECIMAL
|
|
285
285
|
max_decimal = min(max(min_decimal, max_decimal), decimal_cap)
|
|
286
286
|
|
|
287
287
|
# sum up cnt_values (if they exist for all partitions)
|
|
288
|
-
has_cnt_values = all(
|
|
288
|
+
has_cnt_values = all(j["cnt_values"] for j in stats_list)
|
|
289
289
|
if has_cnt_values:
|
|
290
290
|
# sum up all counts for each categorical value
|
|
291
291
|
cnt_values: dict[str, int] = {}
|
|
@@ -505,7 +505,7 @@ def _decode_numeric_discrete(df_encoded: pd.DataFrame, stats: dict) -> pd.Series
|
|
|
505
505
|
valid_values = pd.Series(
|
|
506
506
|
[
|
|
507
507
|
str(k)
|
|
508
|
-
for k in stats["codes"]
|
|
508
|
+
for k in stats["codes"]
|
|
509
509
|
if k not in [NUMERIC_DISCRETE_UNKNOWN_TOKEN, NUMERIC_DISCRETE_NULL_TOKEN]
|
|
510
510
|
]
|
|
511
511
|
)
|
|
@@ -53,7 +53,6 @@ class LanguageEngine(ABC):
|
|
|
53
53
|
Default implementation does nothing.
|
|
54
54
|
Engines that support JSON constraints should override this method.
|
|
55
55
|
"""
|
|
56
|
-
pass
|
|
57
56
|
|
|
58
57
|
def can_reuse_schemas(self) -> bool:
|
|
59
58
|
"""Whether the engine can reuse JSON schema constraints across batches with different sizes.
|
{mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_language/engine/hf_engine.py
RENAMED
|
@@ -79,28 +79,28 @@ class HuggingFaceEngine(LanguageEngine):
|
|
|
79
79
|
) -> tuple[list[int], EngineMetrics]:
|
|
80
80
|
do_sample = sampling_temperature > 0.0
|
|
81
81
|
|
|
82
|
-
tokenize_kwargs =
|
|
83
|
-
tokenizer
|
|
84
|
-
return_tensors
|
|
85
|
-
add_bos_token
|
|
86
|
-
add_eos_token
|
|
87
|
-
padding
|
|
88
|
-
truncation
|
|
89
|
-
max_length
|
|
90
|
-
|
|
82
|
+
tokenize_kwargs = {
|
|
83
|
+
"tokenizer": self.tokenizer,
|
|
84
|
+
"return_tensors": "pt",
|
|
85
|
+
"add_bos_token": True,
|
|
86
|
+
"add_eos_token": False,
|
|
87
|
+
"padding": True,
|
|
88
|
+
"truncation": True,
|
|
89
|
+
"max_length": self.tokenizer_max_length, # truncates input
|
|
90
|
+
}
|
|
91
91
|
t_tokenize = time.time()
|
|
92
92
|
inputs = tokenize_fn(text=text, **tokenize_kwargs).to(self.device)
|
|
93
93
|
tokenize_time = time.time() - t_tokenize
|
|
94
94
|
|
|
95
|
-
generate_kwargs =
|
|
96
|
-
do_sample
|
|
97
|
-
max_new_tokens
|
|
98
|
-
temperature
|
|
99
|
-
top_p
|
|
100
|
-
bos_token_id
|
|
101
|
-
pad_token_id
|
|
102
|
-
eos_token_id
|
|
103
|
-
|
|
95
|
+
generate_kwargs = {
|
|
96
|
+
"do_sample": do_sample,
|
|
97
|
+
"max_new_tokens": self.max_new_tokens,
|
|
98
|
+
"temperature": sampling_temperature if do_sample else None,
|
|
99
|
+
"top_p": sampling_top_p if do_sample else None,
|
|
100
|
+
"bos_token_id": self.tokenizer.bos_token_id,
|
|
101
|
+
"pad_token_id": self.tokenizer.pad_token_id,
|
|
102
|
+
"eos_token_id": self.tokenizer.eos_token_id,
|
|
103
|
+
}
|
|
104
104
|
|
|
105
105
|
t_generate = time.time()
|
|
106
106
|
outputs = self._model.generate(**inputs, **generate_kwargs, logits_processor=self._logits_processors)
|
{mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_language/engine/vllm_engine.py
RENAMED
|
@@ -99,7 +99,7 @@ def get_dynamic_gpu_memory_utilization(utilization_ratio: float = 0.9) -> float:
|
|
|
99
99
|
# Ensure utilization is within reasonable bounds (0.1 to 0.95)
|
|
100
100
|
return max(0.1, min(0.95, utilization))
|
|
101
101
|
|
|
102
|
-
except Exception:
|
|
102
|
+
except Exception: # noqa: BLE001
|
|
103
103
|
# Fallback to provided ratio if anything goes wrong
|
|
104
104
|
return utilization_ratio
|
|
105
105
|
|
|
@@ -155,15 +155,15 @@ class VLLMEngine(LanguageEngine):
|
|
|
155
155
|
def generate(
|
|
156
156
|
self, text: list[str], sampling_temperature: float, sampling_top_p: float
|
|
157
157
|
) -> tuple[list[int], EngineMetrics]:
|
|
158
|
-
tokenize_kwargs =
|
|
159
|
-
tokenizer
|
|
160
|
-
return_tensors
|
|
161
|
-
add_bos_token
|
|
162
|
-
add_eos_token
|
|
163
|
-
padding
|
|
164
|
-
truncation
|
|
165
|
-
max_length
|
|
166
|
-
|
|
158
|
+
tokenize_kwargs = {
|
|
159
|
+
"tokenizer": self.tokenizer,
|
|
160
|
+
"return_tensors": None,
|
|
161
|
+
"add_bos_token": True,
|
|
162
|
+
"add_eos_token": False,
|
|
163
|
+
"padding": False,
|
|
164
|
+
"truncation": True,
|
|
165
|
+
"max_length": self.tokenizer_max_length, # truncates input
|
|
166
|
+
}
|
|
167
167
|
t_tokenize = time.time()
|
|
168
168
|
inputs = tokenize_fn(text=text, **tokenize_kwargs)
|
|
169
169
|
tokenize_time = time.time() - t_tokenize
|
|
@@ -73,8 +73,8 @@ def decode_buffered_samples(
|
|
|
73
73
|
try:
|
|
74
74
|
parsed_x = json_repair.loads(x, stream_stable=True)
|
|
75
75
|
if not isinstance(parsed_x, dict):
|
|
76
|
-
raise ValueError("parsed_x has to be a dictionary")
|
|
77
|
-
except Exception:
|
|
76
|
+
raise ValueError("parsed_x has to be a dictionary") # noqa: TRY004
|
|
77
|
+
except Exception: # noqa: BLE001
|
|
78
78
|
parsed_x = {}
|
|
79
79
|
return [parsed_x.get(c, INVALID_VALUE) for c in columns]
|
|
80
80
|
|
|
@@ -112,7 +112,7 @@ def decode_buffered_samples(
|
|
|
112
112
|
if ctx_keys.name != DUMMY_CONTEXT_KEY:
|
|
113
113
|
tgt_data = pd.concat([ctx_keys, tgt_data], axis=1)
|
|
114
114
|
|
|
115
|
-
for col in tgt_stats["columns"]
|
|
115
|
+
for col in tgt_stats["columns"]:
|
|
116
116
|
col_stats = tgt_stats["columns"][col]
|
|
117
117
|
if col_stats["encoding_type"] == ModelEncodingType.language_numeric:
|
|
118
118
|
tgt_data[col] = decode_language_numeric(tgt_data[col], col_stats)
|
|
@@ -272,8 +272,7 @@ def generate(
|
|
|
272
272
|
batch_size = batch_size or engine.get_default_batch_size()
|
|
273
273
|
_LOG.info(f"model loading time: {time.time() - t0:.2f}s")
|
|
274
274
|
|
|
275
|
-
|
|
276
|
-
batch_size = sample_size
|
|
275
|
+
batch_size = min(batch_size, sample_size)
|
|
277
276
|
_LOG.info(f"{batch_size=}")
|
|
278
277
|
|
|
279
278
|
seed_data = ensure_seed_can_be_tokenized(seed_data, engine.tokenizer)
|
|
@@ -231,7 +231,7 @@ class LanguageModel(BaseEstimator):
|
|
|
231
231
|
try:
|
|
232
232
|
self._temp_dir.cleanup()
|
|
233
233
|
self._temp_dir = None # Mark as cleaned up
|
|
234
|
-
except Exception:
|
|
234
|
+
except Exception: # noqa: BLE001, S110
|
|
235
235
|
pass
|
|
236
236
|
|
|
237
237
|
def __enter__(self):
|
|
@@ -298,7 +298,7 @@ class LanguageModel(BaseEstimator):
|
|
|
298
298
|
|
|
299
299
|
# For sequential models: if ctx_data was not explicitly provided and n_samples is specified,
|
|
300
300
|
# take a random sample of the training ctx_data
|
|
301
|
-
if not ctx_data_explicit and n_samples is not None and self.tgt_context_key is not None:
|
|
301
|
+
if not ctx_data_explicit and n_samples is not None and self.tgt_context_key is not None: # noqa: SIM102
|
|
302
302
|
if len(ctx_data_df) > n_samples:
|
|
303
303
|
ctx_data_df = ctx_data_df.sample(n=n_samples, random_state=self.random_state)
|
|
304
304
|
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import logging
|
|
16
16
|
|
|
17
17
|
import torch
|
|
18
|
-
|
|
18
|
+
from torch import nn
|
|
19
19
|
from transformers import AutoConfig, AutoModel, AutoModelForCausalLM, GenerationMixin, PretrainedConfig, PreTrainedModel
|
|
20
20
|
from transformers.modeling_outputs import CausalLMOutput
|
|
21
21
|
|
|
@@ -477,9 +477,8 @@ def train(
|
|
|
477
477
|
differential_privacy=with_dp,
|
|
478
478
|
)
|
|
479
479
|
tokenizer = AutoTokenizer.from_pretrained(model_id_or_path, **tokenizer_args)
|
|
480
|
-
if tokenizer.eos_token is None:
|
|
481
|
-
|
|
482
|
-
tokenizer.eos_token_id = model_config.eos_token_id
|
|
480
|
+
if tokenizer.eos_token is None and getattr(model_config, "eos_token_id", None) is not None:
|
|
481
|
+
tokenizer.eos_token_id = model_config.eos_token_id
|
|
483
482
|
if tokenizer.bos_token is None:
|
|
484
483
|
if getattr(model_config, "bos_token_id", None) is not None:
|
|
485
484
|
tokenizer.bos_token_id = model_config.bos_token_id
|
|
@@ -83,13 +83,13 @@ def get_model_units(model: nn.Module) -> dict[str, Any]:
|
|
|
83
83
|
name[name.find("sequential_context@") :]: [module.hidden_size] * module.num_layers
|
|
84
84
|
for name, module in model.named_modules()
|
|
85
85
|
if ".sequential_context@" in name
|
|
86
|
-
if isinstance(module, nn.LSTM
|
|
86
|
+
if isinstance(module, (nn.LSTM, DPLSTM))
|
|
87
87
|
}
|
|
88
88
|
history_units = {
|
|
89
89
|
name[name.find("history@") :]: [module.hidden_size] * module.num_layers
|
|
90
90
|
for name, module in model.named_modules()
|
|
91
91
|
if ".history@" in name
|
|
92
|
-
if isinstance(module, nn.LSTM
|
|
92
|
+
if isinstance(module, (nn.LSTM, DPLSTM))
|
|
93
93
|
}
|
|
94
94
|
regressor_units = {
|
|
95
95
|
name[name.find("regressor@") :]: [layer.out_features for layer in module]
|
|
@@ -116,11 +116,11 @@ def get_model_units(model: nn.Module) -> dict[str, Any]:
|
|
|
116
116
|
def _embedding_heuristic(id: str, model_size: ModelSizeOrUnits, dim_input: int) -> int:
|
|
117
117
|
if isinstance(model_size, dict):
|
|
118
118
|
return model_size[id]
|
|
119
|
-
model_size_output_dim =
|
|
120
|
-
S
|
|
121
|
-
M
|
|
122
|
-
L
|
|
123
|
-
|
|
119
|
+
model_size_output_dim = {
|
|
120
|
+
"S": max(10, int(2 * np.ceil(dim_input**0.15))),
|
|
121
|
+
"M": max(10, int(3 * np.ceil(dim_input**0.25))),
|
|
122
|
+
"L": max(10, int(4 * np.ceil(dim_input**0.33))),
|
|
123
|
+
}
|
|
124
124
|
return min(dim_input, model_size_output_dim[model_size])
|
|
125
125
|
|
|
126
126
|
|
|
@@ -133,11 +133,11 @@ def _column_embedding_heuristic(
|
|
|
133
133
|
) -> int:
|
|
134
134
|
if isinstance(model_size, dict):
|
|
135
135
|
return model_size.get(id, dim_input)
|
|
136
|
-
model_size_output_dim =
|
|
137
|
-
S
|
|
138
|
-
M
|
|
139
|
-
L
|
|
140
|
-
|
|
136
|
+
model_size_output_dim = {
|
|
137
|
+
"S": int(4 + n_sub_cols),
|
|
138
|
+
"M": int(10 + n_sub_cols),
|
|
139
|
+
"L": int(16 + n_sub_cols),
|
|
140
|
+
}
|
|
141
141
|
compress = compress_enabled and n_sub_cols > 2
|
|
142
142
|
dim_output = model_size_output_dim[model_size] if compress else dim_input
|
|
143
143
|
# dim_output should always be at most dim_input
|
|
@@ -147,7 +147,7 @@ def _column_embedding_heuristic(
|
|
|
147
147
|
def _regressor_heuristic(id: str, model_size: ModelSizeOrUnits, dim_input: int, cardinality: int) -> list[int]:
|
|
148
148
|
if isinstance(model_size, dict):
|
|
149
149
|
return model_size[id]
|
|
150
|
-
model_size_layers =
|
|
150
|
+
model_size_layers = {"S": [4], "M": [16], "L": [16, 16]}
|
|
151
151
|
dims = [dim_input]
|
|
152
152
|
layers = model_size_layers[model_size]
|
|
153
153
|
# first layers depend on input dimension
|
|
@@ -164,7 +164,7 @@ def _regressor_heuristic(id: str, model_size: ModelSizeOrUnits, dim_input: int,
|
|
|
164
164
|
def _flat_context_heuristic(id: str, model_size: ModelSizeOrUnits, dim_input: int) -> list[int]:
|
|
165
165
|
if isinstance(model_size, dict):
|
|
166
166
|
return model_size[id]
|
|
167
|
-
model_size_layers =
|
|
167
|
+
model_size_layers = {"S": [2], "M": [8], "L": [32]}
|
|
168
168
|
layers = model_size_layers[model_size]
|
|
169
169
|
coefficient = round(np.log(max(dim_input, np.e)))
|
|
170
170
|
dims = [unit * coefficient for unit in layers]
|
|
@@ -177,7 +177,7 @@ def _sequential_context_heuristic(
|
|
|
177
177
|
) -> list[int]:
|
|
178
178
|
if isinstance(model_size, dict):
|
|
179
179
|
return model_size[id]
|
|
180
|
-
model_size_layers =
|
|
180
|
+
model_size_layers = {"S": [4], "M": [16], "L": [64, 64]}
|
|
181
181
|
layers = model_size_layers[model_size]
|
|
182
182
|
coefficient = round(np.log(max(dim_input * seq_len_median, np.e)))
|
|
183
183
|
dims = [unit * coefficient for unit in layers]
|
|
@@ -188,7 +188,7 @@ def _sequential_context_heuristic(
|
|
|
188
188
|
def _history_heuristic(id: str, model_size: ModelSizeOrUnits, dim_input: int, seq_len_median: int) -> list[int]:
|
|
189
189
|
if isinstance(model_size, dict):
|
|
190
190
|
return model_size[id]
|
|
191
|
-
model_size_layers =
|
|
191
|
+
model_size_layers = {"S": [16], "M": [64], "L": [128, 128]}
|
|
192
192
|
layers = model_size_layers[model_size]
|
|
193
193
|
coefficient = round(np.log(max(dim_input * seq_len_median, np.e)))
|
|
194
194
|
dims = [unit * coefficient for unit in layers]
|
|
@@ -508,7 +508,7 @@ class SequentialContextCompressor(nn.Module):
|
|
|
508
508
|
def forward(self, x) -> tuple[list[torch.Tensor], list[torch.Tensor]]:
|
|
509
509
|
sequential_contexts = []
|
|
510
510
|
sequential_context_masks = []
|
|
511
|
-
for table
|
|
511
|
+
for table in self.ctxseq_table_sub_columns:
|
|
512
512
|
# pass through sequential context table embeddings
|
|
513
513
|
table_embeddings, mask = self.embedders[table](x)
|
|
514
514
|
sequential_context_masks.append(mask)
|
|
@@ -1476,7 +1476,7 @@ class SequentialModel(nn.Module):
|
|
|
1476
1476
|
if is_0th_step and sub_col.startswith(RIDX_SUB_COLUMN_PREFIX):
|
|
1477
1477
|
# overwrite output for RIDX sub-columns on 0th step with SLEN sub-columns
|
|
1478
1478
|
slen_sub_col = sub_col.replace(RIDX_SUB_COLUMN_PREFIX, SLEN_SUB_COLUMN_PREFIX)
|
|
1479
|
-
out = outputs
|
|
1479
|
+
out = outputs.get(slen_sub_col, out)
|
|
1480
1480
|
outputs[sub_col] = out
|
|
1481
1481
|
|
|
1482
1482
|
# update current sub column embedding
|
|
@@ -220,7 +220,7 @@ def encode_df(
|
|
|
220
220
|
# data columns
|
|
221
221
|
stats = stats or {"columns": {}}
|
|
222
222
|
delayed_encodes = []
|
|
223
|
-
for column in stats["columns"]
|
|
223
|
+
for column in stats["columns"]:
|
|
224
224
|
if column not in df:
|
|
225
225
|
# skip encoding for columns that are not present in the data
|
|
226
226
|
continue
|
|
@@ -148,7 +148,7 @@ def _resolve_gen_column_order(
|
|
|
148
148
|
+ [target_column_argn]
|
|
149
149
|
)
|
|
150
150
|
|
|
151
|
-
if rebalancing:
|
|
151
|
+
if rebalancing: # noqa: SIM102
|
|
152
152
|
# rebalance column should be at the beginning in the generation model
|
|
153
153
|
# rebalancing has higher priority than imputation
|
|
154
154
|
if rebalancing.column in column_stats:
|
|
@@ -438,7 +438,7 @@ def _fix_imputation_probs(
|
|
|
438
438
|
col_stats = stats["columns"][col]
|
|
439
439
|
encoding_type = col_stats["encoding_type"]
|
|
440
440
|
# null_name will be either None, "na" or "nan"
|
|
441
|
-
null_subcol = next(iter([k[4:] for k in col_stats
|
|
441
|
+
null_subcol = next(iter([k[4:] for k in col_stats if k in ["has_na", "has_nan"]]), None)
|
|
442
442
|
if null_subcol is not None and col_stats[f"has_{null_subcol}"]:
|
|
443
443
|
# column has separate null sub column and there are some nulls
|
|
444
444
|
code_null = 1
|
|
@@ -546,7 +546,7 @@ def _decode_df(
|
|
|
546
546
|
argn_column=column_stats[ARGN_COLUMN],
|
|
547
547
|
argn_sub_column=sub_col,
|
|
548
548
|
)
|
|
549
|
-
for sub_col in column_stats["cardinalities"]
|
|
549
|
+
for sub_col in column_stats["cardinalities"]
|
|
550
550
|
]
|
|
551
551
|
# fetch column-specific sub_columns from data
|
|
552
552
|
df_encoded_col = df_encoded[sub_columns]
|
|
@@ -773,9 +773,9 @@ def generate(
|
|
|
773
773
|
has_slen = has_ridx = has_sdec = None
|
|
774
774
|
if is_sequential:
|
|
775
775
|
if isinstance(model_units, dict):
|
|
776
|
-
has_slen = any(SLEN_SUB_COLUMN_PREFIX in k for k in model_units
|
|
777
|
-
has_ridx = any(RIDX_SUB_COLUMN_PREFIX in k for k in model_units
|
|
778
|
-
has_sdec = any(SDEC_SUB_COLUMN_PREFIX in k for k in model_units
|
|
776
|
+
has_slen = any(SLEN_SUB_COLUMN_PREFIX in k for k in model_units)
|
|
777
|
+
has_ridx = any(RIDX_SUB_COLUMN_PREFIX in k for k in model_units)
|
|
778
|
+
has_sdec = any(SDEC_SUB_COLUMN_PREFIX in k for k in model_units)
|
|
779
779
|
else:
|
|
780
780
|
has_slen, has_ridx, has_sdec = DEFAULT_HAS_SLEN, DEFAULT_HAS_RIDX, DEFAULT_HAS_SDEC
|
|
781
781
|
|
|
@@ -867,6 +867,19 @@ def generate(
|
|
|
867
867
|
ctx_primary_keys.rename(ctx_primary_key, inplace=True)
|
|
868
868
|
ctx_data = ctx_primary_keys.to_frame()
|
|
869
869
|
|
|
870
|
+
if sample_size == 0:
|
|
871
|
+
# Empty parents are valid (including after DP generation). Persist
|
|
872
|
+
# a typed part so downstream tables and reports can still read it,
|
|
873
|
+
# without constructing tensors or regrouping empty sequences.
|
|
874
|
+
encoding_types = {name: stats["encoding_type"] for name, stats in tgt_stats["columns"].items()}
|
|
875
|
+
syn = apply_encoding_type_dtypes(pd.DataFrame(columns=list(encoding_types)), encoding_types)
|
|
876
|
+
if tgt_context_key:
|
|
877
|
+
keys = ctx_data[ctx_primary_key].iloc[:0] if ctx_primary_key in ctx_data else pd.Series(dtype="string")
|
|
878
|
+
syn.insert(0, tgt_context_key, keys)
|
|
879
|
+
syn = _post_process_decoding(syn, tgt_primary_key=tgt_primary_key)
|
|
880
|
+
persist_data_part(syn, output_path, f"{0:06}.{0:06}")
|
|
881
|
+
return
|
|
882
|
+
|
|
870
883
|
if seed_data is None:
|
|
871
884
|
# create on-the-fly seed data
|
|
872
885
|
seed_data = pd.DataFrame(columns=[tgt_context_key])
|
|
@@ -1256,7 +1269,7 @@ def generate(
|
|
|
1256
1269
|
[ctx_keys]
|
|
1257
1270
|
+ [
|
|
1258
1271
|
pd.Series(out_dct[sub_col].detach().cpu().numpy(), dtype="int32", name=sub_col)
|
|
1259
|
-
for sub_col in tgt_cardinalities
|
|
1272
|
+
for sub_col in tgt_cardinalities
|
|
1260
1273
|
],
|
|
1261
1274
|
axis=1,
|
|
1262
1275
|
)
|
|
@@ -271,7 +271,7 @@ class TabularARGN(BaseEstimator):
|
|
|
271
271
|
try:
|
|
272
272
|
self._temp_dir.cleanup()
|
|
273
273
|
self._temp_dir = None # Mark as cleaned up
|
|
274
|
-
except Exception:
|
|
274
|
+
except Exception: # noqa: BLE001, S110
|
|
275
275
|
pass
|
|
276
276
|
|
|
277
277
|
def __enter__(self):
|
|
@@ -344,7 +344,7 @@ class TabularARGN(BaseEstimator):
|
|
|
344
344
|
|
|
345
345
|
# For sequential models: if ctx_data was not explicitly provided and n_samples is specified,
|
|
346
346
|
# take a random sample of the training ctx_data
|
|
347
|
-
if not ctx_data_explicit and n_samples is not None and self.tgt_context_key is not None:
|
|
347
|
+
if not ctx_data_explicit and n_samples is not None and self.tgt_context_key is not None: # noqa: SIM102
|
|
348
348
|
if len(ctx_data_df) > n_samples:
|
|
349
349
|
ctx_data_df = ctx_data_df.sample(n=n_samples, random_state=self.random_state)
|
|
350
350
|
|
|
@@ -285,7 +285,7 @@ def _generate_marginal_probs(
|
|
|
285
285
|
argn_column=target_stats[ARGN_COLUMN],
|
|
286
286
|
argn_sub_column=sub_col,
|
|
287
287
|
)
|
|
288
|
-
for sub_col in target_stats["cardinalities"]
|
|
288
|
+
for sub_col in target_stats["cardinalities"]
|
|
289
289
|
]
|
|
290
290
|
|
|
291
291
|
# Convert column names to ARGN format for model
|
|
@@ -354,7 +354,7 @@ def predict_proba(
|
|
|
354
354
|
_LOG.info(f"PREDICT_PROBA started for targets: {target_columns}")
|
|
355
355
|
|
|
356
356
|
# Initialize model
|
|
357
|
-
model, tgt_stats, ctx_stats,
|
|
357
|
+
model, tgt_stats, ctx_stats, _tgt_cardinalities, all_columns, fixed_probs, device, enable_flexible_generation = (
|
|
358
358
|
_initialize_model(
|
|
359
359
|
workspace=workspace,
|
|
360
360
|
rare_category_replacement_method=rare_category_replacement_method,
|
|
@@ -460,7 +460,7 @@ def predict_proba(
|
|
|
460
460
|
prev_target_col = target_columns[i]
|
|
461
461
|
encoded_val = prev_combo[i]
|
|
462
462
|
prev_target_stats = tgt_stats["columns"][prev_target_col]
|
|
463
|
-
for sub_col_key in prev_target_stats["cardinalities"]
|
|
463
|
+
for sub_col_key in prev_target_stats["cardinalities"]:
|
|
464
464
|
full_sub_col_name = get_argn_name(
|
|
465
465
|
argn_processor=prev_target_stats[ARGN_PROCESSOR],
|
|
466
466
|
argn_table=prev_target_stats[ARGN_TABLE],
|
|
@@ -176,13 +176,7 @@ class BatchCollator:
|
|
|
176
176
|
),
|
|
177
177
|
dim=-1,
|
|
178
178
|
)
|
|
179
|
-
elif column.startswith(TGT) and not self.is_sequential:
|
|
180
|
-
# construct column tensor in single step
|
|
181
|
-
tensors[column] = torch.unsqueeze(
|
|
182
|
-
torch.tensor(batch[column].values, dtype=torch.int64, device=self.device),
|
|
183
|
-
dim=-1,
|
|
184
|
-
)
|
|
185
|
-
elif column.startswith(CTXFLT):
|
|
179
|
+
elif column.startswith(TGT) and not self.is_sequential or column.startswith(CTXFLT):
|
|
186
180
|
# construct column tensor in single step
|
|
187
181
|
tensors[column] = torch.unsqueeze(
|
|
188
182
|
torch.tensor(batch[column].values, dtype=torch.int64, device=self.device),
|
|
@@ -365,7 +365,7 @@ def _analyze_reduce(
|
|
|
365
365
|
if value_protection_epsilon is not None and n_dp_splits > 0:
|
|
366
366
|
_LOG.info(f"epsilon for analyzing each column and sequence length: {value_protection_epsilon / n_dp_splits}")
|
|
367
367
|
|
|
368
|
-
for column in encoding_types:
|
|
368
|
+
for column in encoding_types: # noqa: PLC0206
|
|
369
369
|
encoding_type = encoding_types[column]
|
|
370
370
|
column_stats_list = [item["columns"][column] for item in stats_list]
|
|
371
371
|
column_stats_list = [
|
|
@@ -110,22 +110,22 @@ def split(
|
|
|
110
110
|
with ProgressCallbackWrapper(update_progress) as progress:
|
|
111
111
|
# validate input
|
|
112
112
|
if tgt_primary_key and tgt_primary_key not in tgt_data:
|
|
113
|
-
raise Exception("tgt_primary_key not found in tgt_data")
|
|
113
|
+
raise Exception("tgt_primary_key not found in tgt_data") # noqa: TRY002
|
|
114
114
|
if tgt_primary_key and tgt_data[tgt_primary_key].duplicated().any():
|
|
115
|
-
raise Exception("tgt_primary_key must be unique")
|
|
115
|
+
raise Exception("tgt_primary_key must be unique") # noqa: TRY002
|
|
116
116
|
if ctx_data is not None:
|
|
117
117
|
if tgt_context_key is None:
|
|
118
|
-
raise Exception("tgt_context_key must be provided")
|
|
118
|
+
raise Exception("tgt_context_key must be provided") # noqa: TRY002
|
|
119
119
|
if tgt_context_key not in tgt_data:
|
|
120
|
-
raise Exception("tgt_context_key not found in tgt_data")
|
|
120
|
+
raise Exception("tgt_context_key not found in tgt_data") # noqa: TRY002
|
|
121
121
|
if ctx_primary_key is None:
|
|
122
|
-
raise Exception("ctx_primary_key must be provided")
|
|
122
|
+
raise Exception("ctx_primary_key must be provided") # noqa: TRY002
|
|
123
123
|
if ctx_primary_key not in ctx_data:
|
|
124
|
-
raise Exception("ctx_primary_key not found in ctx_data")
|
|
124
|
+
raise Exception("ctx_primary_key not found in ctx_data") # noqa: TRY002
|
|
125
125
|
if ctx_data[ctx_primary_key].duplicated().any():
|
|
126
|
-
raise Exception("ctx_primary_key must be unique")
|
|
126
|
+
raise Exception("ctx_primary_key must be unique") # noqa: TRY002
|
|
127
127
|
if not tgt_data[tgt_context_key].isin(ctx_data[ctx_primary_key]).all():
|
|
128
|
-
raise Exception("tgt_primary_keys must match ctx_primary_keys")
|
|
128
|
+
raise Exception("tgt_primary_keys must match ctx_primary_keys") # noqa: TRY002
|
|
129
129
|
|
|
130
130
|
# prepare data
|
|
131
131
|
if ctx_data is None and tgt_context_key is not None:
|
|
@@ -177,7 +177,7 @@ def split(
|
|
|
177
177
|
# check if tgt_encoding_types are consistent with model_type
|
|
178
178
|
for col, enc_type in tgt_encoding_types.items():
|
|
179
179
|
if not enc_type.startswith(model_type):
|
|
180
|
-
raise Exception("Mismatch between model_type and model_encoding_types")
|
|
180
|
+
raise Exception("Mismatch between model_type and model_encoding_types") # noqa: TRY002
|
|
181
181
|
|
|
182
182
|
# split into trn/val
|
|
183
183
|
tmp_key = "__key"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "mostlyai-engine"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.8.0"
|
|
4
4
|
description = "Synthetic Data Engine"
|
|
5
5
|
requires-python = ">=3.11,<3.14"
|
|
6
6
|
readme = "README.md"
|
|
@@ -29,33 +29,34 @@ dependencies = [
|
|
|
29
29
|
"joblib>=1.4.2",
|
|
30
30
|
"scikit-learn>=1.4.0",
|
|
31
31
|
"psutil>=5.9.5,<6", # upgrade when colab psutil is updated
|
|
32
|
-
"tokenizers>=0.
|
|
33
|
-
"transformers>=5.
|
|
32
|
+
"tokenizers>=0.23.3", # vllm lower bound
|
|
33
|
+
"transformers>=5.16.1", # aligned with vllm 0.34
|
|
34
34
|
"datasets>=3.0.0",
|
|
35
35
|
"accelerate>=1.5.0",
|
|
36
36
|
"peft>=0.18.2", # transformers 5.7+ checks min PEFT in model.add_adapter (integrations/peft.py)
|
|
37
37
|
"huggingface-hub[hf-xet]>=0.30.2",
|
|
38
38
|
"opacus>=1.6.0",
|
|
39
|
-
"xgrammar>=0.2.
|
|
39
|
+
"xgrammar>=0.2.8,<1.0.0", # aligned with vllm 0.34
|
|
40
40
|
"json-repair>=0.60.1",
|
|
41
|
-
"torch>=2.
|
|
41
|
+
"torch>=2.14.0,<2.15.0",
|
|
42
42
|
"torchaudio>=2.11.0,<2.12.0",
|
|
43
|
-
"torchvision>=0.
|
|
43
|
+
"torchvision>=0.29.0,<0.30.0",
|
|
44
44
|
]
|
|
45
45
|
|
|
46
46
|
[project.optional-dependencies]
|
|
47
47
|
gpu = [
|
|
48
48
|
"bitsandbytes==0.42.0; sys_platform == 'darwin'",
|
|
49
49
|
"bitsandbytes>=0.45.5; sys_platform == 'linux'",
|
|
50
|
-
"vllm==0.
|
|
50
|
+
"vllm==0.34.0; sys_platform == 'linux'",
|
|
51
51
|
]
|
|
52
52
|
|
|
53
53
|
[dependency-groups]
|
|
54
54
|
dev = [
|
|
55
55
|
"pytest>=9.0.3",
|
|
56
56
|
"pytest-rerunfailures>=15.0",
|
|
57
|
-
"ruff>=0.
|
|
58
|
-
"
|
|
57
|
+
"ruff>=0.17.6,<0.18", # sync'ed with .pre-commit-config
|
|
58
|
+
"prek>=0.5.12",
|
|
59
|
+
"ty==0.0.112", # pinned: ty is pre-1.0 and diagnostics change between releases
|
|
59
60
|
"twine>=6.1",
|
|
60
61
|
"ipykernel>=6.25",
|
|
61
62
|
]
|
|
@@ -99,4 +100,11 @@ extend-exclude = ["*.ipynb"]
|
|
|
99
100
|
[tool.ruff.format]
|
|
100
101
|
exclude = ["examples/*.ipynb"]
|
|
101
102
|
[tool.ruff.lint]
|
|
102
|
-
extend-select = ["I"]
|
|
103
|
+
extend-select = ["I", "UP"]
|
|
104
|
+
extend-ignore = [
|
|
105
|
+
"UP042", # str+Enum -> StrEnum changes str()/format() of public enums
|
|
106
|
+
"RUF012", # mutable class attributes are idiomatic for pydantic models
|
|
107
|
+
]
|
|
108
|
+
|
|
109
|
+
[tool.ty.src]
|
|
110
|
+
include = ["mostlyai"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_encoding_types/language/__init__.py
RENAMED
|
File without changes
|
{mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_encoding_types/language/text.py
RENAMED
|
File without changes
|
{mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_encoding_types/tabular/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_language/engine/__init__.py
RENAMED
|
File without changes
|
{mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_language/tokenizer_utils.py
RENAMED
|
File without changes
|
{mostlyai_engine-2.7.3 → mostlyai_engine-2.8.0}/mostlyai/engine/_language/xgrammar_hf_logits.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|