Skip to main content

adaptcompile

adaptcompile is a model-agnostic Python library for representing, measuring, comparing, and predicting model adaptation.

adaptcompile treats model adaptation as a behavioral transformation that can be represented, measured, compared, and predicted independently of the training framework used to produce it.

See the architecture overview for how the objects fit together.

Installation

pip install adaptcompile

DataFrame exports are optional:

pip install "adaptcompile[dataframe]"

The reference prediction implementation is also optional:

pip install "adaptcompile[predict]"

For contributor setup:

python -m pip install -e ".[dev]"

Minimal example

from adaptcompile import (
    AdaptationResult,
    AdaptationStudy,
    LearningEpisode,
    ModelContext,
    ProgramSpec,
)

model = ModelContext("example/model", revision="v1", base_state_id="base-1")
episode = LearningEpisode(
    "toy-task",
    train=["example"],
    evaluations={"accuracy": ["held-out example"]},
    episode_id="toy-task-v1",
)

results = [
    AdaptationResult(
        model_context=model,
        episode=episode,
        program=ProgramSpec(name, "adapter", {"strength": strength}),
        before={"accuracy": 0.40},
        after={"accuracy": score},
    )
    for name, strength, score in [
        ("gentle", 0.25, 0.68),
        ("strong", 0.75, 0.81),
    ]
]

study = AdaptationStudy(results)
print(study.best("accuracy").program.name)
print(study.best("accuracy").delta.to_dict())

More runnable examples are available in examples.

Core objects

  • ModelContext identifies a model revision and pre-adaptation base state.
  • LearningEpisode names a learning problem and references its datasets.
  • ProgramFamily describes a conceptual adaptation family.
  • ProgramSpec declares one concrete, backend-independent adaptation program.
  • AdaptationGeometry stores arbitrary-dimensional behavioral measurements.
  • AdaptationResult records before/after geometry for one observed adaptation.
  • AdaptationStudy compares programs for one fixed model context and episode.
  • AdaptationDataset stores observations across models, episodes, and programs.

Public records support JSON-safe serialization. Dataset-like objects attached to a LearningEpisode are intentionally held by reference and are not serialized. DataFrame export is available through the optional dataframe extra.

Compiler-ready data

adaptcompile.compiler combines an AdaptationDataset with externally supplied numeric decision-time descriptors to produce a validated supervised dataset. Feature extraction remains external. Version 0.3 can fit a predictor over the assembled numeric features.

from adaptcompile.compiler import build_compiler_dataset

compiler_data = build_compiler_dataset(
    observations,
    episode_descriptors=episode_features,
    program_descriptors=program_features,
    target="delta",
)
print(compiler_data.feature_names)

See the compiler data contract for descriptor identities, namespaces, baseline features, and validation rules.

Predicting geometry

The dependency-free GeometryPredictor protocol defines target-free prediction from compiler features and candidate identity. RidgeGeometryPredictor is one optional, deliberately simple reference implementation:

from adaptcompile.compiler.predictors import RidgeGeometryPredictor

predictor = RidgeGeometryPredictor().fit(compiler_data)
prediction = predictor.predict(
    features=compiler_data[0].features,
    model_key=compiler_data[0].model_key,
    episode_key=compiler_data[0].episode_key,
    family_fingerprint=compiler_data[0].family_fingerprint,
    program_fingerprint=compiler_data[0].program_fingerprint,
)
print(prediction.predicted_geometry)

See prediction for target semantics and delta reconstruction.

What adaptcompile does not do

  • It does not train or load adapted models.
  • It does not implement LoRA or replace PEFT, TRL, or another training framework.
  • It does not select adaptation programs or execute adaptations.
  • It has no mandatory ML-framework or numerical-stack dependencies; pandas and the scikit-learn reference predictor are optional extras.

Status

0.3.0 adds target-free prediction of adaptation geometry from compiler-ready features. The API is usable but may evolve during the 0.x series. The package does not extract features, execute adaptations, or select programs.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adaptcompile-0.3.0.tar.gz (47.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

adaptcompile-0.3.0-py3-none-any.whl (27.8 kB view details)

Uploaded Python 3

File details

Details for the file adaptcompile-0.3.0.tar.gz.

File metadata

  • Download URL: adaptcompile-0.3.0.tar.gz
  • Upload date:
  • Size: 47.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.0

File hashes

Hashes for adaptcompile-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0413f5e798fff08af0e6ca3342e637d47c7a8bf7ebef7979157c9eb808225aad
MD5 d0729f9509ff0b05ba7d77df04305a73
BLAKE2b-256 c4edfc8a331bfddc6eddab69cfa23b379389f772d436bb116bb97b827550d846

See more details on using hashes here.

File details

Details for the file adaptcompile-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: adaptcompile-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 27.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.0

File hashes

Hashes for adaptcompile-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a9f6e98b60f727c7fb5196d9b62e5a28cf86403442305d883d329e2b6841b41
MD5 2bdfbc4ef58e3fe403691d0ba67f16af
BLAKE2b-256 f44fca030a0830313d509df014f463a25be16011261a7638fc70b2b752adc51d

See more details on using hashes here.

Release history Release notifications | RSS feed

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

This release

0.3.0 This release

2 files

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page