39.5  Ecosystem

Most models in this book were trained from scratch, on Fashion-MNIST or on The Time Machine, so that every step stayed visible. A real project rarely starts that way. It starts from someone else’s work: a pretrained checkpoint, a public dataset, the code released with a paper. Suppose you want a model that sorts the support tickets of a small company. A search of the Hugging Face Hub for text classifiers returns more than a hundred thousand candidates, each with a download count and many with a model card and a benchmark score. Which one should you try first? Will its reported score hold on your tickets? And will the model you load next year be the one you evaluated today?

These are questions about evidence and identity rather than about training. Answering them means treating external artifacts the way a software engineer treats dependencies: find them where the community keeps them, judge them by measurements on your own task and not by rankings alone, and record which version you used and under which license. Without that record a result cannot be reproduced. A checkpoint downloaded in good faith can also run code on your machine unless its file format is checked first. This section follows the hardware sections because the choice of a model and the choice of a machine constrain each other. We look first at where models, datasets and papers are found, then at how to read benchmarks and leaderboards, at a few sources that keep a practitioner informed, and finally at how to pin, check and license what we download.

39.5.1 Sources of Models, Data, and Papers

39.5.1.1 Models

The Hugging Face Hub listed more than three million public models as of November 2026. Each model lives in a Git repository, with a model card and integrations with the libraries used in this book. Popularity does not establish suitability, so search by task, check recency and download counts, and read the model card. Several other sources complement the Hub:

  • ModelScope, Alibaba’s hub, hosts a large part of the Chinese open-model ecosystem, with more than 280,000 models as of November 2026.
  • Kaggle Models hosts curated weights wired into Kaggle’s competition and notebook infrastructure (Section 39.2).
  • The Ollama library is a short, curated list of models packaged for a local runtime (Section 39.7).
  • timm provides a broad collection of vision backbones, and Civitai hosts community image-generation checkpoints and LoRA adapters.

39.5.1.2 Datasets

Hugging Face Datasets (more than a million public datasets as of November 2026) and Kaggle cover most supervised needs. For pretraining-scale text, the lineage runs from raw Common Crawl through filtered derivatives. FineWeb held 15 trillion tokens at its 2024 release and more than 18.5 trillion after later versions added newer crawls, and the multilingual FineWeb2 applies the same pipeline to more than 1,000 languages. FineWeb is now a common open baseline for pretraining, the role that C4 played after its release with T5 in 2019. For image–text pairs, DataComp provides an alternative to LAION with an emphasis on controlled dataset construction and evaluation. Older and very large corpora are sometimes available only through Academic Torrents. Whatever the source, datasets have versions, licenses and documented failure modes, just as models do. Read a dataset’s documentation before adopting it.

39.5.1.3 Papers and Code

New work appears first on arXiv. Hugging Face Papers curates a daily front page and links papers to their code. It took over that role when Papers with Code, for years the index from papers to code and benchmarks, closed in July 2025; its address now redirects there, and its historical data survives as a frozen archive. The episode is a reason not to make a project depend on one external index. Semantic Scholar and alphaXiv help with search and discussion. Released code usually lives on GitHub, where issue history, recent commits and reported reproductions are evidence beyond the paper itself.

39.5.2 Benchmarks and Leaderboards

A leaderboard ranks models by one measurement, and a project needs a model that does well on another, its own task. A static benchmark also ages: models saturate it, or its questions leak into training data. Two retirements show both. The Open LLM Leaderboard, which ran fixed benchmarks on more than ten thousand open models, replaced its benchmarks in 2024 after models saturated them and was retired in 2025. In February 2026 OpenAI stopped reporting SWE-bench Verified, a set of real GitHub issues for coding agents, citing contamination and tests that reject correct fixes, and recommended the harder SWE-bench Pro instead. Model selection therefore combines several kinds of evidence:

  • Arena, formerly LMArena and Chatbot Arena, ranks models by blind pairwise human preference. It measures what users of the site prefer on average, which may differ from what the target task needs.
  • LiveBench limits contamination by releasing new questions regularly and withholding the newest ones.
  • Capability benchmarks such as SWE-bench for coding agents follow a benchmark-per-capability pattern; mathematics, long context and safety have their own.
  • Artificial Analysis measures quality, price and latency across models and providers.
  • OpenRouter rankings order models by the number of tokens customers send them, a revealed preference that is most instructive where it disagrees with the quality leaderboards.

After forming a shortlist, build a small evaluation set from the target task and run each candidate on it. On the target task, models that sit next to each other on a leaderboard often differ by much more than their leaderboard scores do, and not always in the same order. The evaluation discipline used throughout this book (held-out data, meaningful baselines, error analysis) applies to choosing models just as it does to training them.

39.5.3 Information Sources

New models, papers and tools appear daily, and nobody can read every announcement. A small, deliberate set of sources is easier to judge than a continuous stream. One workable set, as of November 2026:

  • r/LocalLLaMA, a community that reports open-weight releases, quantizations, hardware measurements and reproduction attempts.
  • The daily selection of Hugging Face Papers instead of the hundreds of papers that arXiv receives each day.
  • One newsletter, such as Andrew Ng’s The Batch, Jack Clark’s Import AI, or Sebastian Raschka’s Ahead of AI.
  • The GPU MODE lectures and community for systems, and the EleutherAI community for open research.

Social media is where labs announce results. Use it to discover them, and cite the paper or the model card instead. The introduction of this chapter (Chapter 39) lists long-form references.

39.5.4 Managing External Artifacts

39.5.4.1 Pinned Revisions

A model is more than its weights. The tokenizer, preprocessing, configuration, license and revision all determine whether a result can be reproduced (Figure 39.5.1).

Figure 39.5.1: A reusable model artifact combines configuration, weights, preprocessing, documentation, and an immutable revision.

Hub repositories are Git repositories, and the branch main moves when the owner pushes a commit. To load the same files tomorrow, download a specific commit:

from huggingface_hub import snapshot_download

path = snapshot_download(
    repo_id="organization/model-name",
    revision="0123456789abcdef",          # an immutable commit, not main
    allow_patterns=["*.json", "*.safetensors"],
)

A small manifest records the model identity explicitly. In production, add file hashes, library versions and an evaluation record:

from dataclasses import asdict, dataclass
import json

@dataclass(frozen=True)
class Artifact:
    repository: str
    revision: str
    task: str
    license: str
    parent: str | None = None

artifact = Artifact(repository="organization/model-name",
                    revision="0123456789abcdef",
                    task="text-generation", license="apache-2.0")
print(json.dumps(asdict(artifact), indent=2))
{
  "repository": "organization/model-name",
  "revision": "0123456789abcdef",
  "task": "text-generation",
  "license": "apache-2.0",
  "parent": null
}

The same pinning applies to derived artifacts. A LoRA adapter without the revision of its base model is incomplete, and a quantized conversion (GGUF or AWQ, see Section 39.7) is a new artifact whose numerical fidelity to the source must be checked. The field parent of Artifact records the artifact that a derived one was made from.

39.5.4.2 Security and Licenses

A downloaded model is an input to your software supply chain, with the same security and licensing questions as any third-party library:

  • Prefer safetensors, a container that holds only tensors. Legacy pickle-based checkpoints can execute arbitrary code when loaded. The Hub scans such files for known malicious patterns, which reduces the risk but does not remove it.
  • trust_remote_code=True runs Python from the repository on your machine. Read and pin that code, and use the flag only when the architecture requires it.
  • “Open” spans a wide range of licenses: permissive Apache or MIT weights, acceptable-use licenses with commercial thresholds, research-only releases, and gated models whose terms you accept per account. Record the license of the pinned revision, since a repository can change its license between revisions.
  • Hub clients cache every file they download, and tens to hundreds of gigabytes in ~/.cache/huggingface are common. hf cache ls lists the cache, hf cache rm deletes a repository or revision, and hf cache prune removes revisions that no branch or tag points to any longer, along with incomplete downloads.

With these habits, a model found on a hub becomes a dependency you can justify, reproduce and audit. What they do not settle is whether the model is good enough for your task; only an evaluation on your own data answers that, and the exercises below show how large such an evaluation must be to separate two models.

39.5.5 Summary

Pretrained models, datasets and papers are found mostly on the Hugging Face Hub and its complements, and on arXiv. Preference rankings, contamination-resistant benchmarks, capability benchmarks and price-and-latency data each measure something different, and benchmarks are retired as models saturate or memorize them, so no single leaderboard settles a choice. The choice of a model rests on a small evaluation built from your own task, with error bars. Every external artifact is a supply-chain dependency: pin its revision, prefer safetensors, review remote code, and record its license and parent.

39.5.6 Exercises

  1. Rating gaps on the Arena. Arena (formerly LMArena) fits the Bradley–Terry model of Section 15.3 to pairwise votes (Chiang et al. 2024) and reports the scores on the Elo scale. Ignoring ties, model A then beats model B with probability \[P(A \succ B) = \frac{1}{1 + 10^{-(R_A - R_B)/400}}, \tag{39.5.1}\] where \(R_A\) and \(R_B\) are the reported scores.

    1. Compute this probability for score gaps \(R_A - R_B\) of 10, 20, 50, and 100 points.
    2. Linearize \(P(A \succ B)\) around \(R_A = R_B\), and show that a gap \(R_A - R_B\) estimated from \(v\) independent votes between two models of similar strength has a standard error of about \(347/\sqrt{v}\) points. How many votes are needed before a 20-point gap lies two standard errors from zero?
    3. Model A leads model B by 20 points over all votes. On the 10% of the votes cast on prompts that resemble your task, B wins 60%. What is A’s win rate on the remaining votes? What does the result imply for choosing between A and B?
  2. What a revision pins. A Hugging Face repository can be addressed by the branch main, by a tag such as v1.0, by a pull-request ref such as refs/pr/3, or by a 40-character commit hash.

    1. Which of these identifiers always refer to the same files, and which can refer to different files tomorrow? Who can move each of them? Dataset repositories are addressed the same way, and HuggingFaceFW/fineweb keeps each earlier version in a branch named after it, such as v1.3.0. Which identifier of that dataset should a training manifest record?
    2. A pinned commit of a repository contains a config.json whose auto_map entry reads "AutoModelForCausalLM": "other-org/shared-code--modeling.MyModel". With trust_remote_code=True, transformers then imports modeling.py from the repository other-org/shared-code. Read get_class_from_dynamic_module in transformers/dynamic_module_utils.py. Which revision of modeling.py runs when you pass only revision with your commit, and what must the manifest therefore record?
    3. Name three inputs that lie outside all the repositories involved and still change the outputs of the loaded model when every repository is pinned to a commit.
  3. [code] Code on load. Python’s pickle rebuilds an object by calling whatever callable the object’s __reduce__ method returns, with the arguments it returns.

    1. Write a class whose __reduce__ returns (print, ("code ran during load",)). Save an instance with torch.save inside a dictionary that also holds a tensor, and load the file with torch.load twice: with the default arguments and with weights_only=False. What happens in each case? Which file of the repository openai-community/gpt2, which also holds model.safetensors, tf_model.h5, and flax_model.msgpack, is read by the same unpickling machinery?
    2. With weights_only=True, torch.load still interprets the pickle opcode stream but admits only an allowlist of classes and functions. In PyTorch 2.5.1 and earlier this restriction could be bypassed, so that loading a crafted file ran arbitrary code (CVE-2025-32434). Why does a safetensors loader need no such allowlist? Which risks remain when you load a safetensors model from a repository you do not trust?
  4. [extended] Task-specific model selection. ● Choose a task you know well, such as answering support questions in your field or extracting fields from documents you handle.

    1. Shortlist three models using Arena or LiveBench, one benchmark for the capability your task needs, and Artificial Analysis. Where do the rankings disagree? Explain each disagreement by what the disagreeing leaderboards measure.
    2. Build an evaluation set from your task. Choose its size with the paired-comparison standard-error analysis of Section 36.5.2.6 for the smallest difference in accuracy that would change your choice. Add a random baseline and a simple heuristic baseline, such as the most frequent answer or keyword matching.
    3. Run the shortlist and the baselines on the set. Report each score with its standard error and each difference between two models with its paired standard error. Which differences are resolved, and does your ranking agree with the leaderboards?

    Adapted from Chip Huyen, Machine Learning Systems Design, “Model selection”.

  5. [code] A tensor container from scratch. ● A safetensors file consists of an 8-byte unsigned little-endian integer \(N\), an \(N\)-byte UTF-8 JSON header, and a byte buffer. The header maps each tensor name to its dtype (such as "F32" or "I64"), its shape, and its data_offsets, a pair [begin, end) of byte positions relative to the start of the buffer. An optional key __metadata__ maps strings to strings. Tensors are stored in little-endian byte order and row-major layout.

    1. Write save_tensors(path, tensors, metadata) and load_tensors(path) for dictionaries of NumPy arrays, using only json, struct, and numpy. Check that a round trip reproduces the arrays. If the safetensors package is installed, also check that safetensors.numpy.load_file reads your files.
    2. Add an argument to load_tensors that loads one named tensor through np.memmap without reading the rest of the buffer.
    3. Read only the header of model.safetensors from revision 607a30d783dfa663caf39e06633721c8d4cfcd7e of openai-community/gpt2, using two HTTP range requests, and count the stored values from the shapes. Why does the count exceed the 124 million parameters of GPT-2 small?
    4. List the checks that a loader must perform before it trusts a header from an unknown source. Build one malformed file that violates each check, and confirm that your loader rejects all of them.

Discussions