Skip to content
goldener-dataPublic

About

Goldener - Make your data even more valuable - Open source data-centric orchestration for the full AI lifecycle

Topics

Resources

Stars

19 stars

Watchers

1 watching

Forks

Repository files navigation

Goldener Logo

A Python library for data-centric orchestration during the full lifecycle of Artificial Intelligence pipelines.

License PyPI Package

Overview | Principles | Features | Installation | Contribute | Contributors

Overview

Goldener is an open-source Python library (Apache 2 licence) designed to manage the orchestration of data during the full lifecycle of Artificial Intelligence (AI) pipelines.

In the AI era, the data is the new gold. Being able to collect it is already something but creating value from it is the real challenge. Goldener is designed to help make the most of the available data. It provides tools to orchestrate data during the full lifecycle of Artificial Intelligence pipelines, from the training phase to the monitoring phase.

All Goldener's features are built from the same core principle: the semantics of data can be described by embeddings extracted from pre-trained/foundational models. This semantic representation is general enough to emphasize the differences or similarities between the data samples.

Goldener applies data-centric processes/algorithms on these representations to make the right data available at the right time, allowing to optimize the performance of any AI pipelines while minimizing the costs (time, performance, computing resources).

When it's time to annotate data, Goldener finds the most representative subset to annotate. During annotation, it can help to define annotation guidelines by spotting specific cases or as well run annotation quality checks. Once enough data is annotated, Goldener can split it in multiple sets (train, validation, test) ensuring the reproduction of the task variability. During the training phase, Goldener can efficiently balance the data to optimize the training time and the model performance. Finally, when the model is deployed, Goldener can find the most informative data to monitor the model performance and detect any drift in the data distribution.

As illustrated in the Goldener's open research repository, the possibilities are endless. Every step of the AI lifecycle includes inefficiencies that can be solved by data-centric processes based on pre-trained/foundational embeddings. Goldener aims to gather all the possible solutions in one place, universal for all data and task types.

Key design principles

Artificial intelligence is deployed everywhere, and the data it processes can have multiple shapes. To deal with the diversity of data and tasks, Goldener is designed to be:

  • Modality-agnostic: All the features are actionable for any data modalities (text, image, video, tabular, etc.) and even for multimodality data.
  • Customizable: All features leverage specifiable tools. These tools are defined following standard API patterns allowing anyone to implement their own tools to customize the behavior of the features.
  • Standard dependencies: Goldener is built on standard dependencies (PyTorch, numpy, scikit-learn, etc.) to ensure compatibility with the most common AI pipelines while limiting the need for new dependencies.

The AI lifecycle is often iterative and incremental. The success of an AI pipeline is a trade-off between the speed to release it for a real-life confrontation and its performance. At the same time, the computing resources are often scarce (distributed across different locations, restricted throughput and memory) and the datasets often large and continuously growing. In order to keep the lifecycle fast enough and be adaptable to any computing resources, Goldener is articulated around the following principles:

  • Progressive batch processing: Each task can be stopped and restarted on demand (or failure). Already computed results are not recomputed.
  • Multipurposes embeddings: The same embeddings are used for different tasks (selection, splitting, monitoring, etc.). They are computed once and stored for later use. This allows to save time and computing resources.
  • Distributed first: Any task can be distributed across multiple machines.
  • On demand access to pipelines: All processing pipelines are serializable. They are stored and available whenever a new request is made.

Example of features

Sampling among not annotated data

Goldener can find the most representative data subset to annotate. It can extract and store semantic knowledge of the data from embeddings extracted with pre-trained models. Then, it leverages this knowledge to find the most representative subset of data to annotate. This subset of data can be annotated in order to train or monitor a model.

from goldener import (
    GoldSelector,
    GoldDescriptor,
    GoldTorchEmbeddingTool,
    GoldTorchEmbeddingToolConfig,
    GoldTensorVectorizationTool,
)

# my_model, my_layers, and dataset are user-supplied.
gd = GoldDescriptor(
    table_path="my_table_for_description",
    embedder=GoldTorchEmbeddingTool(
        GoldTorchEmbeddingToolConfig(
            model=my_model,
            layers=my_layers,
        )
    ),
    vectorizer=GoldTensorVectorizationTool(),
)

# Descriptor stores vectors under description_key (default "embeddings").
gs = GoldSelector(
    table_path="my_table_for_selection",
    vectorized_key=gd.description_key,
)

description = gd.describe_in_table(dataset)
selection_table = gs.select_in_table(description, 100, "to_annotate")
selected = GoldSelector.get_selection_indices(
    selection_table,
    value="to_annotate",
)

By default, GoldSelector uses GoldGreedyKernelPointsSelectionTool, which relies on Coreax. Coreax is not installed on Windows, so on Windows replace the GoldSelector above with one that uses another selection tool:

from goldener import GoldGreedyKCenterSelectionTool

gs = GoldSelector(
    table_path="my_table_for_selection",
    vectorized_key=gd.description_key,
    selection_tool=GoldGreedyKCenterSelectionTool(device="cpu"),
)

Scoring novel vectors against a reference

New data does not always resemble the data already known by a model or a team. Some samples show situations that were never seen before, some come from a shifted distribution, and some are simply mislabeled. Finding them by hand in a large batch of new data is slow and error prone.

Goldener can score how novel each new sample is compared to a reference set, such as the training set, previously reviewed data, or data known to be correctly annotated. The higher the score, the less the sample resembles the reference. These scores can be used to prioritize annotation or review, to detect out-of-distribution data or drift in production, or to check annotations by comparing the samples of each label to a reference of the same label.

GoldNoveltyScorer compares the new and reference samples using their embeddings. Scores are stored per vector; when a sample has multiple vectors, retrieving scores by sample idx keeps its highest vector score by default.

from goldener import GoldNearestNeighborNoveltyScoringTool, GoldNoveltyScorer

# reference_vectors is a 2D tensor and new_vectors is a PixelTable table,
# both produced with the same embedding model and vectorization settings.
tool = GoldNearestNeighborNoveltyScoringTool()
tool.fit(reference_vectors)
scorer = GoldNoveltyScorer(table_path="my_table_for_novelty", scorer=tool)
score_table = scorer.score_in_table(new_vectors)

# Up to 50 samples, from the most novel to the least novel.
most_novel = GoldNoveltyScorer.get_novelty_scores_per_idx(
    score_table, idx_key="idx", k=50
)

See Find wrong labels with a reference you trust for a runnable label check, results on synthetic embeddings, and triage of unlabeled data.

Splitting annotated data in train and validation sets

Goldener can split data between the train and validation sets ensuring that the training set is containing most of the different situations for the tasks. From a description of the samples (embeddings), the most different/unique elements are kept for the training set while the least informative ones are kept for the validation set.

from goldener import (
    GoldSet,
    GoldSplitter,
    GoldDescriptor,
    GoldSelector,
)

# Reuse the descriptor from smart sampling (vectorizer included).
# dataset is user-supplied. The selector must read the descriptor output column.
gd = GoldDescriptor(...)
gselector = GoldSelector(
    table_path="my_table_for_selection",
    vectorized_key=gd.description_key,
)
gs = GoldSplitter(
    sets=[GoldSet("train", 0.7), GoldSet("val", 0.3)],
    descriptor=gd,
    selector=gselector,
)

split_table = gs.split_in_table(dataset)
splits = GoldSplitter.get_split_indices(
    split_table, selection_key="selected", idx_key="idx"
)
train_indices = splits["train"]
val_indices = splits["val"]

Clustering data to define annotation guidelines

Among the data, there are often multiple "modes" (e.g. different types of images, different types of text, etc.). Goldener can clusterize the data to find these different modes. Then, the different clusters can be leveraged to define annotation guidelines for each cluster.

from goldener import (
    GoldClusterizer,
    GoldSKLearnClusteringTool,
    GoldDescriptor,
)
from sklearn.cluster import KMeans

# Reuse the descriptor from smart sampling (vectorizer included).
# dataset is user-supplied.
gd = GoldDescriptor(...)
n_clusters = 10
gcluster = GoldClusterizer(
    table_path="my_table_for_clusterization",
    clustering_tool=GoldSKLearnClusteringTool(KMeans(n_clusters=n_clusters)),
    cluster_key="cluster",
    vectorized_key=gd.description_key,
)

description = gd.describe_in_table(dataset)
clustered_table = gcluster.cluster_in_table(description, n_clusters=n_clusters)

for cluster_id in range(n_clusters):
    cluster_indices = GoldClusterizer.get_cluster_indices(
        clustered_table,
        cluster_key="cluster",
        cluster_idx=cluster_id,
        idx_key="idx",
    )

    # sample few samples and use them to define annotation guidelines for this cluster

Reducing dimensionality

Depending on the dataset (size, data type, task), the computation tackled by Goldener can be quite resource intensive and time consuming. The dimensionality reduction aims to reduce the memory footprint and increase the speed for the downstream task. It can be quite useful to adapt the computation to the hardware constraints or access results in time constrained situation.

import torch
from sklearn.decomposition import PCA
from goldener import GoldSKLearnReductionTool

# 50 embeddings of dimension 16
x = torch.randn(50, 16)

reducer = GoldSKLearnReductionTool(PCA(n_components=2))
x_reduced = reducer.fit_transform(x)  # shape: (50, 2)

See Reducing the dimensionality of embeddings for the reduction API, fitting versus transforming new rows, and which estimators can map new vectors.

Balancing batches during training

When training with randomly sampled batches, the content distribution within each batch can vary a lot — some batches may end up overrepresenting certain types of data while barely including others. This imbalance can hurt how well a model learns to recognize the underrepresented cases.

Goldener proposes a batch sampler grouping data into groups of similar content, and then drawing samples so each batch is spread across clusters as evenly as possible.

from goldener import GoldClusterizedBatchSampler, GoldClusterizer, GoldDescriptor

# Reuse the descriptor and clusterizer from earlier examples.
# Keep vectorized_key aligned with gd.description_key on the clusterizer.
# my_dataset is user-supplied.
gd = GoldDescriptor(...)
gc = GoldClusterizer(...)

batch_sampler = GoldClusterizedBatchSampler(
    dataset=my_dataset,
    batch_size=32,
    clusterizer=gc,
    descriptor=gd,
    n_clusters=10,
)

Weighting samples by embedding density

GoldDensityWeigher gives larger scores to samples in sparse embedding neighborhoods. Use it to explore loss weighting or sampling policies that emphasize underrepresented patterns, including variation within a class. Sparsity is a representation-based signal, not a calibrated measure of model difficulty or a guarantee of better generalization.

See Weighting training samples by embedding density for a runnable example, the kNN scoring formula, training integration, and chunking and restart limitations. Raw scores are stored per vector; retrieval defaults to averaging by sample idx, then dividing by the maximum returned score.

from goldener import (
    GoldDensityWeigher,
    GoldDescriptor,
    GoldTensorVectorizationTool,
    GoldVectorizer,
)

# Explicit vectorization stage: descriptor embeddings -> vectorized column.
# dataset, and embedder settings inside GoldDescriptor(...), are user-supplied.
described = GoldDescriptor(...).describe_in_table(dataset)
vectors = GoldVectorizer(
    table_path="my_table_for_vectorization",
    vectorizer=GoldTensorVectorizationTool(),
).vectorize_in_table(described)
weigher = GoldDensityWeigher(table_path="my_table_for_weights")
weighted = weigher.weigh_in_table(vectors)
sample_weights = GoldDensityWeigher.get_weights_per_idx(weighted)

Installation

Installing Goldener is as simple as running the following command:

pip install goldener

Contribute

We welcome contributions to Goldener! Here's how you can help:

Getting Started

  1. Fork the repository
  2. Clone your fork
  3. Install the dependencies
  4. Create your branch and make your proposals
  5. Push to your fork and create a pull request
  6. The PR will be automatically tested by GitHub Actions
  7. A maintainer will review your PR and may request changes
  8. Once approved, your PR will be merged

Development

To set up the development environment:

  1. Install uv if you haven't already:
curl -LsSf https://astral.sh/uv/install.sh | sh
  1. Create and activate a virtual environment (optional but recommended):
uv venv
source .venv/bin/activate  # On Unix/macOS
  1. Install development dependencies:
uv sync --all-extras  # Install all dependencies including development dependencies
  1. Run tests:
uv run pytest tests/
  1. Run type checking with mypy:
uv run mypy .
  1. Run linting with ruff:
# Run all checks
uv run ruff check .

# Format code
uv run ruff format .
  1. Set up pre-commit hooks:
# Install git hooks
uv run pre-commit install

# Run pre-commit on all files
uv run pre-commit run --all-files

The pre-commit hooks will automatically run:

  • mypy for type checking
  • ruff for linting and formatting

whenever you make a commit. Run tests separately with uv run pytest tests/.

  1. Generate the developer API documentation:
./scripts/generate_api_docs.sh

The API documentation is generated with pdoc from the docstrings (Google style) into docs/api (open docs/api/index.html in a browser). It is not committed: the website workflow regenerates it from the deployed code.

Release Process

To release a new version of the goldener package:

  1. Create a new branch for the release: git checkout -b release-vX.Y.Z
  2. Update the version vX.Y.Z in pyproject.toml
  3. Run uv sync to update the lock file with the new version
  4. Commit the changes with a message like release vX.Y.Z
  5. Merge the branch into main
  6. Trigger a new release on GitHub with the tag vX.Y.Z

Once the package is published on PyPI, the release workflow regenerates the API docs and uploads the website to the hosting provider through SFTP: docs/landing/index.html as index.html at the root, docs/api as the api folder and docs/statics as the statics folder. It requires, in the website environment of the repository, the secrets FTP_SERVER, FTP_USERNAME and FTP_PASSWORD, the variable SFTP_KNOWN_HOSTS (the host key of the server, as ssh-keyscan prints it, checked against the fingerprint given by the hosting provider), and optionally the variable FTP_SERVER_DIR (the remote folder, ending with /, defaults to the home folder of the FTP account). To update the website without a release (e.g. after a change of the landing page), run the Update the website workflow manually from the Actions tab of the repository, on the branch or tag to publish.

Contributors

abhiramvsmg
abhiramvsmg
AhmadBilalDSA
AhmadBilalDSA
AnayGarodia
AnayGarodia
ariktadas144
ariktadas144
AshleyAHuang
AshleyAHuang
bfs2021
bfs2021
CyberKun
CyberKun
Dhruv06000
Dhruv06000
emreocell
emreocell
Golden007-prog
Golden007-prog
HafidIdrissi
HafidIdrissi
inverteum
inverteum
jason-scheffel
jason-scheffel
Josequevedov08
Josequevedov08
Julianovak
Julianovak
LyViolz
LyViolz
mangomac
mangomac
Mr-Neutr0n
Mr-Neutr0n
panosfrantzolas
panosfrantzolas
pre765
pre765
Sahilkumar-r
Sahilkumar-r
SHEKHAR-Y
SHEKHAR-Y
TaniaW777
TaniaW777
Yann-CV
Yann-CV

About

Goldener - Make your data even more valuable - Open source data-centric orchestration for the full AI lifecycle

Topics

Resources

Stars

19 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages