Matthew Ford commited on
Commit
b5c68f0
·
1 Parent(s): c558e9f

feat: full molequles multi-tag target space (575-dim ablation arm)

Browse files

Mine descriptive tokens from odor_descriptions monograph text (arctander/
goodscents/tgsc) in material_profiles. 575 tags at >=10 occurrences; 1187
CAS with nonzero multi-hot vectors (~10 tags/CAS). Additional target space
per the all-tags directive; 138-Pyrfume basis retained for the primary arm.


Former-commit-id: c0292fe4fd2126c4272ccf2d2548be0d75ff5b61
Former-commit-id: fdbdca6c20417e96065fc1471b45bcab982774f8

data/molequles_tag_matrix.json ADDED
The diff for this file is too large to render. See raw diff
 
data/molequles_tag_vocab.json ADDED
@@ -0,0 +1,580 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "dimension": 575,
3
+ "tags": [
4
+ "about",
5
+ "abs",
6
+ "absolute",
7
+ "according",
8
+ "acetal",
9
+ "acetate",
10
+ "acid",
11
+ "acidic",
12
+ "alcoholic",
13
+ "aldehydic",
14
+ "all",
15
+ "allspice",
16
+ "almond",
17
+ "alpha",
18
+ "alpha-pinene",
19
+ "although",
20
+ "always",
21
+ "amber",
22
+ "ambergris",
23
+ "ambery",
24
+ "ambrette",
25
+ "amounts",
26
+ "amyl",
27
+ "animal",
28
+ "animalic",
29
+ "anise",
30
+ "anisic",
31
+ "any",
32
+ "apc",
33
+ "apple",
34
+ "apple-like",
35
+ "apricot",
36
+ "aquatic",
37
+ "arctander",
38
+ "aroma",
39
+ "aromatic",
40
+ "aromatics",
41
+ "ascc",
42
+ "attractive",
43
+ "author",
44
+ "available",
45
+ "avoid",
46
+ "background",
47
+ "bacon",
48
+ "balsam",
49
+ "balsamic",
50
+ "balsams",
51
+ "banana",
52
+ "base",
53
+ "bases",
54
+ "basil",
55
+ "because",
56
+ "becomes",
57
+ "been",
58
+ "being",
59
+ "below",
60
+ "benzaldehyde",
61
+ "benzoin",
62
+ "benzyl",
63
+ "bergamot",
64
+ "berry",
65
+ "biobased",
66
+ "bitter",
67
+ "black",
68
+ "blackcurrant",
69
+ "bland",
70
+ "bleach",
71
+ "blends",
72
+ "blends-well-with",
73
+ "blossom",
74
+ "blueberry",
75
+ "body",
76
+ "bois",
77
+ "brandy",
78
+ "bready",
79
+ "brings",
80
+ "brown",
81
+ "bud",
82
+ "butter",
83
+ "buttery",
84
+ "butyrate",
85
+ "camphor",
86
+ "camphoraceous",
87
+ "camphoreous",
88
+ "can",
89
+ "candy",
90
+ "caramel",
91
+ "caramellic",
92
+ "care",
93
+ "carnation",
94
+ "cashmeran",
95
+ "cassis",
96
+ "category",
97
+ "cedar",
98
+ "cedarwood",
99
+ "celery",
100
+ "certain",
101
+ "characteristic",
102
+ "cheese",
103
+ "cheesy",
104
+ "chemicals",
105
+ "cherry",
106
+ "chocolate",
107
+ "choking",
108
+ "cinnamate",
109
+ "cinnamic",
110
+ "cinnamon",
111
+ "cinnamyl",
112
+ "cis-",
113
+ "citral",
114
+ "citric",
115
+ "citronella",
116
+ "citronellol",
117
+ "citrus",
118
+ "citrusy",
119
+ "clary",
120
+ "classified",
121
+ "clean",
122
+ "cleaner",
123
+ "clothing",
124
+ "clove",
125
+ "clove-like",
126
+ "clover",
127
+ "cocoa",
128
+ "coconut",
129
+ "coffee",
130
+ "cognac",
131
+ "colorless",
132
+ "combination",
133
+ "commercial",
134
+ "common",
135
+ "company",
136
+ "complex",
137
+ "complexes",
138
+ "composition",
139
+ "compositions",
140
+ "concentration",
141
+ "considered",
142
+ "container",
143
+ "cool",
144
+ "cooling",
145
+ "coriander",
146
+ "corporation",
147
+ "cortex",
148
+ "cosmetic",
149
+ "cost",
150
+ "coumarin",
151
+ "coumarinic",
152
+ "creamy",
153
+ "cucumber",
154
+ "cut",
155
+ "cyclamen",
156
+ "cypress",
157
+ "dairy",
158
+ "damascone",
159
+ "data",
160
+ "deep",
161
+ "delicate",
162
+ "described",
163
+ "description",
164
+ "descriptions",
165
+ "desirable",
166
+ "difference",
167
+ "different",
168
+ "diffusion",
169
+ "diffusive",
170
+ "diluted",
171
+ "dimethyl",
172
+ "dipropylene",
173
+ "does",
174
+ "down",
175
+ "dried",
176
+ "dry",
177
+ "dry-woody",
178
+ "earthy",
179
+ "ecsa",
180
+ "effect",
181
+ "effective",
182
+ "effects",
183
+ "elegant",
184
+ "environment",
185
+ "essence",
186
+ "essential",
187
+ "esters",
188
+ "etc",
189
+ "ether",
190
+ "ethereal",
191
+ "ethereal-fruity",
192
+ "etherial",
193
+ "ethyl",
194
+ "eucalyptus",
195
+ "eugenol",
196
+ "even",
197
+ "exceptional",
198
+ "experimental",
199
+ "extreme",
200
+ "fabric",
201
+ "facets",
202
+ "fact",
203
+ "fatty",
204
+ "fecal",
205
+ "fermented",
206
+ "find",
207
+ "finds",
208
+ "fine",
209
+ "firmenich",
210
+ "fishy",
211
+ "fixative",
212
+ "fixer",
213
+ "flavor",
214
+ "floral",
215
+ "floral-fruity",
216
+ "floral-rose",
217
+ "floreal",
218
+ "flower",
219
+ "flowers",
220
+ "foliage",
221
+ "found",
222
+ "free",
223
+ "fresh",
224
+ "fresh-green",
225
+ "fresher",
226
+ "freshness",
227
+ "fruit",
228
+ "fruits",
229
+ "fruity",
230
+ "fruity-floral",
231
+ "fruity-green",
232
+ "fruity-winey",
233
+ "fusel",
234
+ "galaxolide",
235
+ "galbanum",
236
+ "gardenia",
237
+ "garlic",
238
+ "gassy",
239
+ "geraniol",
240
+ "geranium",
241
+ "givaudan",
242
+ "give",
243
+ "gives",
244
+ "glycol",
245
+ "grade",
246
+ "grades",
247
+ "grape",
248
+ "grass",
249
+ "grassy",
250
+ "great",
251
+ "green",
252
+ "green-floral",
253
+ "green-fruity",
254
+ "gum",
255
+ "gums",
256
+ "harsh",
257
+ "having",
258
+ "hawthorn",
259
+ "hay",
260
+ "hazard",
261
+ "heavy",
262
+ "herbaceous",
263
+ "herbal",
264
+ "hexyl",
265
+ "high",
266
+ "higher",
267
+ "home",
268
+ "honey",
269
+ "honey-like",
270
+ "however",
271
+ "hyacinth",
272
+ "iff",
273
+ "ike",
274
+ "impression",
275
+ "impurities",
276
+ "incense",
277
+ "including",
278
+ "indukern",
279
+ "information",
280
+ "ingredient",
281
+ "intense",
282
+ "interesting",
283
+ "international",
284
+ "ionone",
285
+ "isomers",
286
+ "jam",
287
+ "jammy",
288
+ "jasmin",
289
+ "jasmine",
290
+ "juicy",
291
+ "keep",
292
+ "kephalis",
293
+ "ketone",
294
+ "ketonic",
295
+ "known",
296
+ "kosher",
297
+ "labdanum",
298
+ "laboratory",
299
+ "lactonic",
300
+ "lasting",
301
+ "lavender",
302
+ "leaf",
303
+ "leafy",
304
+ "leather",
305
+ "leathery",
306
+ "lemon",
307
+ "lemony",
308
+ "licorice",
309
+ "lift",
310
+ "lifting",
311
+ "light",
312
+ "like",
313
+ "lilac",
314
+ "lime",
315
+ "linalool",
316
+ "linalyl",
317
+ "liquid",
318
+ "little",
319
+ "long",
320
+ "lotion",
321
+ "low",
322
+ "lower",
323
+ "luebke",
324
+ "macrocyclic",
325
+ "makes",
326
+ "malty",
327
+ "mandarin",
328
+ "many",
329
+ "materials",
330
+ "meaty",
331
+ "medical",
332
+ "medicinal",
333
+ "mellow",
334
+ "melon",
335
+ "mentholic",
336
+ "metallic",
337
+ "methyl",
338
+ "mild",
339
+ "milder",
340
+ "milky",
341
+ "mimosa",
342
+ "mint",
343
+ "minty",
344
+ "moellhausen",
345
+ "monoterpenes",
346
+ "mossy",
347
+ "most",
348
+ "muguet",
349
+ "mushroom",
350
+ "musk",
351
+ "musks",
352
+ "musky",
353
+ "must",
354
+ "musty",
355
+ "naphthyl",
356
+ "narcissus",
357
+ "nat",
358
+ "neroli",
359
+ "new",
360
+ "nuances",
361
+ "nut",
362
+ "nut-like",
363
+ "nutmeg",
364
+ "nutty",
365
+ "oakmoss",
366
+ "odorless",
367
+ "odors",
368
+ "odour",
369
+ "offers",
370
+ "often",
371
+ "oils",
372
+ "old",
373
+ "olibanum",
374
+ "one",
375
+ "onion",
376
+ "orange",
377
+ "orangeflower",
378
+ "oriental",
379
+ "origin",
380
+ "orris",
381
+ "out",
382
+ "ozone",
383
+ "patchouli",
384
+ "peach",
385
+ "peach-like",
386
+ "pear",
387
+ "peculiar",
388
+ "peel",
389
+ "pell",
390
+ "penetrating",
391
+ "peppermint",
392
+ "peppery",
393
+ "perceptible",
394
+ "perfumer",
395
+ "perfumers",
396
+ "perfumersworld",
397
+ "perfumery",
398
+ "persistent",
399
+ "personal",
400
+ "petal",
401
+ "petitgrain",
402
+ "phenolic",
403
+ "phenyl",
404
+ "picture",
405
+ "pine",
406
+ "pineapple",
407
+ "pineapple-like",
408
+ "pinene",
409
+ "piney",
410
+ "plastic",
411
+ "plum",
412
+ "powder",
413
+ "powdery",
414
+ "power",
415
+ "precautionary",
416
+ "prodasynth",
417
+ "produced",
418
+ "products",
419
+ "profile",
420
+ "pronounced",
421
+ "proper",
422
+ "provides",
423
+ "pungent",
424
+ "pure",
425
+ "purified",
426
+ "purity",
427
+ "quality",
428
+ "quite",
429
+ "rancid",
430
+ "raspberry",
431
+ "recommended",
432
+ "red",
433
+ "refined",
434
+ "refreshing",
435
+ "release",
436
+ "reminiscent",
437
+ "repulsive",
438
+ "res",
439
+ "research",
440
+ "resemblance",
441
+ "resembling",
442
+ "resinous",
443
+ "rhubarb",
444
+ "rich",
445
+ "rind",
446
+ "ripe",
447
+ "roasted",
448
+ "robertet",
449
+ "roll-on",
450
+ "root",
451
+ "rose",
452
+ "rum",
453
+ "sage",
454
+ "salicylate",
455
+ "sandalwood",
456
+ "sas",
457
+ "savory",
458
+ "scent",
459
+ "sds",
460
+ "see",
461
+ "seed",
462
+ "seedy",
463
+ "shampoo",
464
+ "sharp",
465
+ "show",
466
+ "similar",
467
+ "since",
468
+ "skin",
469
+ "slight",
470
+ "smell",
471
+ "smoky",
472
+ "smooth",
473
+ "soap",
474
+ "soapy",
475
+ "soft",
476
+ "softer",
477
+ "soluble",
478
+ "solvent",
479
+ "sometimes",
480
+ "somewhat",
481
+ "sour",
482
+ "spearmint",
483
+ "special",
484
+ "spice",
485
+ "spicy",
486
+ "srs",
487
+ "stable",
488
+ "strawberry",
489
+ "strength",
490
+ "substantive",
491
+ "subtle",
492
+ "suggested",
493
+ "suggestive",
494
+ "suitable",
495
+ "sulfurous",
496
+ "super",
497
+ "suppliers",
498
+ "sweet",
499
+ "sweet-balsamic",
500
+ "sweet-floral",
501
+ "sweet-fruity",
502
+ "sweet-herbaceous",
503
+ "sweeter",
504
+ "sweetness",
505
+ "symrise",
506
+ "takasago",
507
+ "taytonn",
508
+ "tea",
509
+ "tea-like",
510
+ "tenacious",
511
+ "terpene",
512
+ "terpenic",
513
+ "terpineol",
514
+ "terpy",
515
+ "there",
516
+ "title",
517
+ "tobacco",
518
+ "tobacco-like",
519
+ "tone",
520
+ "tonka",
521
+ "top",
522
+ "topnote",
523
+ "topnotes",
524
+ "toxicity",
525
+ "trace",
526
+ "traces",
527
+ "tropical",
528
+ "true",
529
+ "tuberose",
530
+ "two",
531
+ "type",
532
+ "types",
533
+ "typical",
534
+ "undiluted",
535
+ "unique",
536
+ "unpleasant",
537
+ "unripe",
538
+ "upon",
539
+ "useful",
540
+ "uses",
541
+ "value",
542
+ "vanilla",
543
+ "vanilla-like",
544
+ "vanillin",
545
+ "vegetable",
546
+ "vegetative",
547
+ "velvety",
548
+ "versatile",
549
+ "vetiver",
550
+ "vigon",
551
+ "violet",
552
+ "volatile",
553
+ "wall",
554
+ "warm",
555
+ "warm-herbaceous",
556
+ "warm-spicy",
557
+ "warm-woody",
558
+ "water",
559
+ "watery",
560
+ "waxy",
561
+ "weedy",
562
+ "well",
563
+ "when",
564
+ "where",
565
+ "while",
566
+ "who",
567
+ "will",
568
+ "william",
569
+ "wine",
570
+ "winey",
571
+ "wintergreen",
572
+ "without",
573
+ "wood",
574
+ "woody",
575
+ "word",
576
+ "yeasty",
577
+ "yet",
578
+ "ylang"
579
+ ]
580
+ }
scripts/build_molequles_tag_space.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Build the full molequles multi-tag vocabulary + per-CAS multi-label target matrix.
3
+
4
+ Directive (2026-07-17): train on ALL molequles tags, not just the curated
5
+ 138-Pyrfume categories — the richer tag space may be more insightful.
6
+
7
+ This mines descriptive tokens from the structured odor_descriptions monograph
8
+ text (arctander / goodscents / tgsc) in material_profiles, keeps tags with
9
+ >= --min-count occurrences, and emits:
10
+ - data/molequles_tag_vocab.json : ordered tag list (the target basis)
11
+ - data/molequles_tag_matrix.json : cas -> multi-hot vector over that basis
12
+ This is an additional/ablation target space; the 138-Pyrfume basis is retained.
13
+ """
14
+ from __future__ import annotations
15
+
16
+ import argparse
17
+ import json
18
+ import re
19
+ from collections import Counter
20
+ from pathlib import Path
21
+
22
+ STOP = set(
23
+ "the a an and or of to in with is it as but not that this for has have be are was were on at by from very slightly powerful moderate strong weak odor note notes character tenacity excellent good if could would should more much use used using also some overall almost may which than into its it's over under such other these those dilution perfumes perfume fragrance fragrances material product compound chemical ester alcohol aldehyde oil natural synthetic less rather poor faint pleasant considerable nuance undertone undertones rosy".split()
24
+ )
25
+
26
+
27
+ def harvest(path: Path) -> tuple[Counter, dict[str, Counter]]:
28
+ tag_count: Counter = Counter()
29
+ cas_tags: dict[str, Counter] = {}
30
+ with path.open() as fh:
31
+ for line in fh:
32
+ try:
33
+ r = json.loads(line)
34
+ except Exception:
35
+ continue
36
+ cas = r.get("cas")
37
+ od = r.get("odor_descriptions")
38
+ if not cas or not isinstance(od, list):
39
+ continue
40
+ local: Counter = cas_tags.setdefault(cas, Counter())
41
+ for rec in od:
42
+ txt = rec.get("text", "") if isinstance(rec, dict) else str(rec)
43
+ for tok in re.findall(r"[a-z][a-z-]+", txt.lower()):
44
+ if tok not in STOP and len(tok) > 2 and not tok.endswith("ly"):
45
+ tag_count[tok] += 1
46
+ local[tok] += 1
47
+ return tag_count, cas_tags
48
+
49
+
50
+ def main() -> None:
51
+ ap = argparse.ArgumentParser()
52
+ ap.add_argument("--profiles", default="data/material_profiles_v11_6.jsonl")
53
+ ap.add_argument("--min-count", type=int, default=10)
54
+ ap.add_argument("--vocab-out", default="data/molequles_tag_vocab.json")
55
+ ap.add_argument("--matrix-out", default="data/molequles_tag_matrix.json")
56
+ args = ap.parse_args()
57
+
58
+ tag_count, cas_tags = harvest(Path(args.profiles))
59
+ vocab = sorted(t for t, c in tag_count.items() if c >= args.min_count)
60
+ idx = {t: i for i, t in enumerate(vocab)}
61
+
62
+ matrix: dict[str, list[int]] = {}
63
+ for cas, local in cas_tags.items():
64
+ vec = [0] * len(vocab)
65
+ any_set = False
66
+ for tok, _ in local.items():
67
+ if tok in idx:
68
+ vec[idx[tok]] = 1
69
+ any_set = True
70
+ if any_set:
71
+ matrix[cas] = vec
72
+
73
+ Path(args.vocab_out).write_text(json.dumps({"dimension": len(vocab), "tags": vocab}, indent=1))
74
+ Path(args.matrix_out).write_text(json.dumps(matrix))
75
+ print(f"vocab dimension: {len(vocab)} (min_count={args.min_count})")
76
+ print(f"CAS with nonzero multi-tag vector: {len(matrix)}")
77
+ density = sum(sum(v) for v in matrix.values()) / max(len(matrix), 1)
78
+ print(f"avg tags per CAS: {density:.1f}")
79
+
80
+
81
+ if __name__ == "__main__":
82
+ main()