Skip to content

Rules, labelling and conflicts

Knowtation's rules propose values for the data dictionary: "this column is a measure", "its unit is m³/s". This page covers what a rule is, how disagreements are decided, and how that relates to established methods.

A rule is a labelling function

In weak supervision, a small heuristic that labels data is a labelling function. Knowtation's rules are exactly that:

  • A rule looks at one element (a column, a JSON path, a field of a layer) and either
  • abstains: its conditions don't hold, so it says nothing; or
  • votes: it proposes a value for a property, with a weight. For example unit = m3/s, weight 0.6.
  • Overlap: two or more rules vote on the same property of the same element.
  • Conflict: they vote for different values of that property, such as unit = m3/s against unit = L/s.

Agreeing rules raise confidence; conflicts need deciding. The profiler, recognisers (such as GTFS) and the LLM vote the same way; rules are the part you edit.

How Knowtation decides: a weighted vote

Votes are combined by the confidence policy (confidence.md):

  1. Each vote counts with its weight. An LLM's own confidence is capped, because LLMs are poorly calibrated.
  2. Votes for the same value combine with noisy-OR, 1 − ∏(1 − wᵢ): two rules at 0.6 give 0.84.
  3. Votes for different values reduce each other. Each is multiplied by (1 − penalty × the strongest rival).
  4. The highest-scoring value is chosen, and ties go to the more deterministic source.

It is transparent and reproducible (policies are versioned and each run records its policy), but the weights are set by hand.

Some datasets come with files that explain another file's codes. While files are read, Knowtation records which columns hold unique keys and which other columns' values are found among them, with counts, a few unmatched codes and the lookup rows of the codes used. This evidence is observed. A link rule (link: instead of when:) decides which of it counts:

- id: code-lookup
  description: A column whose values are the keys of another file refers to it.
  link: {min_inclusion: 0.95, min_inclusion_named: 0.5, min_codes: 2}
  propose: {role: identifier}
  weight: 0.8

A column links when at least min_inclusion of its codes are keys (min_inclusion_named when the two column names match apart from case and punctuation). It then gets references (the lookup's key), a code list (meaning from a name/label/title column, a long text column as the description, the rest as attributes) and the rule's propose values; both files get a role (data, lookup); a column with a single code also proposes the dataset's description and publisher. The score is the weight times the share of codes found, plus 0.1 when the names match. The built-in lookup-tables pack holds this rule and applies when files link (applies_when: {has_overlaps: true}).

Several rule sets in one run

Votes from different rule sets are combined in the same way. A rule pack says when it suits a dataset with applies_when; every condition given must hold:

id: hydrology
version: 1.0.0
applies_when:
  names_any: [discharge_m3s, stage_m, station_id]   # compared without case
  min_names: 2                                      # at least two of them present
  # standard_in: [gtfs]                             # a resource follows a recognised standard
  # resource_kind_in: [geospatial]                  # a resource is of this kind
rules: [...]

A run uses the latest core rules plus the latest version of every built-in, public or own pack (its starter's) whose applies_when holds. A rule set without applies_when is only used when a run names it. A run request can name its rule sets exactly ("rule_sets": [{"name": "core"}, {"name": "hydrology", "version": "1.0.0"}]), and then no automatic selection happens. Every run records each rule set it used, with its version and content hash.

Seeing overlaps and conflicts

Rule analysis (Analyse on a dataset's Advanced tab, or POST /rules/analysis for one or more datasets) reports for each rule:

Measure Meaning
Coverage The share of elements the rule votes on
Overlap The share of its votes where another rule also voted on the same property
Conflict The share where another rule voted a different value, naming that rule
Accuracy Where a benchmark data dictionary exists, the share of its votes that match the benchmark value

These are the measures of Snorkel's LFAnalysis, computed directly to avoid the dependency.

It also reports gaps: for each element property rules can propose (role, unit, aggregation, description, title), how many elements got no rule vote, with the commonest name prefixes and suffixes among them (such as pc11_ or _pct). A pattern shared by many uncovered columns is a good candidate for a new rule.

Draft rules from LLM answers

Values an LLM proposed, or people typed, can become rules, so the next dataset with similar columns gets them from rules: free, instant and reproducible. The Draft rules tab drafts them from the latest version:

  • Each chosen value from an LLM or a person becomes a rule proposing it. Values from rules, recognisers or the profiler are left out: rules for them already exist.
  • Columns whose names share a prefix or suffix (pc11_, _pct) get one pattern rule only when every column in the dataset with that prefix or suffix got the same value; otherwise each column gets an exact-name rule. There is no fixed minimum: the data decides. A column name that has different values in different files gets no rule.
  • Weights follow the source: 0.4 for LLM values nobody reviewed, 0.5 for LLM values people accepted, 0.6 for values people typed. A rule covering columns from several sources takes the lowest.
  • Each rule carries tests (its columns should match, an unrelated name shouldn't), so an edited draft that no longer proposes what its tests expect can't be approved.

Try runs the draft on this dataset and others you can see: columns reached, values that agree with the current ones, and disagreements. A draft is never used until someone who can review the dataset approves it; it then becomes their private rule set and can be made public like any other. Runs pick it up for datasets that share at least two of its column names. Approving or discarding a draft stays with that draft: later runs show the same draft as decided, and a review that changes its values makes a new one.

What Snorkel does

Snorkel (Ratner et al., VLDB 2017) replaces hand-labelling with many noisy labelling functions. Its label model estimates each function's accuracy and their correlations from agreements and disagreements alone, without ground truth, and combines the votes into probabilistic labels, usually to train a model.

Alternatives for combining votes

Approach How it decides Notes
Majority vote The value with most votes wins Ignores how reliable each rule is
Weighted vote (Knowtation now) Hand-set weights, noisy-OR agreement, conflict penalty Transparent; weights are guesses until calibrated
Dawid–Skene (Dawid & Skene, Applied Statistics, 1979) The EM algorithm estimates each voter's error rates The classic crowdsourcing model
Snorkel's label model Learns accuracies and correlations by matrix completion Strong, but heavier
FlyingSquid (Fu et al., ICML 2020) A fast closed-form label model ("triplet methods") Much faster than Snorkel's
DMN decision tables (OMG standard) A hit policy decides which row wins: unique, any, priority, first, collect… For deterministic rules; a standard way to state conflict policy
Rule engines (for example Drools) Salience, specificity and recency resolve conflicts Production rules that trigger actions; a different paradigm

Why the weighted vote, and what comes next

Results must be inspectable and reproducible, and there are few benchmarks yet, so a visible weighted vote fits best. With enough benchmark data dictionaries, weights can be learned, from each rule's measured accuracy or with a label model such as Dawid–Skene or FlyingSquid, and saved as a new policy version to compare with the hand-set one (TASKS.md).