HTML 77.2%
TypeScript 10.5%
Python 9.6%
JavaScript 2.5%
1"""Openness 2.0 — measurable dimensions first, a carefully labelled category second.23Dimensions (each `True | False | None` = unknown):4 weights_available the weights can be downloaded (a checkpoint exists on a public hub / official download)5 source_code_available inference / model code is published6 training_code_available the training pipeline is published7 training_data_disclosed the composition of the training data is documented8 dataset_available the training data itself (or most of it) is downloadable9 commercial_use_allowed licence permits commercial use10 redistribution_allowed licence permits redistributing the weights11 derivatives_allowed licence permits fine-tunes / modifications1213Categories (`OPENNESS_CATEGORIES`) are derived, never asserted directly by a connector unless the source literally states it:14 open-source weights + code under an OSI-approved (or equivalently permissive) licence, commercial use and derivatives allowed15 open-weights weights downloadable under a permissive or Creative Commons licence allowing commercial use (code may be missing)16 restricted-weights weights downloadable but the licence restricts commercial use, hosting, derivatives or field of use17 proprietary weights not available (API / product only)18 unknown not enough evidence1920The historical single-value vocabulary (`open-weights | open-source | proprietary | restricted`) stays valid as input to `normalize_openness`.21"""22from __future__ import annotations2324from typing import Any2526from aiatlas.ontology.licenses import LICENSES, normalize_license2728OPENNESS_CATEGORIES = ("open-source", "open-weights", "restricted-weights", "proprietary", "unknown")2930OPENNESS_DIMENSIONS = (31 "weights_available", "source_code_available", "training_code_available", "training_data_disclosed", "dataset_available",32 "commercial_use_allowed", "redistribution_allowed", "derivatives_allowed",33)3435_LEGACY = {36 "open-weights": "open-weights", "open_weights": "open-weights", "open weights": "open-weights", "openweights": "open-weights", "open": "open-weights",37 "open-source": "open-source", "open_source": "open-source", "open source": "open-source", "opensource": "open-source", "oss": "open-source",38 "proprietary": "proprietary", "closed": "proprietary", "closed-source": "proprietary", "closed_source": "proprietary", "closed source": "proprietary",39 "api-only": "proprietary", "api only": "proprietary", "commercial": "proprietary",40 "restricted": "restricted-weights", "restricted-weights": "restricted-weights", "restricted_weights": "restricted-weights", "gated": "restricted-weights",41 "research-only": "restricted-weights", "non-commercial": "restricted-weights",42 "unknown": "unknown", "": "unknown",43}444546def normalize_openness(raw: Any) -> str | None:47 """Legacy single label → canonical category. Unknown strings → None (the writer keeps the raw label)."""48 if raw is None:49 return None50 s = str(raw).strip().lower()51 return _LEGACY.get(s)525354def openness_dimensions(*, weights_available: bool | None = None, license_key: str | None = None, license_raw: str | None = None,55 source_code_available: bool | None = None, training_code_available: bool | None = None,56 training_data_disclosed: bool | None = None, dataset_available: bool | None = None) -> dict[str, bool | None]:57 """Fill the licence-derived dimensions from the licence ontology; everything else is passed through (unknown stays None)."""58 key = license_key or normalize_license(license_raw)59 info = LICENSES.get(key) if key else None60 dims: dict[str, bool | None] = {61 "weights_available": weights_available,62 "source_code_available": source_code_available,63 "training_code_available": training_code_available,64 "training_data_disclosed": training_data_disclosed,65 "dataset_available": dataset_available,66 "commercial_use_allowed": info.commercial_use if info else None,67 "redistribution_allowed": info.redistribution if info else None,68 "derivatives_allowed": info.derivatives if info else None,69 }70 if info and not info.weights_downloadable and weights_available is None:71 dims["weights_available"] = False72 return dims737475def derive_openness(dims: dict[str, bool | None], *, license_key: str | None = None) -> str:76 """Category from dimensions (+ licence category). Conservative: a custom community licence is never 'open-source'."""77 info = LICENSES.get(license_key) if license_key else None78 weights = dims.get("weights_available")79 if weights is False:80 return "proprietary"81 if weights is None:82 return "unknown"83 commercial = dims.get("commercial_use_allowed")84 derivatives = dims.get("derivatives_allowed")85 redistribution = dims.get("redistribution_allowed")86 restricted_by_license = bool(info and (info.category in ("community", "research-only", "responsible-ai") or info.hosting_restrictions))87 if commercial is False or derivatives is False or redistribution is False or restricted_by_license:88 return "restricted-weights"89 if info and info.osi_approved and dims.get("source_code_available") is True and commercial is True and derivatives is True:90 return "open-source"91 if info and info.category in ("permissive", "creative-commons") and commercial is True and redistribution is True:92 return "open-weights"93 if info is None:94 # weights downloadable, licence unknown → we know the weights exist, not the terms95 return "open-weights" if commercial is None else "restricted-weights"96 return "open-weights"979899OPENNESS_LABELS = {100 "open-source": "Open source",101 "open-weights": "Open weights",102 "restricted-weights": "Restricted weights",103 "proprietary": "Closed / proprietary",104 "unknown": "Unknown",105}106107OPENNESS_DEFINITIONS = {108 "open-source": "Weights and code published under an OSI-approved licence that allows commercial use and derivatives.",109 "open-weights": "Weights downloadable under a permissive or Creative Commons licence allowing commercial use; code or data may be missing.",110 "restricted-weights": "Weights downloadable, but the licence restricts commercial use, hosting, derivatives or field of use (community, research and RAIL licences).",111 "proprietary": "Weights are not available; the model is reachable only through an API or a product.",112 "unknown": "Not enough sourced evidence to classify.",113}114115__all__ = ["OPENNESS_CATEGORIES", "OPENNESS_DEFINITIONS", "OPENNESS_DIMENSIONS", "OPENNESS_LABELS", "derive_openness", "normalize_openness", "openness_dimensions"]116