Skip to content

feat: Curate and publish a modern pure Prolog DPO / preference dataset on Hugging Face #4

Description

@dougransom

Background & Motivation

Foundation LLMs (Claude, GPT, Gemini, Llama, DeepSeek) overwhelmingly default to 1980s-era imperative Prolog constructs:

  • Non-logical cuts (!)
  • Soft cuts (( Cond -> Then ; Else ))
  • Negation-as-failure (\+) for inequality
  • Procedural built-in list operations (include/3, member/2 in conditional tests)
  • Arithmetic evaluation (is/2, <) that breaks query reversibility

This occurs due to a 1000:1 historical training distribution imbalance: over 99% of open-source Prolog code across GitHub, Rosetta Code, and textbooks (1980–2012) was written before modern ISO standardization and prior to Ulrich Neumerkel's development of library(reif) (2014+).

Modern AI alignment and post-training pipelines rely heavily on Direct Preference Optimization (DPO) and RLHF datasets hosted on Hugging Face (trl, axolotl, llama-factory). When a model is tuned with DPO, its loss function directly penalizes undesirable patterns and rewards preferred paradigms.

Currently, no curated, pure declarative Prolog DPO dataset exists on Hugging Face. Creating one provides an open resource that model creators can ingest to permanently improve future Prolog coding models.


Objective

Curate, validate, and publish an open-access DPO dataset on Hugging Face (e.g. dougransom/modern-pure-prolog-dpo or prolog-agent-toolkit/pure-prolog-dpo) under a permissive open license (Apache-2.0 / CC-BY-4.0).


Dataset Schema (DPO / Preference Triplet)

Each entry will follow the standard Hugging Face DPO schema:

{
  "prompt": "User coding request or algorithmic task",
  "chosen": "Modern, pure ISO Prolog solution using library(reif), CLP(Z), chars, and clean data representations",
  "rejected": "Legacy imperative solution relying on cuts (!), soft cuts (->), is/2, or non-monotonic negation",
  "rationale": "Detailed explanation of why the chosen solution preserves bidirectionality, monotonicity, and declarative debugging, while explaining why the rejected solution commits destructively or fails on uninstantiated variables."
}

Target Content & Problem Categories (300–500 pairs)

  1. List Filtering & Transformation:
    • chosen: tfilter(dif(X), List, Out) and higher-order closures.
    • rejected: Recursive loops with cuts remove(X, [X|Xs], Ys) :- !, ... or include/3.
  2. Conditional Branching & Option Lookups:
    • chosen: if_/3, memberd_t/3, cond_t/3, lookup_option/4.
    • rejected: ( member(Key(Val), Opts) -> ... ; Val = Default ).
  3. Declarative Integer Arithmetic:
    • chosen: library(clpz) constraints (#=, #<, #=<, domain declarations ins).
    • rejected: is/2, >, < causing instantiation errors when queried backwards.
  4. Clean vs. Defaulty Data Representations:
    • chosen: Terms distinguishable solely by principal functor (leaf(X) vs node(L, R)).
    • rejected: Catch-all default clauses or runtime var/1/nonvar/1 testing.
  5. Pure Definite Clause Grammars (DCGs):
    • chosen: Pure sequence parsing and generation with --> and { if_(...) }.
    • rejected: Non-logical cuts in DCG bodies or imperative peek lookaheads.

Quality Control & Automated Verification

To ensure this dataset is the highest-quality Prolog resource on Hugging Face:

  • Purity Gate: Run prolog-audit from prolog-agent-toolkit over every chosen solution to mathematically verify 0 unjustified cuts, 0 soft cuts, and 0 unsound negations.
  • Bidirectionality Unit Tests: Run prolog-safe (Scryer and Trealla runners) to assert that every chosen predicate succeeds both forward (?- pred(+In, -Out).) and backward (?- pred(-In, +Out).).

Deliverables

  • Python generation and validation pipeline in prolog-agent-toolkit (e.g. scripts/generate_hf_dataset.py).
  • Export script generating Parquet and JSONL formats compatible with Hugging Face datasets.
  • Hugging Face repository creation and upload.
  • Comprehensive Dataset Card (README.md) on Hugging Face explaining the historical bias, declarative purity invariants, and training instructions.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions