3LC Documentation

website·Indexed 33 days ago

https://docs.3lc.ai

Documentation for 3LC, a machine learning ecosystem for managing datasets and training metrics. It includes a Python package for creating and modifying tables (such as semantic and instance segmentation), integrating with frameworks like PyTorch, PyTorch Lightning, and Detectron2, and a Hub Frontend based on Flask and Jinja2.

Tokens
252.9K
Snippets
1.1K
Records
1.8K
Agent score
52%

What's inside 3LC

  1. Overview of the 3LC Hub

    The 3LC Hub is a browser-based, no-code interface that unifies dataset management, model training, performance analysis, and retraining into a single data-centric workflow. It integrates three primary components:

    • Object Service: Serves data and metrics.
    • Dashboard: Used for detailed analysis.
    • Compute Service (and plugins): Executes training, insights, and import/export workloads.
  2. Overview of the 3LC (Three Lines of Code) Python Package

    The tlc package is the Python entry point for 3LC, a tool used to analyze and improve machine learning models and datasets. It provides functionality to construct and read tlc.Table and tlc.Run objects, collect per-sample metrics, and serve data to the 3LC Dashboard via the Object Service. The public interface is defined by the names in tlc.__all__ and curated sub-namespaces, which follow semantic versioning.
  3. Overview of PyTorch sampler creation functions in tlc.integration.torch.samplers

    The tlc.integration.torch.samplers module provides several utility functions to create PyTorch-compatible samplers from tables based on weight columns:

    • create_weighted_sampler(): For probability-proportional sampling (with replacement).
    • create_random_sampler(): For uniform random sampling.
    • create_sequential_sampler(): For deterministic sequential iteration.
    • create_repeat_by_weight_sampler(): For repeating rows based on weights to ensure distribution match while sampling every row (with weight > 1) in a single epoch.
  4. Overview of Custom Sample Types in 3LC

    Custom sample types allow developers to round-trip arbitrary Python objects through 3LC Tables. A sample type converts data between two forms:

    1. Sample form: Python objects used in ML code (e.g., NumPy arrays, dataclasses).
    2. Row form: Serializable primitives stored in table rows (e.g., numbers, strings, nested lists).

    There are two primary storage tracks:

    • Inline: Data is stored directly in the row. Subclass tlc.sample_types.SampleType and implement to_row() and from_row().
    • External: Data is stored as individual resources (files, S3 objects) referenced by a URL in the row. Subclass tlc.sample_types.ExternalSampleType and implement save() and load().

    Note: While custom types allow data round-tripping, the Dashboard only displays raw stored data (URLs, numbers, lists) for custom schemas. Specialized Dashboard features (like image rendering or annotation editing) are only available for built-in schemas.

  5. Overview of 3LC Detectron2 integration utilities

    The tlc.integration.detectron2 package provides specialized tools for integrating 3LC with Detectron2, including:

    • Metrics Collection: detectron_metrics_collection_hook for standard Detectron2 metrics, metrics_collection_hook for 3LC-specific metrics on Detectron datasets, and bounding_box_metrics_collector for bounding box predictions.
    • Dataset Utilities: register_coco_instances serves as a drop-in replacement for detectron2.data.datasets.register_coco_instances.
    • Embedding Analysis: umap_reduce_embeddings_hook allows for UMAP reduction of embeddings generated during a run.
  6. Overview of semantic segmentation metrics in tlc.metrics.semantic_segmentation

    The tlc.metrics.semantic_segmentation module provides offline Python-side metrics for semantic segmentation based on a $C \times C$ pixel confusion matrix (where $C$ is the number of real classes). It supports standard metrics including pixel accuracy, per-class recall/accuracy, per-class IoU, mean IoU, frequency-weighted IoU, and Dice/F1.

    Aggregation Duality:

    • Cumulative: The confusion matrix is accumulated over all pixels of all images before computing IoU. This is the standard for benchmark reporting.
    • Per-image then averaged: Metrics are computed for each image and then averaged, which can be noisier and biased toward small objects.

    To achieve benchmark-correct cumulative mean IoU using per-image data, sum the per-image confusion matrices and then derive the metrics from the resulting total matrix.

  7. Overview of the tlc.metrics package

    The tlc.metrics package is used to collect per-sample metrics from a model operating on a tlc.Table and write those results to a tlc.Run. The primary workflow involves using tlc.collect_metrics() during inference passes, utilizing various metrics_collectors to gather data.
  8. Overview of the tlc Python package API

    The tlc Python package provides the core functionality for Three Lines of Code (3LC). The public API is designed for end-users; internal symbols may be visible via introspection but are not part of the public API and are subject to change in future releases. For high-level concepts, refer to the Getting Started and User Guide documentation.
  9. Overview of 3LC Tables

    A Table is the central object in 3LC that connects training code, the Dashboard, and storage. It allows developers to visualize, analyze, and modify data in the Dashboard and consume those changes in Python via tlc.Table. Tables are interoperable with common ML/Python tabular types such as PyTorch Datasets, Pandas DataFrames, and Hugging Face Datasets. Edits made to Tables are non-destructive and tracked via a revision model, ensuring original data remains unmodified.