Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Standardization strategies, with leaves_only on and off

Companion to TUTORIAL.ipynb section 4. Every text and score below is real: it was printed by strategy_text and standardize_constructs on ELSST R5 with allmpnet.

1. What a strategy is

standardize_constructs matches a span to a taxonomy concept by embedding both and taking the cosine. The span is embedded as it is. The concept has no natural text, so a strategy is the recipe that builds one. Six recipes exist. They use four fields of a taxonomy entry:

fieldmeaningSELF-ESTEEM
leafthe concept’s own labelSELF-ESTEEM
paththe chain of broader concepts from a top concept down to itIDENTITY > PERSONAL IDENTITY > SELF-ESTEEM
parentsthe broader concepts, nearest firstPERSONAL IDENTITY, IDENTITY
altthe entry terms (synonyms)SELF-ACCEPTANCE, SELF-CONFIDENCE, SELF-RESPECT
notethe English scope note or definition, often empty(empty)

Everything is lowercased before embedding.

strategyrecipeSELF-ESTEEM
leaflabelself-esteem
pathpathidentity > personal identity > self-esteem
anchorlabel: pathself-esteem: identity > personal identity > self-esteem
contextlabel is related to parentsself-esteem is related to personal identity, identity
bracketlabel (parents)self-esteem (personal identity, identity)
enrichedlabel. synonyms. note. pathself-esteem. self-acceptance; self-confidence; self-respect. identity > personal identity > self-esteem

Each strategy is one answer to one question: how much of the tree should the concept vector carry? leaf carries none. path, anchor, context, bracket carry the ancestors in four phrasings. enriched carries the ancestors and, more important, the synonyms.

2. What leaves_only is

ELSST is a tree. A leaf has no narrower concept under it. A branch has children.

MOTIVATION                    branch (and a top concept: no parent)
├── ASPIRATION                leaf
└── INCENTIVES                leaf

WELL-BEING (HEALTH)           branch (top concept)
├── PSYCHOLOGICAL WELL-BEING  leaf
├── LIFESTYLE AND HEALTH      leaf
├── AGEING                    leaf
└── ENVIRONMENTAL EXPOSURE    leaf

IDENTITY > PERSONAL IDENTITY > SELF-ESTEEM     leaf, two paths (also under IMAGE)
leaves_only=True (default)leaves_only=False
who can be an answerthe 2,417 leavesall 3,436 concepts
entries embedded2,6613,739
cache fileelsst_<strategy>_<model>_leaves.npyelsst_<strategy>_<model>_all.npy
where a span landsthe bottom of the tree, alwaysany level

The switch changes which concepts may answer. It does not change any recipe or any score. A leaf’s text is the same under both settings.

How a branch becomes an entry

With leaves_only=False every branch gets an entry of the same shape as a leaf entry: its own label as leaf, the path from a top concept down to itself, its own parents. The six recipes then apply unchanged. Two cases:

A branch with parents (PERSONAL IDENTITY, child of IDENTITY and of IMAGE):

strategytext
leafpersonal identity
pathidentity > personal identity
anchorpersonal identity: identity > personal identity
contextpersonal identity is related to identity
bracketpersonal identity (identity)
enrichedpersonal identity. <synonyms>. identity > personal identity

A top concept (no parent; 247 of them in R5, MOTIVATION and WELL-BEING (HEALTH) among them). The path is the label alone, the parents list is empty, and the recipes collapse:

strategyMOTIVATION
leafmotivation
pathmotivation
anchormotivation: motivation
contextmotivation
bracketmotivation
enrichedmotivation. motivation

anchor and enriched repeat the label for a top concept because the path is the label. Harmless for the cosine, but not pretty. It is the one place where a recipe would deserve a special case (skip the path when it equals the label).

A leaf with two paths

SELF-ESTEEM sits under IDENTITY and under IMAGE. It gets two entries, one per path, under both settings. The label, synonyms and note are the same in both; the path and parents differ:

strategyentry 1entry 2
leafself-esteemself-esteem (identical vector)
pathidentity > personal identity > self-esteemimage > personal identity > self-esteem
bracketself-esteem (personal identity, identity)self-esteem (personal identity, image)

At lookup the span is scored against both and the best score is kept for the concept. No path is preferred by depth or by any other rule; the span picks the path that fits it. 244 of the 2,661 leaf entries come from this (97 of those concepts also have synonyms). Under leaf the two vectors are identical and the duplicate falls away in the de-duplication.

3. The same spans under every strategy, on and off

Six SDT spans, top-1 concept and cosine, allmpnet.

leaves_only=True

spanleafpathanchorcontextbracketenriched
intrinsic motivationINCENTIVES 0.56INCENTIVES 0.72INCENTIVES 0.62INCENTIVES 0.62INCENTIVES 0.70INCENTIVES 0.65
well-beingMENTAL HEALTH 0.70HAPPINESS 0.66HAPPINESS 0.63HAPPINESS 0.55HAPPINESS 0.70HAPPINESS 0.55
autonomy supportAUTONOMY AT WORK 0.72AUTONOMY AT WORK 0.59AUTONOMY AT WORK 0.67AUTONOMY AT WORK 0.65AUTONOMY AT WORK 0.65AUTONOMY AT WORK 0.57
self-confidenceSELF-ESTEEM 0.79SELF-ESTEEM 0.57SELF-ESTEEM 0.60SELF-ESTEEM 0.56SELF-ESTEEM 0.63SELF-ESTEEM 0.58
need frustrationANGER 0.55SATISFACTION 0.54BOREDOM 0.50SATISFACTION 0.54BOREDOM 0.56SATISFACTION 0.50
academic achievementACADEMIC ACHIEVEMENT 1.00ACADEMIC ACHIEVEMENT 0.83ACADEMIC ACHIEVEMENT 0.82ACADEMIC ACHIEVEMENT 0.80ACADEMIC ACHIEVEMENT 0.90ACADEMIC ACHIEVEMENT 0.69

leaves_only=False

spanleafpathanchorcontextbracketenriched
intrinsic motivationMOTIVATION 0.77MOTIVATION 0.77MOTIVATION 0.73MOTIVATION 0.77MOTIVATION 0.77MOTIVATION 0.69
well-beingWELL-BEING (HEALTH) 0.82WELL-BEING (HEALTH) 0.82WELL-BEING (SOCIETY) 0.70WELL-BEING (HEALTH) 0.82WELL-BEING (HEALTH) 0.82WELL-BEING (HEALTH) 0.61
autonomy supportAUTONOMY AT WORK 0.72AUTONOMY AT WORK 0.59AUTONOMY AT WORK 0.67AUTONOMY AT WORK 0.65AUTONOMY AT WORK 0.65AUTONOMY AT WORK 0.57
self-confidenceSELF-ESTEEM 0.79SELF-ESTEEM 0.57SELF-ESTEEM 0.60SELF-ESTEEM 0.56SELF-ESTEEM 0.63SELF-ESTEEM 0.58
need frustrationANGER 0.55SATISFACTION 0.54BOREDOM 0.50SATISFACTION 0.54BOREDOM 0.56SATISFACTION 0.50
academic achievementACADEMIC ACHIEVEMENT 1.00ACADEMIC ACHIEVEMENT 0.83ACADEMIC ACHIEVEMENT 0.82ACADEMIC ACHIEVEMENT 0.80ACADEMIC ACHIEVEMENT 0.90ACADEMIC ACHIEVEMENT 0.69

How to read the two tables:

  • Rows 3 to 6 are identical on and off. When the right concept is already a leaf, the switch does nothing. The only change in the candidate list is the addition of branches, and none of them beats the leaf for these spans.
  • Rows 1 and 2 change under every strategy. intrinsic motivation moves from INCENTIVES (a child, and the wrong child: incentives are external rewards) to MOTIVATION. well-being moves from HAPPINESS or MENTAL HEALTH to WELL-BEING (HEALTH). Both targets are top concepts that leaves-only cannot offer. The scores rise too (0.65 → 0.69, 0.55 → 0.61 under enriched), which says the branch is a closer match, not only a permitted one.
  • The strategy decides the score, not the concept. Down a column the winner rarely changes; the cosine does. leaf gives the highest cosines for exact and near-exact labels (academic achievement 1.00, self-confidence 0.79 through the synonym in the label space). enriched gives the lowest, because its long text spreads the vector over synonyms and ancestors. This matters for τ: a threshold tuned for leaf is too strict for enriched.
  • need frustration fails everywhere. ANGER, BOREDOM, SATISFACTION at 0.50–0.56. ELSST has no concept for it. No strategy and no switch invents one; this is the standardisation-failure class.
  • One warning in the anchor column. well-being → WELL-BEING (SOCIETY) instead of WELL-BEING (HEALTH). The two top concepts have the same name apart from the bracket; the anchor recipe repeats a top concept’s label twice, which shifts its vector enough to flip the tie. A recipe artefact, not a signal.

4. Which strategy, with the switch on or off

From the entry-term test in section 5 (positive and negative pairs, three models, both settings, plus a held-out synonym test):

  • The ranking of strategies is the same on and off: leaf ≥ enriched > anchor > context ≈ bracket > path. Turning the switch off moves every F1 by at most 0.01.
  • enriched stays the default. On held-out synonyms it is never worse than leaf beyond noise and has the best hit@5; on real spans, which are paraphrases rather than labels, the synonyms are the part that helps.
  • path is the weakest under both settings. Ancestors written as a chain dilute the label.
  • The switch is a granularity choice, not an accuracy one: off, broad constructs get their own concept and the graph carries nodes at mixed depth; on, every node is a leaf and broad constructs are pushed onto a child.

5. The entry-term test: how the defaults were chosen

A thesaurus lists its own synonyms. ELSST gives them as skos:altLabel. Each synonym with its concept is a positive pair: self-confidence ↔ SELF-ESTEEM. For each positive pair the test adds two negative pairs with the same query: a sibling concept (same nearest parent; hard) and a random concept (easy). A fixed seed draws the negatives once. A setting scores a pair by the cosine between the query and the concept text. The rule is same concept if score ≥ τ. A sweep over τ gives the best F1 and its τ. AUC is the threshold-free view. Top-1 accuracy asks if the gold concept wins the ranking against the whole thesaurus.

ELSST, three scopes:

scopecandidatesqueriespairsreads as
leaves2,417 leavessynonyms of leaves5,532leaves_only=True
all3,436 conceptssynonyms of all concepts7,888leaves_only=False
all·leafq3,436 conceptssynonyms of leaves5,584the cost of the extra candidates on the same queries

enriched puts the synonyms inside the concept text. On this test the query sits inside its own target, and the score is inflated (F1 0.84–0.92). enriched_noalt (label, note, path; no synonyms) is the fair version. Best F1, fair rows, scope leaves / all:

strategyallmpnetbge_baseminilm
leaf0.79 / 0.800.82 / 0.820.78 / 0.79
enriched_noalt0.78 / 0.780.79 / 0.790.76 / 0.76
anchor0.77 / 0.780.79 / 0.790.75 / 0.76
context0.77 / 0.780.77 / 0.770.75 / 0.76
bracket0.76 / 0.770.79 / 0.790.74 / 0.75
path0.75 / 0.750.79 / 0.790.73 / 0.73
  • Strategy. The bare label wins. Each phrasing of the tree and the note pull the vector away from the label and cost 0.02–0.05 F1. The spread between strategies is small next to the spread between models.
  • Model. bge_base beats allmpnet by about 0.02 F1 and 0.04 top-1 accuracy in every cell. minilm is last. bge_base separates positives from siblings more sharply: τ* is 0.65–0.70, against 0.45–0.55 for allmpnet.
  • leaves_only. The branches as candidates cost F1 0.005 and top-1 accuracy 0.03–0.07 on the same queries. The branches bring their own labels and synonyms in return. The switch is a granularity choice, not an accuracy choice.
  • τ. τ* depends on the model: about 0.50 for allmpnet with leaf, about 0.70 for bge_base. The old τ = 0.55 was set for all-mpnet-base-v2. Do not reuse it for another model, another strategy or another thesaurus.
  • The hard errors are the thesaurus’s own granularity. Siblings accepted at τ*: sporting activities → SPORTS CLUBS (gold SPORTS); distance courses → ONLINE EDUCATION (gold DISTANCE EDUCATION); achievement tests → INTELLIGENCE TESTS (gold EDUCATIONAL TESTS). Positives missed: mores → CUSTOMS AND TRADITIONS (0.45); perks → FRINGE BENEFITS (0.63). No setting resolves these. They are the granularity-mismatch class of the disagreement classifier.

Do the synonyms in enriched help with a synonym the text has never seen? A second test holds one out. For the 651 ELSST concepts with two or more synonyms, one synonym leaves the concept text and becomes the query. Mean F1 over three models and two scopes:

concept textF1hit@5
label + remaining synonyms0.8110.806
enriched: label + synonyms + note + path0.8060.821
leaf0.7990.796
label + note + path, no synonyms0.7790.766

The synonyms generalise. They add 0.01–0.03 F1 over the bare label for bge_base and minilm, and nothing for allmpnet. The note and the path cost about 0.02 alone. The synonyms pay that cost back. enriched stays the default: it is never worse than leaf beyond noise, it gives the best hit@5, and it is the recipe Paper 3 ships.

The test itself was a temporary script and is not part of the package.

6. Where to look in the code

  • Recipes: strategy_text in theoryminer/harmonizer/taxonomy.py.
  • Entries and paths: _load_elsst and its inner paths_to_root in the same file. All root-to-concept paths are kept, one entry each; nothing is chosen by depth.
  • The switch: load_taxonomy(name, leaves_only); the cache key includes it.
  • Lookup and de-duplication by concept: _top_matches in standardize.py.