Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:NVIDIA NeMo Curator ModelInterface

From Leeroopedia
Revision as of 13:21, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/NVIDIA_NeMo_Curator_ModelInterface.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Machine Learning, Architecture, Interfaces
Last Updated 2026-02-14 00:00 GMT

Overview

Abstract base class that defines the interface contract for all machine learning models in the NeMo Curator pipeline, focused on weight handling and environmental setup.

Description

The ModelInterface class uses Python's abc.ABC to declare two abstract members that all model wrappers must implement:

  • model_id_names -- An abstract property that returns a list of model identifier strings. These are typically HuggingFace-style model IDs (e.g., Salesforce/instructblip-vicuna-13b) that uniquely identify the models associated with the implementation.
  • setup() -- An abstract method for loading weights and building computation graphs. This is called after construction to prepare the model for inference.

The interface is intentionally minimal. It standardizes weight management and environment setup without constraining how inference is performed. This allows each concrete model implementation to define its own __call__, generate, or other inference methods as appropriate.

Usage

Implement ModelInterface when creating a new model wrapper for the NeMo Curator pipeline. The pipeline infrastructure relies on model_id_names for weight downloading and setup() for model initialization, enabling uniform handling of all model types across the system.

Code Reference

Source Location

  • Repository: NeMo-Curator
  • File: nemo_curator/models/base.py
  • Lines: 1-42

Signature

class ModelInterface(abc.ABC):
    @property
    @abc.abstractmethod
    def model_id_names(self) -> list[str]:
        """Returns a list of model IDs associated with the model."""

    @abc.abstractmethod
    def setup(self) -> None:
        """Set up the model for use, such as loading weights and building computation graphs."""

Import

from nemo_curator.models.base import ModelInterface

I/O Contract

Abstract Members

Name Type Description
model_id_names property -> list[str] Returns a list of HuggingFace-style model identifiers associated with this model implementation
setup() method -> None Initializes the model by loading weights and building computation graphs; must be called before inference

Known Implementations

The following classes in the NeMo Curator codebase implement ModelInterface:

Class Module Purpose
AestheticScorer nemo_curator.models.aesthetics Aesthetic quality scoring from CLIP embeddings
NSFWScorer nemo_curator.models.nsfw NSFW content detection from CLIP embeddings
QwenLM nemo_curator.models.qwen_lm Text-only language model for caption enhancement
QwenVL nemo_curator.models.qwen_vl Vision-language model for video captioning

Usage Examples

Basic Usage

from nemo_curator.models.base import ModelInterface

class MyCustomModel(ModelInterface):
    def __init__(self, model_dir: str) -> None:
        self.model_dir = model_dir
        self.model = None

    @property
    def model_id_names(self) -> list[str]:
        return ["my-org/my-model-name"]

    def setup(self) -> None:
        # Load weights and prepare the model
        self.model = load_model(self.model_dir)
        self.model.eval()

    def __call__(self, inputs):
        return self.model(inputs)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment