PeaTMOSS: Mining Pre-Trained Models in Open-Source Software

Wenxin Jiang, Jason Jones, Jerin Yasmin, Nicholas Synovic, Rajeev Sashti, Sophie Chen, George K. Thiruvathukal, Yuan Tian, James C. DavisarXiv 2023

Abstract

Developing and training deep learning models is expensive, so software engineers have begun to reuse pre-trained deep learning models (PTMs) and fine-tune them for downstream tasks. Despite the wide-spread use of PTMs, we know little about the corresponding software engineering behaviors and challenges. To enable the study of software engineering with PTMs, we present the PeaTMOSS dataset: Pre-Trained Models in Open-Source Software. PeaTMOSS has three parts: a snapshot of (1) 281,638 PTMs, (2) 27,270 open-source software repositories that use PTMs, and (3) a mapping between PTMs and the projects that use them. We challenge PeaTMOSS miners to discover software engineering practices around PTMs.

Introduction

The landscape of deep learning has undergone a significant transformation, moving from a "train-from-scratch" paradigm to a "reuse-and-fine-tune" engineering practice. Pre-trained models (PTMs) have become central to modern software development, with platforms like Hugging Face serving as the "NPM" or "PyPI" for AI artifacts. Despite this widespread adoption, the software engineering (SE) community has lacked the visibility needed to understand how these models are integrated, maintained, and tested within real-world applications.

Conceptual overview of PTMs as dependencies for downstream GitHub projects.

Methodology

To bridge this gap, we developed PeaTMOSS (Pre-Trained Models in Open-Source Software). The creation of this dataset involved a multi-stage pipeline:

  1. ETL Pipeline: We built an Extract-Translate-Load pipeline to scrape metadata from Hugging Face and PyTorch Hub, normalizing it into a uniform SQLite schema.
  2. Signature Collection: We manually identified "signatures"—the specific library calls (like from_pretrained in the Transformers library) used to load models across 23 different AI libraries.
  3. Sourcegraph Search: Using the Sourcegraph CLI, we searched millions of GitHub repositories for these signatures to find projects that likely use PTMs.
  4. Static Analysis: To filter out false positives, we used the Scalpel framework to perform static analysis on the discovered code. By building Abstract Syntax Trees (ASTs), we could confirm that a model was actually being loaded and extract the specific model names being used as arguments.

The PeaTMOSS Dataset

PeaTMOSS is released in two versions to support different research needs:

  • Metadata Version (7.12 GB): A SQLite database containing the metadata for PTMs (commits, issues, pull requests) and a subset of GitHub project metadata.
  • Full Version (48.2 TB): A massive collection that includes the actual PTM package contents (weights, model cards) and the full git history of the main branches of the associated GitHub projects.

The dataset covers 281,638 PTM packages and 27,270 GitHub projects, with 44,337 verified links between them.

Key Insights and Results

PeaTMOSS enables researchers to treat PTMs as software dependencies. This perspective allows for the application of traditional SE metrics—like "dependency lag" or "issue density"—to the world of AI. By mapping which models are used where, we enable the study of the AI supply chain. For example, if a popular "base" model is found to have a security vulnerability, PeaTMOSS can help identify every downstream project at risk.

Distribution of PTM usage across different AI libraries.

Our analysis reveals a clear hierarchy in the ecosystem. As shown in the figure above, the transformers library is the dominant gateway for PTM integration, followed by spacy and sentence-transformers. This concentration highlights the critical role of a few key frameworks in the modern AI software stack.

Conclusion

PeaTMOSS provides the first comprehensive map of the PTM ecosystem in open-source software. By linking artifacts to applications, it opens new avenues for research into AI supply chains, testing practices, and the evolution of AI-powered systems. The authors conclude by proposing a research roadmap with 15 questions to guide the community in improving how we build AI-powered software.

Summary updated

BibTeX
@misc{jiang2023peatmoss,
  author = {Wenxin Jiang and Jason Jones and Jerin Yasmin and Nicholas Synovic and Rajeev Sashti and Sophie Chen and George K. Thiruvathukal and Yuan Tian and James C. Davis},
  title = {{PeaTMOSS: Mining Pre-Trained Models in Open-Source Software}},
  year = {2023},
  eprint = {2310.03620},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2310.03620},
}
Figure