Matthew Ford commited on
Commit ·
1491c5b
1
Parent(s): 3458215
v11 material profile table: available fields, N=557, deferred enrichments
Browse filesFormer-commit-id: 84d879ab6c3b33be426935a8fd0afe574f4fe180
Former-commit-id: 21d5199571ff0505638413c33543f33b7647d7fa
- data/material_profiles_v11.jsonl +0 -0
- scripts/pimt_v11_build.py +825 -0
data/material_profiles_v11.jsonl
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
scripts/pimt_v11_build.py
ADDED
|
@@ -0,0 +1,825 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
from __future__ import annotations
|
| 3 |
+
|
| 4 |
+
import argparse
|
| 5 |
+
import json
|
| 6 |
+
import math
|
| 7 |
+
import sys
|
| 8 |
+
import time
|
| 9 |
+
from collections import Counter, defaultdict
|
| 10 |
+
from pathlib import Path
|
| 11 |
+
from typing import Any
|
| 12 |
+
|
| 13 |
+
import joblib
|
| 14 |
+
import numpy as np
|
| 15 |
+
|
| 16 |
+
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
| 17 |
+
import train_substantivity as train # noqa: E402
|
| 18 |
+
|
| 19 |
+
from pino.materials import MATERIALS # noqa: E402
|
| 20 |
+
from pino.substitution_v11 import ( # noqa: E402
|
| 21 |
+
PIMT_V11,
|
| 22 |
+
descriptor_distribution_from_codes,
|
| 23 |
+
evaluate_formula,
|
| 24 |
+
evaluate_material,
|
| 25 |
+
evaluate_retriever,
|
| 26 |
+
load_jsonl,
|
| 27 |
+
normalize_name,
|
| 28 |
+
substitute,
|
| 29 |
+
write_jsonl,
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
ROOT = Path(__file__).resolve().parents[1]
|
| 34 |
+
DATA = ROOT / "data"
|
| 35 |
+
ARTIFACTS = ROOT / "artifacts"
|
| 36 |
+
V10_MODEL = ROOT / "models/pimt_v10_line_drawn/pimt_v10_line_drawn_substantivity_gbm.joblib"
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
SUBSTITUTION_EVAL_ROWS: list[dict[str, Any]] = [
|
| 40 |
+
{
|
| 41 |
+
"pair_id": "v11_sub_0001",
|
| 42 |
+
"target": "Oakmoss absolute",
|
| 43 |
+
"target_cas": "90028-68-5",
|
| 44 |
+
"substitute": "Fauxmoss",
|
| 45 |
+
"substitute_cas": None,
|
| 46 |
+
"grade": "acceptable",
|
| 47 |
+
"suggested_percentage_adjustment": None,
|
| 48 |
+
"mode": "regulatory_match",
|
| 49 |
+
"source_name": "Fraterworks Fauxmoss product note",
|
| 50 |
+
"source_url": "https://fraterworks.com/products/fauxmoss",
|
| 51 |
+
"provenance_flag": "authoritative-supplier-page",
|
| 52 |
+
"evidence": "Direct replacement for restricted oakmoss absolute; unrestricted oakmoss replacement.",
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"pair_id": "v11_sub_0002",
|
| 56 |
+
"target": "Oakmoss absolute",
|
| 57 |
+
"target_cas": "90028-68-5",
|
| 58 |
+
"substitute": "Veramoss / Evernyl",
|
| 59 |
+
"substitute_cas": "4707-47-5",
|
| 60 |
+
"grade": "partial",
|
| 61 |
+
"suggested_percentage_adjustment": None,
|
| 62 |
+
"mode": "regulatory_match",
|
| 63 |
+
"source_name": "Fraterworks Veramoss product note",
|
| 64 |
+
"source_url": "https://fraterworks.com/products/veramoss",
|
| 65 |
+
"provenance_flag": "authoritative-supplier-page",
|
| 66 |
+
"evidence": "IFRA-compliant replacement for oakmoss, providing mossy character and fixative properties.",
|
| 67 |
+
},
|
| 68 |
+
{
|
| 69 |
+
"pair_id": "v11_sub_0003",
|
| 70 |
+
"target": "Hedione",
|
| 71 |
+
"target_cas": "24851-98-7",
|
| 72 |
+
"substitute": "Paradise Molecule",
|
| 73 |
+
"substitute_cas": None,
|
| 74 |
+
"grade": "functional-only",
|
| 75 |
+
"suggested_percentage_adjustment": "one-for-one documented by supplier",
|
| 76 |
+
"mode": "function_match",
|
| 77 |
+
"source_name": "Fraterworks Paradise Molecule product note",
|
| 78 |
+
"source_url": "https://fraterworks.com/products/paradise-molecule",
|
| 79 |
+
"provenance_flag": "authoritative-supplier-page",
|
| 80 |
+
"evidence": "One for one replacer for Hedione and Hedione High Cis; diffusion/radiance role.",
|
| 81 |
+
},
|
| 82 |
+
{
|
| 83 |
+
"pair_id": "v11_sub_0004",
|
| 84 |
+
"target": "Hedione High Cis",
|
| 85 |
+
"target_cas": "24851-98-7",
|
| 86 |
+
"substitute": "Paradise Molecule",
|
| 87 |
+
"substitute_cas": None,
|
| 88 |
+
"grade": "functional-only",
|
| 89 |
+
"suggested_percentage_adjustment": "one-for-one documented by supplier",
|
| 90 |
+
"mode": "function_match",
|
| 91 |
+
"source_name": "Fraterworks Paradise Molecule product note",
|
| 92 |
+
"source_url": "https://fraterworks.com/products/paradise-molecule",
|
| 93 |
+
"provenance_flag": "authoritative-supplier-page",
|
| 94 |
+
"evidence": "One for one replacer for Hedione and Hedione High Cis.",
|
| 95 |
+
},
|
| 96 |
+
{
|
| 97 |
+
"pair_id": "v11_sub_0005",
|
| 98 |
+
"target": "Vanillin",
|
| 99 |
+
"target_cas": "121-33-5",
|
| 100 |
+
"substitute": "Isobutavan",
|
| 101 |
+
"substitute_cas": "20665-85-4",
|
| 102 |
+
"grade": "functional-only",
|
| 103 |
+
"suggested_percentage_adjustment": None,
|
| 104 |
+
"mode": "function_match",
|
| 105 |
+
"source_name": "Fraterworks Isobutavan product note",
|
| 106 |
+
"source_url": "https://fraterworks.com/products/isobutavan",
|
| 107 |
+
"provenance_flag": "authoritative-supplier-page",
|
| 108 |
+
"evidence": "Non-discolouring alternative to vanillin for soap; vanillic gourmand profile.",
|
| 109 |
+
},
|
| 110 |
+
{
|
| 111 |
+
"pair_id": "v11_sub_0006",
|
| 112 |
+
"target": "Bacdanol",
|
| 113 |
+
"target_cas": "28219-61-6",
|
| 114 |
+
"substitute": "Dartanol",
|
| 115 |
+
"substitute_cas": "28219-61-6",
|
| 116 |
+
"grade": "acceptable",
|
| 117 |
+
"suggested_percentage_adjustment": "one-for-one documented by supplier",
|
| 118 |
+
"mode": "function_match",
|
| 119 |
+
"source_name": "Fraterworks Dartanol product note",
|
| 120 |
+
"source_url": "https://fraterworks.com/products/dartanol",
|
| 121 |
+
"provenance_flag": "authoritative-supplier-page",
|
| 122 |
+
"evidence": "Same chemical/laevo form; can be used one for one in place of Bacdanol.",
|
| 123 |
+
},
|
| 124 |
+
{
|
| 125 |
+
"pair_id": "v11_sub_0007",
|
| 126 |
+
"target": "Natural sandalwood",
|
| 127 |
+
"target_cas": "8006-87-9",
|
| 128 |
+
"substitute": "Dartanol",
|
| 129 |
+
"substitute_cas": "28219-61-6",
|
| 130 |
+
"grade": "partial",
|
| 131 |
+
"suggested_percentage_adjustment": None,
|
| 132 |
+
"mode": "odor_match",
|
| 133 |
+
"source_name": "Fraterworks Dartanol product note",
|
| 134 |
+
"source_url": "https://fraterworks.com/products/dartanol",
|
| 135 |
+
"provenance_flag": "authoritative-supplier-page",
|
| 136 |
+
"evidence": "One of the finest substitutes for natural sandalwood in chemical form.",
|
| 137 |
+
},
|
| 138 |
+
{
|
| 139 |
+
"pair_id": "v11_sub_0008",
|
| 140 |
+
"target": "Lilial",
|
| 141 |
+
"target_cas": "80-54-6",
|
| 142 |
+
"substitute": "Lilyflore",
|
| 143 |
+
"substitute_cas": "285977-85-7",
|
| 144 |
+
"grade": "functional-only",
|
| 145 |
+
"suggested_percentage_adjustment": None,
|
| 146 |
+
"mode": "regulatory_match",
|
| 147 |
+
"source_name": "Fraterworks Lilyflore product note",
|
| 148 |
+
"source_url": "https://fraterworks.com/products/lilyflore",
|
| 149 |
+
"provenance_flag": "authoritative-supplier-page",
|
| 150 |
+
"evidence": "Alternative to virtually prohibited Lilial and Lyral; muguet volume/structure.",
|
| 151 |
+
},
|
| 152 |
+
{
|
| 153 |
+
"pair_id": "v11_sub_0009",
|
| 154 |
+
"target": "Lyral",
|
| 155 |
+
"target_cas": "31906-04-4",
|
| 156 |
+
"substitute": "Lilyflore",
|
| 157 |
+
"substitute_cas": "285977-85-7",
|
| 158 |
+
"grade": "functional-only",
|
| 159 |
+
"suggested_percentage_adjustment": None,
|
| 160 |
+
"mode": "regulatory_match",
|
| 161 |
+
"source_name": "Fraterworks Lilyflore product note",
|
| 162 |
+
"source_url": "https://fraterworks.com/products/lilyflore",
|
| 163 |
+
"provenance_flag": "authoritative-supplier-page",
|
| 164 |
+
"evidence": "Alternative to virtually prohibited Lilial and Lyral.",
|
| 165 |
+
},
|
| 166 |
+
{
|
| 167 |
+
"pair_id": "v11_sub_0010",
|
| 168 |
+
"target": "Linalool",
|
| 169 |
+
"target_cas": "78-70-6",
|
| 170 |
+
"substitute": "Ethyl Linalool",
|
| 171 |
+
"substitute_cas": "10339-55-6",
|
| 172 |
+
"grade": "partial",
|
| 173 |
+
"suggested_percentage_adjustment": None,
|
| 174 |
+
"mode": "odor_match",
|
| 175 |
+
"source_name": "Fraterworks Ethyl Linalool product note",
|
| 176 |
+
"source_url": "https://fraterworks.com/products/ethyl-linalool",
|
| 177 |
+
"provenance_flag": "authoritative-supplier-page",
|
| 178 |
+
"evidence": "Softer alternative to Linalool with bergamot/lavender floral facets.",
|
| 179 |
+
},
|
| 180 |
+
{
|
| 181 |
+
"pair_id": "v11_sub_0011",
|
| 182 |
+
"target": "Indole",
|
| 183 |
+
"target_cas": "120-72-9",
|
| 184 |
+
"substitute": "Indofleur ND",
|
| 185 |
+
"substitute_cas": None,
|
| 186 |
+
"grade": "functional-only",
|
| 187 |
+
"suggested_percentage_adjustment": None,
|
| 188 |
+
"mode": "regulatory_match",
|
| 189 |
+
"source_name": "PerfumersWorld perfume supplies catalogue",
|
| 190 |
+
"source_url": "https://www.perfumersworld.com/perfume-supplies.php",
|
| 191 |
+
"provenance_flag": "authoritative-supplier-catalogue",
|
| 192 |
+
"evidence": "Replacement for Indol in most fragrance types with much lower discolouration.",
|
| 193 |
+
},
|
| 194 |
+
{
|
| 195 |
+
"pair_id": "v11_sub_0012",
|
| 196 |
+
"target": "Indole",
|
| 197 |
+
"target_cas": "120-72-9",
|
| 198 |
+
"substitute": "Indolene ND Replacer",
|
| 199 |
+
"substitute_cas": None,
|
| 200 |
+
"grade": "functional-only",
|
| 201 |
+
"suggested_percentage_adjustment": None,
|
| 202 |
+
"mode": "regulatory_match",
|
| 203 |
+
"source_name": "PerfumersWorld perfume supplies catalogue",
|
| 204 |
+
"source_url": "https://www.perfumersworld.com/perfume-supplies.php",
|
| 205 |
+
"provenance_flag": "authoritative-supplier-catalogue",
|
| 206 |
+
"evidence": "Low discolouring option where an Indol or Indolene note is required.",
|
| 207 |
+
},
|
| 208 |
+
{
|
| 209 |
+
"pair_id": "v11_sub_0013",
|
| 210 |
+
"target": "Lyral / HMPCC",
|
| 211 |
+
"target_cas": "31906-04-4",
|
| 212 |
+
"substitute": "Lilyreal ND",
|
| 213 |
+
"substitute_cas": None,
|
| 214 |
+
"grade": "functional-only",
|
| 215 |
+
"suggested_percentage_adjustment": None,
|
| 216 |
+
"mode": "regulatory_match",
|
| 217 |
+
"source_name": "PerfumersWorld perfume supplies catalogue",
|
| 218 |
+
"source_url": "https://www.perfumersworld.com/perfume-supplies.php",
|
| 219 |
+
"provenance_flag": "authoritative-supplier-catalogue",
|
| 220 |
+
"evidence": "IFRA-51 and EU compliant base used to replace HMPCC / Lyral.",
|
| 221 |
+
},
|
| 222 |
+
{
|
| 223 |
+
"pair_id": "v11_sub_0014",
|
| 224 |
+
"target": "Musk xylene",
|
| 225 |
+
"target_cas": "81-15-2",
|
| 226 |
+
"substitute": "Musk Xylol Replacer",
|
| 227 |
+
"substitute_cas": None,
|
| 228 |
+
"grade": "functional-only",
|
| 229 |
+
"suggested_percentage_adjustment": None,
|
| 230 |
+
"mode": "regulatory_match",
|
| 231 |
+
"source_name": "PerfumersWorld perfume supplies catalogue",
|
| 232 |
+
"source_url": "https://www.perfumersworld.com/perfume-supplies.php",
|
| 233 |
+
"provenance_flag": "authoritative-supplier-catalogue",
|
| 234 |
+
"evidence": "Nitro musk base to replace Musk Xylol; contains IFRA-compliant Musk Ketone.",
|
| 235 |
+
},
|
| 236 |
+
{
|
| 237 |
+
"pair_id": "v11_sub_0015",
|
| 238 |
+
"target": "Isoeugenol",
|
| 239 |
+
"target_cas": "97-54-1",
|
| 240 |
+
"substitute": "Isoeugenol Replacer",
|
| 241 |
+
"substitute_cas": None,
|
| 242 |
+
"grade": "functional-only",
|
| 243 |
+
"suggested_percentage_adjustment": None,
|
| 244 |
+
"mode": "regulatory_match",
|
| 245 |
+
"source_name": "Fraterworks Isoeugenol Replacer product note",
|
| 246 |
+
"source_url": "https://fraterworks.com/products/isoeugenol-repl-296766",
|
| 247 |
+
"provenance_flag": "authoritative-supplier-page",
|
| 248 |
+
"evidence": "Supplier sells a dedicated Isoeugenol Replacer and contrasts it with less true replacers.",
|
| 249 |
+
},
|
| 250 |
+
{
|
| 251 |
+
"pair_id": "v11_sub_0016",
|
| 252 |
+
"target": "Tolu balsam",
|
| 253 |
+
"target_cas": "9000-64-0",
|
| 254 |
+
"substitute": "Tolu Absolute Replacer 50%",
|
| 255 |
+
"substitute_cas": None,
|
| 256 |
+
"grade": "functional-only",
|
| 257 |
+
"suggested_percentage_adjustment": None,
|
| 258 |
+
"mode": "function_match",
|
| 259 |
+
"source_name": "Fraterworks Tolu Absolute Replacer product note",
|
| 260 |
+
"source_url": "https://fraterworks.com/products/tolu-replacer-decol",
|
| 261 |
+
"provenance_flag": "authoritative-supplier-page",
|
| 262 |
+
"evidence": "Dedicated Tolu replacer base; supplier recommends purchase even when natural products are usable.",
|
| 263 |
+
},
|
| 264 |
+
{
|
| 265 |
+
"pair_id": "v11_sub_0017",
|
| 266 |
+
"target": "Galaxolide",
|
| 267 |
+
"target_cas": "1222-05-5",
|
| 268 |
+
"substitute": "Ethylene brassylate",
|
| 269 |
+
"substitute_cas": "105-95-3",
|
| 270 |
+
"grade": "partial",
|
| 271 |
+
"suggested_percentage_adjustment": None,
|
| 272 |
+
"mode": "function_match",
|
| 273 |
+
"source_name": "Poucher tier profile and local material matrix",
|
| 274 |
+
"source_url": "local:data/literature_profiles_poucher_cleaned_v8.jsonl",
|
| 275 |
+
"provenance_flag": "local-authoritative-literature-derived",
|
| 276 |
+
"evidence": "Clean musk substitution family; held as partial eval because not source-documented as one-for-one.",
|
| 277 |
+
},
|
| 278 |
+
{
|
| 279 |
+
"pair_id": "v11_sub_0018",
|
| 280 |
+
"target": "Ambrettolide",
|
| 281 |
+
"target_cas": "142-62-3",
|
| 282 |
+
"substitute": "Habanolide",
|
| 283 |
+
"substitute_cas": "111-79-5",
|
| 284 |
+
"grade": "partial",
|
| 285 |
+
"suggested_percentage_adjustment": None,
|
| 286 |
+
"mode": "function_match",
|
| 287 |
+
"source_name": "Local material matrix musk family",
|
| 288 |
+
"source_url": "local:data/aroma_chemicals.jsonl",
|
| 289 |
+
"provenance_flag": "local-material-family-control",
|
| 290 |
+
"evidence": "Macrocyclic musk family control pair for evaluator, not used for training.",
|
| 291 |
+
},
|
| 292 |
+
{
|
| 293 |
+
"pair_id": "v11_sub_0019",
|
| 294 |
+
"target": "Geraniol",
|
| 295 |
+
"target_cas": "106-24-1",
|
| 296 |
+
"substitute": "Nerol",
|
| 297 |
+
"substitute_cas": "106-25-2",
|
| 298 |
+
"grade": "odor-only",
|
| 299 |
+
"suggested_percentage_adjustment": None,
|
| 300 |
+
"mode": "odor_match",
|
| 301 |
+
"source_name": "Fraterworks Nerol product note",
|
| 302 |
+
"source_url": "https://fraterworks.com/products/nerol",
|
| 303 |
+
"provenance_flag": "authoritative-supplier-page",
|
| 304 |
+
"evidence": "Nerol listed among rose alcohols beside citronellol, geraniol, and phenyl ethyl alcohol.",
|
| 305 |
+
},
|
| 306 |
+
{
|
| 307 |
+
"pair_id": "v11_sub_0020",
|
| 308 |
+
"target": "Citral",
|
| 309 |
+
"target_cas": "5392-40-5",
|
| 310 |
+
"substitute": "Neral",
|
| 311 |
+
"substitute_cas": "106-26-3",
|
| 312 |
+
"grade": "partial",
|
| 313 |
+
"suggested_percentage_adjustment": None,
|
| 314 |
+
"mode": "odor_match",
|
| 315 |
+
"source_name": "Local material matrix isomer control",
|
| 316 |
+
"source_url": "local:data/aroma_chemicals.jsonl",
|
| 317 |
+
"provenance_flag": "local-material-family-control",
|
| 318 |
+
"evidence": "Citral/neral isomer-family control pair for evaluator, not used for training.",
|
| 319 |
+
},
|
| 320 |
+
{
|
| 321 |
+
"pair_id": "v11_sub_0021",
|
| 322 |
+
"target": "Iso E Super",
|
| 323 |
+
"target_cas": "54452-50-3",
|
| 324 |
+
"substitute": "Timbersilk",
|
| 325 |
+
"substitute_cas": "68039-33-4",
|
| 326 |
+
"grade": "partial",
|
| 327 |
+
"suggested_percentage_adjustment": None,
|
| 328 |
+
"mode": "function_match",
|
| 329 |
+
"source_name": "Local material resolver trade-name family",
|
| 330 |
+
"source_url": "local:src/pino/materials.py",
|
| 331 |
+
"provenance_flag": "local-trade-name-control",
|
| 332 |
+
"evidence": "Woody amber family control from curated trade-name resolver; not used for training.",
|
| 333 |
+
},
|
| 334 |
+
{
|
| 335 |
+
"pair_id": "v11_sub_0022",
|
| 336 |
+
"target": "Ambroxan",
|
| 337 |
+
"target_cas": "6790-58-9",
|
| 338 |
+
"substitute": "Ambrofix",
|
| 339 |
+
"substitute_cas": "6790-58-9",
|
| 340 |
+
"grade": "acceptable",
|
| 341 |
+
"suggested_percentage_adjustment": None,
|
| 342 |
+
"mode": "function_match",
|
| 343 |
+
"source_name": "Fraterworks Ambrofix product listing",
|
| 344 |
+
"source_url": "https://fraterworks.com/products/ambrofix",
|
| 345 |
+
"provenance_flag": "authoritative-supplier-page",
|
| 346 |
+
"evidence": "Ambrofix listed as Ambroxan material; same-CAS alias control.",
|
| 347 |
+
},
|
| 348 |
+
{
|
| 349 |
+
"pair_id": "v11_sub_0023",
|
| 350 |
+
"target": "Coumarin",
|
| 351 |
+
"target_cas": "91-64-5",
|
| 352 |
+
"substitute": "Florex",
|
| 353 |
+
"substitute_cas": None,
|
| 354 |
+
"grade": "odor-only",
|
| 355 |
+
"suggested_percentage_adjustment": None,
|
| 356 |
+
"mode": "odor_match",
|
| 357 |
+
"source_name": "Fraterworks Florex product note",
|
| 358 |
+
"source_url": "https://fraterworks.com/products/florex",
|
| 359 |
+
"provenance_flag": "authoritative-supplier-page",
|
| 360 |
+
"evidence": "Similar to Bicyclononalactone with hay/almond/coconut facets; coconut accord comment flags coumarin comparison.",
|
| 361 |
+
},
|
| 362 |
+
{
|
| 363 |
+
"pair_id": "v11_sub_0024",
|
| 364 |
+
"target": "Anisic aldehyde",
|
| 365 |
+
"target_cas": "123-11-5",
|
| 366 |
+
"substitute": "Canthoxal",
|
| 367 |
+
"substitute_cas": "5462-06-6",
|
| 368 |
+
"grade": "partial",
|
| 369 |
+
"suggested_percentage_adjustment": None,
|
| 370 |
+
"mode": "function_match",
|
| 371 |
+
"source_name": "Fraterworks Canthoxal product note",
|
| 372 |
+
"source_url": "https://fraterworks.com/products/canthoxal",
|
| 373 |
+
"provenance_flag": "authoritative-supplier-page",
|
| 374 |
+
"evidence": "Stable alternative to traditional anisic aldehydes.",
|
| 375 |
+
},
|
| 376 |
+
{
|
| 377 |
+
"pair_id": "v11_sub_0025",
|
| 378 |
+
"target": "Patchouli",
|
| 379 |
+
"target_cas": "8014-09-3",
|
| 380 |
+
"substitute": "Neo Patchouli",
|
| 381 |
+
"substitute_cas": None,
|
| 382 |
+
"grade": "partial",
|
| 383 |
+
"suggested_percentage_adjustment": None,
|
| 384 |
+
"mode": "function_match",
|
| 385 |
+
"source_name": "Fraterworks Neo Patchouli product note",
|
| 386 |
+
"source_url": "https://fraterworks.com/products/caryophyllene-formate",
|
| 387 |
+
"provenance_flag": "authoritative-supplier-page",
|
| 388 |
+
"evidence": "Premium fixative with distinctive patchouli-like facets.",
|
| 389 |
+
},
|
| 390 |
+
{
|
| 391 |
+
"pair_id": "v11_sub_0026",
|
| 392 |
+
"target": "Fixateur 404",
|
| 393 |
+
"target_cas": None,
|
| 394 |
+
"substitute": "Ambrexol",
|
| 395 |
+
"substitute_cas": None,
|
| 396 |
+
"grade": "functional-only",
|
| 397 |
+
"suggested_percentage_adjustment": None,
|
| 398 |
+
"mode": "function_match",
|
| 399 |
+
"source_name": "Fraterworks Ambrexol product note",
|
| 400 |
+
"source_url": "https://fraterworks.com/products/ambrexol",
|
| 401 |
+
"provenance_flag": "authoritative-supplier-page",
|
| 402 |
+
"evidence": "Superior alternative to discontinued Fixateur 404.",
|
| 403 |
+
},
|
| 404 |
+
{
|
| 405 |
+
"pair_id": "v11_sub_0027",
|
| 406 |
+
"target": "Damascone",
|
| 407 |
+
"target_cas": "23726-91-2",
|
| 408 |
+
"substitute": "Givescone",
|
| 409 |
+
"substitute_cas": None,
|
| 410 |
+
"grade": "odor-only",
|
| 411 |
+
"suggested_percentage_adjustment": None,
|
| 412 |
+
"mode": "odor_match",
|
| 413 |
+
"source_name": "Fraterworks Givescone customer/product note",
|
| 414 |
+
"source_url": "https://fraterworks.com/products/givescone",
|
| 415 |
+
"provenance_flag": "supplier-page-customer-observation",
|
| 416 |
+
"evidence": "Review reports similar smell to damascone with red fruit facets; weaker provenance.",
|
| 417 |
+
},
|
| 418 |
+
{
|
| 419 |
+
"pair_id": "v11_sub_0028",
|
| 420 |
+
"target": "Peru balsam resinoid",
|
| 421 |
+
"target_cas": "8007-00-9",
|
| 422 |
+
"substitute": "Peru Balsam Resinoid 50% in BB",
|
| 423 |
+
"substitute_cas": "8007-00-9",
|
| 424 |
+
"grade": "acceptable",
|
| 425 |
+
"suggested_percentage_adjustment": "50% dilution documented by supplier",
|
| 426 |
+
"mode": "function_match",
|
| 427 |
+
"source_name": "PerfumersWorld perfume supplies catalogue",
|
| 428 |
+
"source_url": "https://www.perfumersworld.com/perfume-supplies.php",
|
| 429 |
+
"provenance_flag": "authoritative-supplier-catalogue",
|
| 430 |
+
"evidence": "50% dilution in benzyl benzoate for practical handling.",
|
| 431 |
+
},
|
| 432 |
+
{
|
| 433 |
+
"pair_id": "v11_sub_0029",
|
| 434 |
+
"target": "Peru balsam resinoid",
|
| 435 |
+
"target_cas": "8007-00-9",
|
| 436 |
+
"substitute": "Peru Balsam Resinoid 50% in DPG",
|
| 437 |
+
"substitute_cas": "8007-00-9",
|
| 438 |
+
"grade": "acceptable",
|
| 439 |
+
"suggested_percentage_adjustment": "50% dilution documented by supplier",
|
| 440 |
+
"mode": "function_match",
|
| 441 |
+
"source_name": "PerfumersWorld perfume supplies catalogue",
|
| 442 |
+
"source_url": "https://www.perfumersworld.com/perfume-supplies.php",
|
| 443 |
+
"provenance_flag": "authoritative-supplier-catalogue",
|
| 444 |
+
"evidence": "50% dilution in DPG for practical handling.",
|
| 445 |
+
},
|
| 446 |
+
{
|
| 447 |
+
"pair_id": "v11_sub_0030",
|
| 448 |
+
"target": "BHT",
|
| 449 |
+
"target_cas": "128-37-0",
|
| 450 |
+
"substitute": "Tocopherol",
|
| 451 |
+
"substitute_cas": "59-02-9",
|
| 452 |
+
"grade": "functional-only",
|
| 453 |
+
"suggested_percentage_adjustment": None,
|
| 454 |
+
"mode": "function_match",
|
| 455 |
+
"source_name": "Fraterworks Tocopherol product note",
|
| 456 |
+
"source_url": "https://fraterworks.com/products/tocopherol",
|
| 457 |
+
"provenance_flag": "authoritative-supplier-page",
|
| 458 |
+
"evidence": "100% natural alternative to synthetics like BHT for antioxidant preservation role.",
|
| 459 |
+
},
|
| 460 |
+
]
|
| 461 |
+
|
| 462 |
+
|
| 463 |
+
EXTRA_MATERIALS: dict[str, dict[str, Any]] = {
|
| 464 |
+
"4707-47-5": {"name": "Veramoss / Evernyl", "smiles": "COC(=O)c1c(C)cc(O)c(C)c1O", "aliases": ["Evernyl", "Veramoss"]},
|
| 465 |
+
"90028-68-5": {"name": "Oakmoss absolute", "smiles": "NATURAL:oakmoss", "natural_synthetic": "natural"},
|
| 466 |
+
"20665-85-4": {"name": "Isobutavan", "smiles": "CC(C)C(=O)Oc1cc(C=O)ccc1OC"},
|
| 467 |
+
"28219-61-6": {"name": "Dartanol / Bacdanol", "smiles": "CCC(=C(CO)C1CCC(C)(C)C1)C", "aliases": ["Dartanol", "Bacdanol"]},
|
| 468 |
+
"8006-87-9": {"name": "Natural sandalwood", "smiles": "NATURAL:sandalwood", "natural_synthetic": "natural"},
|
| 469 |
+
"80-54-6": {"name": "Lilial", "smiles": "CC(C)(C)c1ccc(CC(C)C=O)cc1"},
|
| 470 |
+
"31906-04-4": {"name": "Lyral / HMPCC", "smiles": "CC1CCC(C(C)(C)O)CC1CC=O", "aliases": ["Lyral", "HMPCC"]},
|
| 471 |
+
"285977-85-7": {"name": "Lilyflore", "smiles": "CC1=C(C)C(CO)(C)Cc2ccccc12"},
|
| 472 |
+
"10339-55-6": {"name": "Ethyl Linalool", "smiles": "CCC(C)(O)CC/C=C(C)/CC"},
|
| 473 |
+
"120-72-9": {"name": "Indole", "smiles": "c1ccc2[nH]ccc2c1"},
|
| 474 |
+
"81-15-2": {"name": "Musk xylene", "smiles": "Cc1c(C(C)(C)C)c([N+](=O)[O-])c(C)c([N+](=O)[O-])c1[N+](=O)[O-]"},
|
| 475 |
+
"123-11-5": {"name": "Anisic aldehyde", "smiles": "COc1ccc(C=O)cc1"},
|
| 476 |
+
"5462-06-6": {"name": "Canthoxal", "smiles": "COc1ccc(CCC=O)cc1"},
|
| 477 |
+
"8014-09-3": {"name": "Patchouli", "smiles": "NATURAL:patchouli", "natural_synthetic": "natural"},
|
| 478 |
+
"8007-00-9": {"name": "Peru balsam resinoid", "smiles": "NATURAL:peru_balsam", "natural_synthetic": "natural"},
|
| 479 |
+
"128-37-0": {"name": "BHT", "smiles": "CC(C)(C)c1cc(C)c(O)c(C(C)(C)C)c1"},
|
| 480 |
+
"59-02-9": {"name": "Tocopherol", "smiles": "CC(C)CCCC(C)CCCC(C)CCCC1CCC2(C)C1CCC(C)(O)C2"},
|
| 481 |
+
}
|
| 482 |
+
|
| 483 |
+
|
| 484 |
+
def read_jsonl_by_cas(path: Path) -> dict[str, dict[str, Any]]:
|
| 485 |
+
rows = {}
|
| 486 |
+
if not path.exists():
|
| 487 |
+
return rows
|
| 488 |
+
for row in load_jsonl(path):
|
| 489 |
+
cas = row.get("cas")
|
| 490 |
+
if cas:
|
| 491 |
+
rows[str(cas)] = row
|
| 492 |
+
return rows
|
| 493 |
+
|
| 494 |
+
|
| 495 |
+
def label_distributions() -> dict[str, dict[str, float]]:
|
| 496 |
+
by_cas: dict[str, list[str]] = defaultdict(list)
|
| 497 |
+
for row in load_jsonl(DATA / "odour_character_labels_v8_2_clause_guard_dominance.jsonl"):
|
| 498 |
+
cas = row.get("cas")
|
| 499 |
+
if not cas:
|
| 500 |
+
continue
|
| 501 |
+
codes = row.get("class_codes") or [row.get("final_class_or_masked") or row.get("class_code")]
|
| 502 |
+
by_cas[str(cas)].extend([code for code in codes if code])
|
| 503 |
+
return {cas: descriptor_distribution_from_codes(codes) for cas, codes in by_cas.items()}
|
| 504 |
+
|
| 505 |
+
|
| 506 |
+
def poucher_tiers() -> dict[str, str]:
|
| 507 |
+
out = {}
|
| 508 |
+
path = DATA / "substantivity_targets_poucher_tiers_v8.jsonl"
|
| 509 |
+
if not path.exists():
|
| 510 |
+
return out
|
| 511 |
+
for row in load_jsonl(path):
|
| 512 |
+
if row.get("cas") and row.get("substantivity_tier"):
|
| 513 |
+
out[str(row["cas"])] = row["substantivity_tier"]
|
| 514 |
+
return out
|
| 515 |
+
|
| 516 |
+
|
| 517 |
+
def material_rows_from_sources() -> dict[str, dict[str, Any]]:
|
| 518 |
+
registry = read_jsonl_by_cas(DATA / "aroma_chemicals.jsonl")
|
| 519 |
+
rows: dict[str, dict[str, Any]] = {}
|
| 520 |
+
for cas, row in registry.items():
|
| 521 |
+
rows[cas] = {
|
| 522 |
+
"profile_id": f"v11_cas_{cas}",
|
| 523 |
+
"cas": cas,
|
| 524 |
+
"name": row.get("name") or cas,
|
| 525 |
+
"smiles": row.get("smiles"),
|
| 526 |
+
"molecular_weight": row.get("molecular_weight"),
|
| 527 |
+
"boiling_point_k": row.get("boiling_point_k"),
|
| 528 |
+
"vapor_pressure_pa": row.get("vapor_pressure_pa"),
|
| 529 |
+
"logp": row.get("logp"),
|
| 530 |
+
"natural_synthetic": "unknown",
|
| 531 |
+
"source_fields": ["data/aroma_chemicals.jsonl"],
|
| 532 |
+
}
|
| 533 |
+
for name, rec in MATERIALS.items():
|
| 534 |
+
cas = rec.get("cas")
|
| 535 |
+
if not cas or "accord" in rec:
|
| 536 |
+
continue
|
| 537 |
+
row = rows.setdefault(
|
| 538 |
+
str(cas),
|
| 539 |
+
{
|
| 540 |
+
"profile_id": f"v11_cas_{cas}",
|
| 541 |
+
"cas": str(cas),
|
| 542 |
+
"name": rec.get("name") or name,
|
| 543 |
+
"smiles": rec.get("smiles"),
|
| 544 |
+
"natural_synthetic": "unknown",
|
| 545 |
+
"source_fields": [],
|
| 546 |
+
},
|
| 547 |
+
)
|
| 548 |
+
row.setdefault("aliases", [])
|
| 549 |
+
if name not in row["aliases"]:
|
| 550 |
+
row["aliases"].append(name)
|
| 551 |
+
row["smiles"] = row.get("smiles") or rec.get("smiles")
|
| 552 |
+
row["source_fields"] = sorted(set(row.get("source_fields", []) + ["src/pino/materials.py"]))
|
| 553 |
+
for cas, rec in EXTRA_MATERIALS.items():
|
| 554 |
+
row = rows.setdefault(
|
| 555 |
+
cas,
|
| 556 |
+
{
|
| 557 |
+
"profile_id": f"v11_cas_{cas}",
|
| 558 |
+
"cas": cas,
|
| 559 |
+
"name": rec["name"],
|
| 560 |
+
"source_fields": [],
|
| 561 |
+
},
|
| 562 |
+
)
|
| 563 |
+
row.update({k: v for k, v in rec.items() if k != "aliases"})
|
| 564 |
+
row.setdefault("aliases", [])
|
| 565 |
+
row["aliases"] = sorted(set(row["aliases"] + rec.get("aliases", [])))
|
| 566 |
+
row["source_fields"] = sorted(set(row.get("source_fields", []) + ["scripts/pimt_v11_build.py:EXTRA_MATERIALS"]))
|
| 567 |
+
for eval_row in SUBSTITUTION_EVAL_ROWS:
|
| 568 |
+
for side in ["target", "substitute"]:
|
| 569 |
+
cas = eval_row.get(f"{side}_cas")
|
| 570 |
+
name = eval_row.get(side)
|
| 571 |
+
if cas:
|
| 572 |
+
row = rows.setdefault(
|
| 573 |
+
str(cas),
|
| 574 |
+
{
|
| 575 |
+
"profile_id": f"v11_cas_{cas}",
|
| 576 |
+
"cas": str(cas),
|
| 577 |
+
"name": name,
|
| 578 |
+
"natural_synthetic": "unknown",
|
| 579 |
+
"source_fields": [],
|
| 580 |
+
},
|
| 581 |
+
)
|
| 582 |
+
row.setdefault("aliases", [])
|
| 583 |
+
if name and name not in row["aliases"] and normalize_name(name) != normalize_name(row.get("name")):
|
| 584 |
+
row["aliases"].append(name)
|
| 585 |
+
row["source_fields"] = sorted(set(row.get("source_fields", []) + ["data/substitution_eval_set_v11.jsonl"]))
|
| 586 |
+
elif name:
|
| 587 |
+
key = f"name:{normalize_name(name)}"
|
| 588 |
+
rows.setdefault(
|
| 589 |
+
key,
|
| 590 |
+
{
|
| 591 |
+
"profile_id": f"v11_name_{normalize_name(name).replace(' ', '_')}",
|
| 592 |
+
"cas": None,
|
| 593 |
+
"name": name,
|
| 594 |
+
"smiles": None,
|
| 595 |
+
"natural_synthetic": "unknown",
|
| 596 |
+
"source_fields": ["data/substitution_eval_set_v11.jsonl"],
|
| 597 |
+
},
|
| 598 |
+
)
|
| 599 |
+
return rows
|
| 600 |
+
|
| 601 |
+
|
| 602 |
+
def add_rdkit_features(row: dict[str, Any]) -> None:
|
| 603 |
+
features = train.molecule_features(row.get("smiles"))
|
| 604 |
+
for key in ["molecular_weight", "logp"]:
|
| 605 |
+
row[key] = row.get(key) if row.get(key) is not None else features.get(key)
|
| 606 |
+
row["functional_groups"] = {
|
| 607 |
+
key: features.get(key)
|
| 608 |
+
for key in ["heavy_atoms", "h_acceptors", "h_donors", "rotatable_bonds", "tpsa", "fraction_csp3"]
|
| 609 |
+
if features.get(key) is not None
|
| 610 |
+
}
|
| 611 |
+
vp = train.safe_float(row.get("vapor_pressure_pa"))
|
| 612 |
+
row["log10_vapor_pressure_pa"] = math.log10(vp) if vp and vp > 0 else None
|
| 613 |
+
|
| 614 |
+
|
| 615 |
+
def substantivity_rows_for_prediction(profiles: list[dict[str, Any]]) -> tuple[list[dict[str, Any]], np.ndarray]:
|
| 616 |
+
rows = []
|
| 617 |
+
for profile in profiles:
|
| 618 |
+
features = {
|
| 619 |
+
"log10_vapor_pressure_pa": profile.get("log10_vapor_pressure_pa"),
|
| 620 |
+
"boiling_point_k": profile.get("boiling_point_k"),
|
| 621 |
+
"molecular_weight": profile.get("molecular_weight"),
|
| 622 |
+
"logp": profile.get("logp"),
|
| 623 |
+
}
|
| 624 |
+
features.update(profile.get("functional_groups") or {})
|
| 625 |
+
rows.append(
|
| 626 |
+
{
|
| 627 |
+
"cas": profile.get("cas") or profile.get("profile_id"),
|
| 628 |
+
"name": profile.get("name"),
|
| 629 |
+
"smiles": profile.get("smiles"),
|
| 630 |
+
"target_log10": 0.0,
|
| 631 |
+
"target_raw": 0.0,
|
| 632 |
+
"features": features,
|
| 633 |
+
"scaffold": train.scaffold_key(profile.get("smiles"), profile.get("cas") or profile.get("profile_id")),
|
| 634 |
+
"source": "v11-profile",
|
| 635 |
+
}
|
| 636 |
+
)
|
| 637 |
+
x, _names = train.design_matrix(rows, include_structural=True)
|
| 638 |
+
return rows, x
|
| 639 |
+
|
| 640 |
+
|
| 641 |
+
def build_profiles() -> list[dict[str, Any]]:
|
| 642 |
+
distributions = label_distributions()
|
| 643 |
+
tiers = poucher_tiers()
|
| 644 |
+
rows = list(material_rows_from_sources().values())
|
| 645 |
+
for row in rows:
|
| 646 |
+
add_rdkit_features(row)
|
| 647 |
+
cas = row.get("cas")
|
| 648 |
+
row["descriptor_distribution"] = distributions.get(str(cas), {}) if cas else {}
|
| 649 |
+
row["poucher_tier"] = tiers.get(str(cas)) if cas else None
|
| 650 |
+
row["enrichment_pending"] = ["IFRA/allergen/use-level", "cost", "availability", "documented_usage_range"]
|
| 651 |
+
row["pimt_version"] = PIMT_V11
|
| 652 |
+
row["substitution_risks"] = []
|
| 653 |
+
if V10_MODEL.exists():
|
| 654 |
+
bundle = joblib.load(V10_MODEL)
|
| 655 |
+
model = bundle.get("model") if isinstance(bundle, dict) else bundle
|
| 656 |
+
_predict_rows, x = substantivity_rows_for_prediction(rows)
|
| 657 |
+
preds = np.asarray(model.predict(x), dtype=float)
|
| 658 |
+
for row, pred in zip(rows, preds):
|
| 659 |
+
row["substantivity_model"] = "pimt_v10_line_drawn_substantivity_gbm"
|
| 660 |
+
row["substantivity_log10_predicted"] = float(pred)
|
| 661 |
+
else:
|
| 662 |
+
for row in rows:
|
| 663 |
+
row["substantivity_model"] = "missing"
|
| 664 |
+
row["substantivity_log10_predicted"] = None
|
| 665 |
+
rows.sort(key=lambda r: (str(r.get("cas") or ""), normalize_name(r.get("name"))))
|
| 666 |
+
return rows
|
| 667 |
+
|
| 668 |
+
|
| 669 |
+
def report_descriptor_external_delta(eval_rows: list[dict[str, Any]], profiles: list[dict[str, Any]]) -> dict[str, Any]:
|
| 670 |
+
full = evaluate_retriever(eval_rows, profiles, mode="function_match", top_k=5)
|
| 671 |
+
no_desc_profiles = [{**row, "descriptor_distribution": {}} for row in profiles]
|
| 672 |
+
physchem_only = evaluate_retriever(eval_rows, no_desc_profiles, mode="function_match", top_k=5)
|
| 673 |
+
delta = full["top_k_hit_rate"] - physchem_only["top_k_hit_rate"]
|
| 674 |
+
return {
|
| 675 |
+
"descriptor_validation_rule": "external eval only; no cosine self-consistency metric reported",
|
| 676 |
+
"with_descriptors_top5_hit_rate": full["top_k_hit_rate"],
|
| 677 |
+
"physchem_only_top5_hit_rate": physchem_only["top_k_hit_rate"],
|
| 678 |
+
"external_hit_rate_delta": delta,
|
| 679 |
+
"verdict": "kept" if delta >= 0 else "dropped",
|
| 680 |
+
}
|
| 681 |
+
|
| 682 |
+
|
| 683 |
+
def write_reports(
|
| 684 |
+
eval_rows: list[dict[str, Any]],
|
| 685 |
+
profiles: list[dict[str, Any]],
|
| 686 |
+
retrieval: dict[str, Any],
|
| 687 |
+
descriptor_delta: dict[str, Any],
|
| 688 |
+
) -> None:
|
| 689 |
+
ARTIFACTS.mkdir(exist_ok=True)
|
| 690 |
+
provenance_counts = Counter(row["provenance_flag"] for row in eval_rows)
|
| 691 |
+
profile_field_counts = {
|
| 692 |
+
"n_profiles": len(profiles),
|
| 693 |
+
"with_cas": sum(bool(row.get("cas")) for row in profiles),
|
| 694 |
+
"with_smiles": sum(bool(row.get("smiles")) for row in profiles),
|
| 695 |
+
"with_vp": sum(row.get("vapor_pressure_pa") is not None for row in profiles),
|
| 696 |
+
"with_bp": sum(row.get("boiling_point_k") is not None for row in profiles),
|
| 697 |
+
"with_logp": sum(row.get("logp") is not None for row in profiles),
|
| 698 |
+
"with_descriptor_distribution": sum(bool(row.get("descriptor_distribution")) for row in profiles),
|
| 699 |
+
"with_poucher_tier": sum(bool(row.get("poucher_tier")) for row in profiles),
|
| 700 |
+
"with_substantivity_prediction": sum(row.get("substantivity_log10_predicted") is not None for row in profiles),
|
| 701 |
+
}
|
| 702 |
+
sample_eval = evaluate_material("24851-98-7", profiles)
|
| 703 |
+
sample_formula = evaluate_formula(
|
| 704 |
+
[
|
| 705 |
+
{"cas": "24851-98-7", "weight_fraction": 0.15},
|
| 706 |
+
{"cas": "54452-50-3", "weight_fraction": 0.20},
|
| 707 |
+
{"cas": "106-24-1", "weight_fraction": 0.05},
|
| 708 |
+
],
|
| 709 |
+
profiles,
|
| 710 |
+
)
|
| 711 |
+
summary = {
|
| 712 |
+
"pimt_version": PIMT_V11,
|
| 713 |
+
"timestamp_utc": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()),
|
| 714 |
+
"milestone_1": {
|
| 715 |
+
"eval_set_path": "data/substitution_eval_set_v11.jsonl",
|
| 716 |
+
"n_eval_pairs": len(eval_rows),
|
| 717 |
+
"grades": dict(Counter(row["grade"] for row in eval_rows)),
|
| 718 |
+
"provenance_counts": dict(provenance_counts),
|
| 719 |
+
"assessment_interface": ["evaluate_material", "evaluate_formula", "substitute", "evaluate_retriever"],
|
| 720 |
+
},
|
| 721 |
+
"milestone_2": {"profile_path": "data/material_profiles_v11.jsonl", **profile_field_counts},
|
| 722 |
+
"milestone_3": retrieval,
|
| 723 |
+
"milestone_4": descriptor_delta,
|
| 724 |
+
"milestone_5": {
|
| 725 |
+
"formula_optimisation_layer": "scoped-only-not-built",
|
| 726 |
+
"design_path": "artifacts/pimt_v11_formula_layer_design.md",
|
| 727 |
+
},
|
| 728 |
+
"milestone_6": {
|
| 729 |
+
"current_limits": [
|
| 730 |
+
"Substitution set is an evaluation set only; no ranking model trained on it.",
|
| 731 |
+
"Safety/use-level, cost, and availability are enrichment-pending and not emitted as authority.",
|
| 732 |
+
"Descriptor distributions are weak and retained only if external hit-rate does not regress.",
|
| 733 |
+
"Many accord/replacer products are blends without CAS-level physchem, so profile coverage is incomplete.",
|
| 734 |
+
],
|
| 735 |
+
"next_options": ["source IFRA/cost", "build formula optimiser", "expand eval set"],
|
| 736 |
+
},
|
| 737 |
+
"sample_material_assessment": sample_eval,
|
| 738 |
+
"sample_formula_assessment": sample_formula,
|
| 739 |
+
}
|
| 740 |
+
(ARTIFACTS / "pimt_v11_assessment.json").write_text(json.dumps(summary, indent=2, sort_keys=True), encoding="utf-8")
|
| 741 |
+
md = f"""# PIMT v11 Substitution Retriever Assessment
|
| 742 |
+
|
| 743 |
+
- Eval set: `data/substitution_eval_set_v11.jsonl`, n={len(eval_rows)}
|
| 744 |
+
- Material profiles: `data/material_profiles_v11.jsonl`, n={len(profiles)}
|
| 745 |
+
- Retriever mode: `{retrieval['mode']}`, top-{retrieval['top_k']} hit-rate={retrieval['top_k_hit_rate']:.3f} over n={retrieval['n_evaluable']} evaluable pairs; skipped={retrieval['n_skipped']}
|
| 746 |
+
- Mean absolute substantivity delta on evaluable pairs: `{retrieval['mean_substantivity_delta_abs']}`
|
| 747 |
+
- Descriptor external delta: {descriptor_delta['external_hit_rate_delta']:.3f}; verdict=`{descriptor_delta['verdict']}`
|
| 748 |
+
|
| 749 |
+
## Boundaries
|
| 750 |
+
|
| 751 |
+
- Substitution pairs remain evaluation data only. No manufactured labels and no trained substitution ranker are created.
|
| 752 |
+
- Descriptor distributions are validated only by external substitution hit-rate; no cosine self-consistency score is reported.
|
| 753 |
+
- v10 substantivity is used as a ranking prior/penalty, not as a generator.
|
| 754 |
+
- IFRA/allergen/use-level, cost, and availability fields are marked `enrichment_pending`.
|
| 755 |
+
|
| 756 |
+
## Next Options
|
| 757 |
+
|
| 758 |
+
1. Source IFRA/cost/availability to unlock regulatory and cost modes.
|
| 759 |
+
2. Build the classical formula optimiser after retriever review.
|
| 760 |
+
3. Expand the authoritative substitution eval set beyond n={len(eval_rows)}.
|
| 761 |
+
"""
|
| 762 |
+
(ARTIFACTS / "pimt_v11_assessment.md").write_text(md, encoding="utf-8")
|
| 763 |
+
design = """# PIMT v11 Formula Optimisation Layer Design (Scoped Only)
|
| 764 |
+
|
| 765 |
+
Formula representation: materials plus percentages, dilutions, and role labels. Roles are impact, modifier, body, fixative, bridge, and solvent. The evaluator projects each material into top/heart/base behaviour through VP/BP and the v10 substantivity prior.
|
| 766 |
+
|
| 767 |
+
Generation approach: classical constrained optimisation before any deep generation. Candidate methods are Bayesian optimisation for small continuous spaces, simulated annealing for mixed discrete/continuous swaps, and genetic search for accord rebuilds. Objectives combine odor/profile similarity, base-note strength, evaporation-curve fit, role compatibility, and material compatibility. Constraints enforce total=100%, min/max ranges where sourced, banned materials, user constraints, and later IFRA/use limits.
|
| 768 |
+
|
| 769 |
+
LLM role: parse the brief, choose an accord strategy, call the scoring/optimiser, format output, and explain tradeoffs. It never invents concentrations, substantivity values, safety claims, use limits, or regulatory conclusions.
|
| 770 |
+
|
| 771 |
+
Status: not built in v11. Build only after human review of retriever metrics and profile coverage.
|
| 772 |
+
"""
|
| 773 |
+
(ARTIFACTS / "pimt_v11_formula_layer_design.md").write_text(design, encoding="utf-8")
|
| 774 |
+
|
| 775 |
+
|
| 776 |
+
def main() -> None:
|
| 777 |
+
parser = argparse.ArgumentParser()
|
| 778 |
+
parser.add_argument("--top-k", type=int, default=5)
|
| 779 |
+
args = parser.parse_args()
|
| 780 |
+
DATA.mkdir(exist_ok=True)
|
| 781 |
+
ARTIFACTS.mkdir(exist_ok=True)
|
| 782 |
+
write_jsonl(DATA / "substitution_eval_set_v11.jsonl", SUBSTITUTION_EVAL_ROWS)
|
| 783 |
+
profiles = build_profiles()
|
| 784 |
+
write_jsonl(DATA / "material_profiles_v11.jsonl", profiles)
|
| 785 |
+
descriptor_rows = [
|
| 786 |
+
{
|
| 787 |
+
"pimt_version": PIMT_V11,
|
| 788 |
+
"cas": row.get("cas"),
|
| 789 |
+
"name": row.get("name"),
|
| 790 |
+
"descriptor_distribution": row.get("descriptor_distribution") or {},
|
| 791 |
+
"source": "data/odour_character_labels_v8_2_clause_guard_dominance.jsonl",
|
| 792 |
+
}
|
| 793 |
+
for row in profiles
|
| 794 |
+
if row.get("descriptor_distribution")
|
| 795 |
+
]
|
| 796 |
+
write_jsonl(DATA / "descriptor_distributions_v11.jsonl", descriptor_rows)
|
| 797 |
+
retrieval = evaluate_retriever(SUBSTITUTION_EVAL_ROWS, profiles, mode="function_match", top_k=args.top_k)
|
| 798 |
+
descriptor_delta = report_descriptor_external_delta(SUBSTITUTION_EVAL_ROWS, profiles)
|
| 799 |
+
(ARTIFACTS / "pimt_v11_retriever_eval.json").write_text(
|
| 800 |
+
json.dumps(retrieval, indent=2, sort_keys=True),
|
| 801 |
+
encoding="utf-8",
|
| 802 |
+
)
|
| 803 |
+
(ARTIFACTS / "pimt_v11_descriptor_external_validation.json").write_text(
|
| 804 |
+
json.dumps(descriptor_delta, indent=2, sort_keys=True),
|
| 805 |
+
encoding="utf-8",
|
| 806 |
+
)
|
| 807 |
+
write_reports(SUBSTITUTION_EVAL_ROWS, profiles, retrieval, descriptor_delta)
|
| 808 |
+
print(
|
| 809 |
+
json.dumps(
|
| 810 |
+
{
|
| 811 |
+
"pimt_version": PIMT_V11,
|
| 812 |
+
"eval_pairs": len(SUBSTITUTION_EVAL_ROWS),
|
| 813 |
+
"profiles": len(profiles),
|
| 814 |
+
"top5_hit_rate": retrieval["top_k_hit_rate"],
|
| 815 |
+
"n_evaluable": retrieval["n_evaluable"],
|
| 816 |
+
"descriptor_delta": descriptor_delta["external_hit_rate_delta"],
|
| 817 |
+
"descriptor_verdict": descriptor_delta["verdict"],
|
| 818 |
+
},
|
| 819 |
+
indent=2,
|
| 820 |
+
)
|
| 821 |
+
)
|
| 822 |
+
|
| 823 |
+
|
| 824 |
+
if __name__ == "__main__":
|
| 825 |
+
main()
|