Reusing Deep Learning Models: Challenges and Directions in Software Engineering
James C. Davis Purvish Jajal Wenxin Jiang Taylor R. Schorlemmer Nicholas Synovic George K. Thiruvathukal


















 



 

 
 
 




[itemize]leftmargin=*,noitemsep,topsep=0pt
[enumerate]leftmargin=*





























makecaption
	
	
	
	
makecaption
	

	. 
	
	
Table
















 
 
 
 
 
 
 



 
 






















skipabove=0.5,skipbelow=0.5,align=center


thmTheorem
defnDefinition
lemLemma

framedThm
   



smalldescription
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 

smalldescriptionrq
	 
	 
	 
	 
	 
	 
	 
	 
	 
	 


operators“
operators`'







    
    
    

    
    
    













    
    
    
    
    
    
    
    
    
    

    
    
    
    
    
    
    













section#2#1#3
figureFigureFigures
tableTableTables
theoremTheoremTheorems
thmTheoremTheorems
lemmaLemmaLemmata
equationEqt.Eqts.
GrammarGrammar #1
appendixAppendixAppendices
listingListingListings











































lemmaLemma





















Reusing Deep Learning Models: Challenges and Directions in Software Engineering
    
James C. Davis1, Purvish Jajal1, Wenxin Jiang1,

Taylor R. Schorlemmer1, Nicholas Synovic2, and George K. Thiruvathukal2 

1Department of Electrical & Computer Engineering, Purdue University, West Lafayette, IN, USA

{davisjam,pjajal,jiang784,tschorle}@purdue.edu

2Department of Computer Science, Loyola University Chicago, Chicago, IL, USA

{nsynovic,gthiruvathukal}@luc.edu
All authors are listed in alphabetical order as equal contributors to this manuscript. Please direct correspondence to davisjam@purdue.edu and gthiruvathukal@luc.edu.

    April 29, 2024
=====================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================




Deep neural networks (DNNs) achieve state-of-the-art performance in many areas, including
  computer vision,
  system configuration,
  and question-answering.
However, DNNs are expensive to develop, both in intellectual effort (devising new architectures) and computational costs (training).
Re-using DNNs is a promising direction to amortize costs within a company and across the computing industry.
As with any new technology, however, there are many challenges in re-using DNNs.
These challenges include both missing technical capabilities and missing engineering practices.

This vision paper describes challenges in current approaches to DNN re-use.
We summarize studies of re-use failures across the spectrum of re-use techniques, including conceptual (re-using based on a research paper), adaptation (re-using by building on an existing implementation), and deployment (direct re-use on a new device).
We outline possible advances that would improve each kind of re-use.




Machine learning, Deep learning, Pre-trained models, Re-use, Empirical software engineering, Position, Vision




§ INTRODUCTION
 

 

The long “AI Winter” <cit.> is over.
Machine learning, especially the deep learning paradigm, matches or exceeds human performance in diverse tasks <cit.>.
These tasks include signal processing (sight <cit.>,
  hearing <cit.>,
  smell <cit.>), general reasoning (question-answering <cit.>, synthesizing information), and artistic expression (Dall-E <cit.>, music-making <cit.>).
Although we expect further scientific breakthroughs in performance, many techniques are mature and already being applied to domains such as marketing <cit.>, medicine <cit.>, and autonomous vehicles <cit.>.
Machine learning has entered the domain of the software engineer. 

One key software engineering technique is reuse <cit.>.
To reduce engineering costs, software engineers recognize opportunities to reuse, and they also determine an appropriate reuse paradigm.
Software reuse has been exhaustively studied in traditional software engineering,
  both conceptually ( <cit.>) 
  and 
  empirically ( <cit.>).
However, for deep learning software the study of reuse has just begun.


Deep learning (DL) is an emerging field whose probabilistic nature and data-driven approach differs from traditional software <cit.>.
The engineering community lacks long-term experience in appropriate engineering methods for deep learning <cit.>.


Prior work has characterized the challenges of developing DL software <cit.>.
Yet relatively little is known about DL reuse and the specific challenges engineers face when trying to reuse these models.

In this vision paper, we examine challenges and future directions for the reuse of deep neural networks (DNNs). 
<ref> depicts the three paradigms of DNN reuse that we consider: conceptual reuse, adaptation reuse, and deployment reuse.
Conceptual reuse is the replication of DNN techniques from sources like academic literature.
Adaptation reuse is the modification of pre-trained DNNs to work in a particular use case.
Deployment reuse is the conversion of pre-trained DNNs into forms which operate in different environments.

The paper proceeds as follows.
In <ref>, we discuss the general landscape of work on DNNs.
We define the different types of reuse.
In <ref>, we go into detail about each type of reuse, focusing on 
  the general nature of the challenge and
  prior work that clarifies it.
In <ref>, we focus on
  open problems worthy of community attention.
The scope of this work is to introduce the current conceptual, adaptation, and deployment challenges facing DNN reuse, with a discussion of future directions to address these issues.  
We do not aim to address the (many!) other software engineering challenges related to DNNs, such as when to use them, for what purposes, how to integrate them into existing software systems, and how to debug them.

We hope the community's continued efforts to understand the software engineering implications of working with DNNs will lead to standardization of software engineering practices and the development of tools, both of which were greatly helpful to the advancement of traditional software development. 



§ BACKGROUND
 






 §.§ Engineering Deep Neural Networks
 



  §.§.§ DNN Concepts



Software that implements a DNN has three main components:
  the DNN model itself (a parameterized computational graph);
  a data pipeline (preprocessing to manipulate data into an appropriate format);
  and
  the training mechanisms <cit.>.
Due to the computational costs of training and inference, DNN software is also optimized.
We discuss background for each.
 



  
The DNN Model
A DNN model is a parameterized computational graph <cit.>, the composition of weighted operations <cit.>. 
Layers can be grouped into blocks based on their purpose or frequency of occurrence.
For example, Long Short-Term Memory (LSTM) units are commonly used blocks in recurrent neural networks, and they are particularly designed to handle time-series data <cit.>.
Each layer and block can be designed and tested individually <cit.>, and then integrated into one structure prior to training.
These model sub-elements are shown in <ref>.
The layer sizes must be noted to maintain the shape of the model and ensure that adjustments are made so that the output of one element is the same size as the input of the next.






The architecture of a DNN model will vary based on its purpose.
As an example, in the computer vision domain, typical models have three main components: feature extractor (backbone), decoder [There exists some terminological confusion within the literature on “decoder”.  A model decoder refers to the post-processing component of the model. The data pipeline decoder transforms data into a format that is directly usable by downstream operations.],
and head <cit.>.
The backbone refers to the combination of layers responsible for feature extraction. 
The backbone is usually a large number of sequential layers and the majority of the model training process is to adjust the backbone parameters. 
The decoder, which usually has less layers than the backbone, handles post-processing and serves as a connection between the backbone and the head. 
The head, often the smallest element, is responsible for the final model task (ex: image classification). 
Depending on the model architecture, the components included within the backbone and decoder may vary.



  
The Data Pipeline
A data pipeline
  extracts raw data such as pictures from a storage source (decoder),
  transforms the data into the required input format (parser),
  and loads the transformed data into the GPU (loader).
  
The Extract-Transform-Load (ETL) architecture <cit.> is a common pattern for data pipelines as it simplifies implementation.
It also promotes reuse: different models can share datasets (Extract), vary in their data augmentations (Transform), and have similar final stages (Load).
An example data pipeline is depicted in <ref>.




The data pipeline may also be modified as part of training.
Some changes are for robustness, while others are for performance <cit.>.
For robustness, data augmentations can be added to ensure that a model can perform well not only on well formed input but also on more unusual input <cit.>.
For example, in computer vision, images may be rotated, their colors may be changed, and “filters” may be added such as fog <cit.>.
For performance, the data processing may be optimized to avoid bottlenecks during training.
If a dataset fits in the available system memory then it can be cached.
Else, the dataset must be processed in batches.








  
The Training Mechanisms
The final aspect of a DNN is its training — the identification of parameters for the DNN's operations (“weights”) that yield acceptable functionality <cit.>.
When training, engineers must provide a loss function.
A loss function defines the learning curve of the DNN and is used to adjust the network weights (via inspecting the loss gradient over different parameter changes).

Once the weights are finalized by minimizing the loss function, the loss function itself is no longer required.



  
Optimizations
Based on the device being used for training, the model training time and efficiency will vary drastically <cit.>.
Certain measures can be taken to increase the training efficiency on average.
For example, the data pipeline operations have a strong effect on the training time.
Thus, the operations used during the data pipeline stage must be efficient and based on built-in operations whenever possible (vectorized mathematics rather than for-loops).
Training hyper-parameters such as the number of epochs may be adjusted depending on the training device, (whether it is a CPU, GPU or TPU).

However, optimizing the data pipeline may violate the modular design of the data pipeline.
Breaking module boundaries is a common effect of performance optimization <cit.>.
For example, one common data augmentation applied while training a computer vision model is image blurring.
Image blurring uses a convolution operation which is slow on a CPU but efficient on a GPU.

Transitioning to a GPU only for one operation and then back to the CPU would be time-consuming, but this issue can be tackled by placing the blurring operation at the end of the data pipeline.
This is because the blur operation would immediately be followed up by the DNN training process on the same device.  
Thus, the order of operations can influence the model's training time, and they may be re-arranged in an implementation for efficiency.



  §.§.§ Distributing a DNN Model for re-use


DNN software is sometimes shared, either open-source or as binaries.
The model may be shared alone, or with weights after training.
A DNN model with both architecture and pre-trained weights is called a Pre-Trained Model (PTM) <cit.>.
When a PTM is shared for re-use in an organized manner, it is called a pre-trained model package <cit.>.
The package may include the PTM as well as the names of the authors, the bill of materials (SBOM), license information, versioning, test suite, and so on.



  §.§.§ Engineering “Best Practices”


Major technology companies have shared different kinds of studies on machine learning (ML) best practice (Google <cit.>, Microsoft <cit.>, and SAP <cit.>). Google <cit.> and Microsoft <cit.> provide high level guidelines on the current state of the ML models and potential improvements. 
Breck from Google present 28 quantified tests as well as monitoring needs and propose an easy-to-follow rubric to improve ML production readiness and reduce technical debt <cit.>. 


Rahman present a case study on SAP <cit.>.
They discuss the challenges in software engineering, ML, and industry-academia collaboration and specifically point out the demand for a consolidated set of guidelines and recommendations for ML applications.
Unlike the guidance on high-level architectures and organizational processes shared by Google and Microsoft, we focus on lower-level engineering and programming patterns. 

In addition to views of the industry, there are also works on software engineering practice for the engineering of DL software from academic perspectives <cit.>. 
Zhang present 13 valuable findings in the practice of the engineering life cycle of DL applications <cit.>. 

They indicate that we are in great demand for test cases which could be used to check the correctness of the system functions.

Based on their findings, they give suggestions to both practitioners and researchers including using well-known frameworks, improving the robustness of DL applications, and proposing new bug locating tools and logs.

Serban conducted a survey and quantified practice adoption and demographic characteristics, then propose a positive correlation between practices and effects <cit.>.

However, there has been limited focus on perspective of reusability in the context of DL models. In this vision paper, we present a comprehensive summary of existing reuse paradigms, and propose challenges as well as future directions in the field of software engineering



 §.§ Reuse Paradigms
 

We identify three major reuse paradigms for deep learning models.
These reuse paradigms are related to those proposed by Sommerville <cit.> and Krueger <cit.> for reuse in traditional software engineering, but take somewhat different forms in deep learning engineering.
Specifically, the reuse of deep learning models necessitates unique considerations including the demand for significant computational resources, the need to accommodate specific hardware configurations, and the inherent dependencies on diverse datasets.


    
  * Conceptual Reuse: Replicate and reengineer the algorithms, model architectures, or other concepts described in academic literature and similar sources, integrating the replication into new projects. 
    An engineer might do this because of licensing issues or if they are required to use a particular deep learning framework (TensorFlow) but are reusing ideas previously realized in another deep learning framework (PyTorch) <cit.>.
    This paradigm is related to Sommerville's notion of “abstraction reuse”, where an engineer reuses knowledge but not code directly.
    This paradigm is also related to reproducibility in the scientific sense, since an engineer independently confirms the reported results of a proposed technique <cit.>.
    
    
    
  * Adaptation Reuse: Leverage existing DNN models and adapt them to solve different learning tasks.
    
    An engineer might do this using several techniques, such as transfer learning <cit.> or knowledge distillation <cit.>.
    This form of reuse is suitable if there is a publicly available implementation of an appropriate model (a pre-trained model).
    This paradigm is related to Sommerville's notion of “object/component reuse”, since an engineer must identify existing models suited for a purpose and then customize them for a different task.
    
    
  * Deployment Reuse: Convert and deploy pre-trained DNN models in different computational environments and frameworks.
    This form of reuse is suitable if there is a perfect fit for the engineer's needs, viz. a DNN trained on the engineer's desired task (demonstrating proof of concept in a hackathon).
    This paradigm is related to Sommerville's notion of “system reuse”, since an engineer is reusing an entire model (including its training) and deploying it in the appropriate context.
    Deployment often requires the conversion of a DNN from one representation to another, followed by compilation to optimize it for hardware.




These reuse paradigms are orthogonal.
Multiple forms of reuse are possible in a single engineering project.
For example, an engineering team might
  develop their own version of a decision-making component (conceptual reuse);
  re-use the implementation of a feature extractor DNN as a backbone (adaptation reuse);
  and after training, convert their model to a specialized hardware environment (deployment reuse).



§ CHALLENGES
 

Engineers can incorporate pre-trained models (PTMs) directly into their projects as black boxes, utilizing the APIs offered by model hubs. However, this direct reuse of DNNs could lead to potential trust issues. Previous research has highlighted the existence of discrepancies in terms of accuracy, latency, and architecture among models from various model hubs, even when these models are supposed to implement the same architecture <cit.>. For instance, the ResNet V2 50 <cit.> implementation by Keras incorporates max pool skip connections not outlined in the original paper and utilizes convolutions with larger strides in these residual blocks.
Understanding and addressing these potential trust issues are pivotal for building a more reliable deep learning ecosystem.
However, given the complex nature of DNN configuration, conducting comprehensive audits on all open-source DNNs presents a formidable challenge.


In this section, we describe the open software engineering challenges associated with deep learning model reuse.
Each subsection addresses one of the three types of reuse: conceptual, adaptation, and deployment. 






 §.§ Challenges in Conceptual Reuse of DNNs
 






Conceptual reuse in deep learning primarily takes two forms. 

The first is reproducing results using the same code and dataset. 
The second form is replication and model reengineering, where the same algorithm is implemented (possibly with changes) in a new context, a different deep learning framework or a variation on the original task. 
Each of these forms presents its own set of potential challenges. 













  §.§.§ Reproducibility of Results

Conceptual reuse of DNN necessitates an understanding of state-of-the-art DNN architectures and algorithms. As part of this process, both engineers <cit.> and researchers <cit.> regard the reproduction of reported DNN results as essential for enhancing comprehension and trust.

Reproducibility is considered a key quality of machine learning software, with a particular emphasis on the thorough exploration of experimental variables and the requirement for comprehensive documentation to achieve reproducibility <cit.>. Despite this recognition, achieving DNN reproducibility remains a challenging task and continues to be a focal point within the research community <cit.>.

Many state-of-the-art models are publicly available, but they often exist in the research prototype stage. This stage is typically characterized by an absence of rigorous testing, inadequate documentation, and a lack of considerations for portability. These factors contribute to the ongoing “reproducibility crisis” in the field of deep learning <cit.>.




  §.§.§ Model Replication and Reengineering


Replicating and reengineering DNNs is tricky, even when referring to the original code of the research prototypes <cit.>.
Deep learning frameworks contain many sources of variability that can limit replicability <cit.>.

Jiang described three challenges of DNN replication and reengineering:
  model operationalization, portability of DL operations, and performance debugging <cit.>.
First, the model operationalization, or the difficulty in choosing and validating the correct model for the task, can be confusing for reusers. 
It can be hard to distinguish between multiple implementations, to identify the implemented conceptual algorithm(s), and to evaluate their trustworthiness.
Second, the portability of deep learning operations is inconsistent across frameworks. 

Some deep learning operations only support certain hardware which makes it harder to transfer the implementation to frameworks and environments.
Consequently, performance debugging becomes necessary. This step, however, poses its own set of challenges for engineers because of the stochastic nature of deep learning systems <cit.>.




 












 §.§ Challenges in Adaptation Reuse of DNNs
 






Software engineers use multiple techniques to modify existing DNNs for use in their specific applications.
Even though adapting a model is more efficient than training a model from scratch, engineers still face challenges with adaptation.
Software engineers face both technical (with respect to an adaptation technique) 
and decision-making (with respect to the engineering process)
challenges when adapting a DNN to a particular use case.
This section explores these challenges.



  
Technical Adaptation Challenges

Techniques
Existing deep learning models can be adapted by engineers to new tasks through various techniques, such as transfer learning, dataset labeling, and knowledge distillation <cit.>. 
The practice of reusing DL models as pre-trained models (PTMs) reduces the need for users to train their own models, thereby facilitating rapid model development for an expanded range of tasks <cit.>. 

<ref> shows multiple methods for PTM reuse. 
A PTM provider will train a deep learning model on a dataset, resulting in a DNN checkpoint that includes specific architecture and weight parameters. 
A PTM user can then employ one of the aforementioned methods to adapt this model to a new context or application. 
The resulting model may be more compact, easier to manage, and more resource-efficient <cit.>.












Accuracy and Latency:
Engineers adapt DNNs to different hardware constraints and environments.
For example, the adaptation of DNNs to embedded devices (also known as IoT or Edge devices) often demands significant engineering efforts, encompassing techniques such as model compression and hardware acceleration <cit.>.
Engineers report that they are unaware of “push-button” techniques to adapt DNNs across hardware environments <cit.>.


Fairness and Robustness
In addition to accuracy and latency, engineers reusing Deep Neural Networks (DNNs) may also consider properties such as fairness and robustness <cit.>. A multitude of strategies has been developed to boost the fairness of DNNs, encompassing local interpretability techniques <cit.> and model-agnostic methods <cit.>.
Regarding robustness, recent research has shown that decomposition techniques can contribute to the resilience of DL systems <cit.>. By enabling model modularization, these techniques provide engineers with the flexibility to substitute faulty or inefficient components during the adaptation reuse process <cit.>. This approach underscores the potential benefits of modular design in bolstering the robustness and maintainability of DL systems in diverse deployment scenarios.
Nevertheless, enhancing fairness and reducing algorithmic bias remain considerable challenges that require further exploration and advancement <cit.>.



  
Decision-Making Challenges

Adapting DNNs (as PTMs) is also challenging because of the complicated decision-making process and its costly evaluation loops.
Software engineers must assess if they can reuse a DNN for their task, select a model, adapt the model, evaluate the model, and then deploy the model <cit.>.
Several challenges exist for this decision-making process — they include: model selection, discrepancies, and security and privacy risks <cit.>.


First, selecting an appropriate DNN for reuse is a difficult process for software engineers.
While model registries, such as Hugging Face, are popular in the deep learning community, they often lack infrastructure that provides attributes helpful to the reuse process.
These attributes would include DNN information like model provenance, reproducibility, and portability on top of traditional software information like popularity, quality, and maintenance <cit.>.
On the other hand, missing attributes lead to an increased engineering effort and an expensive evaluation process during model selection.


Next, potential performance discrepancies may arise from poor documentation or non-robust models.
For example, Montes  <cit.> demonstrate that popular models can have significant accuracy and latency discrepancies in their implementations in different model hubs.
Jiang  <cit.> also note the lack of documentation for DNNs on Hugging Face.
These issues make it hard for engineers to adapt models to their tasks.
Engineers must spend additional effort discovering different or undocumented behaviors for the DNNs they choose to reuse.

Lastly, attacks against DNNs pose security and privacy risks to products that rely on them.
Because of the unique aspects of machine learning, new types of attacks have emerged specifically for DNNs.
These attacks can target several aspects of the DNN engineering processing including datasets, model parameters, and even model behaviors.
Many of these attacks take advantage of poor documentation, inadequate security features, and performance discrepancies common among open-source DNNs <cit.>.
Traditional software supply chain threats also apply.
Software supply chains contain actors, artifacts, and operations which interact to create some final software product <cit.>.
When DNNs are reused, they create their own supply chain consisting of models, datasets, maintainers, and training processes <cit.> — see <ref>.

Actors play a similar role in both supply chain types, but DNN artifacts and operations differ because of the nature of machine learning.



We divide attacks against DNNs into four types:

    
  * Train-Time Attacks: These attacks manipulate the model's training procedure (often through a malicious dataset) to affect its behavior <cit.>. 
    A prime example is BadNets <cit.> where a model is trained on a malicious dataset to illicit improper classifications when later used.

    
  * Idle-Time Attacks: These attacks maliciously alter existing DNNs to introduce new behavior. 
    Examples of this type include EvilModel <cit.> and StegoNet <cit.>.
    These examples implant malware directly into the parameters of models, hiding a malicious payload in a trained DNN without significant drops in performance.
    Another example includes LoneNeuron <cit.> which injects a malicious function into an existing DNN. 

    
  * Inference-Time Attacks: These attacks exploit unexpected input-output pairs or recover confidential dataset or parameter information <cit.>.
    For example, Papernot  <cit.> describe a method to generate adversarial inputs for DNNs;
    Shokri  <cit.> describe a method for membership inference attacks to reveal sensitive training data;
    and
    MAZE <cit.> is a model stealing attack which recreates the target model without access to its dataset.
    

    
  * Traditional Supply Chain Attacks: These attacks compromise upstream software components with the intent of exploiting downstream DNN vulnerabilities <cit.>. 
    Ladisa  <cit.> and Ohm  <cit.> enumerate several classifications of attacks on traditional open-source supply chains.
    These attacks are also applicable to DNN supply chains.
    For example, typo-squatting (whereby an attacker uses similar package names) could confuse DNN users into using the wrong PTM.






Our results:  

Closing remark or synthesis:  
Change this
While there is progress to understand adaptation reuse, further work is needed to advance the state of the field. See Section <ref> below.









 §.§ Challenges in Deployment Reuse of DNNs
 

Once a deep learning model has been developed, possibly through conceptual or adaptation reuse, it must then be deployed.
This deployment is not simple, so we classify this as a form of reuse rather than just a final step.
Deployment faces its own series of challenges because the development environment of DNNs (for training and testing) may differ substantially from deployment environments.

For this reason, engineers typically face two main types of deployment reuse challenges: interoperability between frameworks and hardware, and trust establishment in DL supply chains.



  
Deep Learning Interoperability

The advent of DNNs has brought computing platforms that specialize in accelerating their execution <cit.>, consequently, there has been a greater demand for tools enabling the deployment of DNNs onto diverse hardware. 
Deep learning compilers <cit.> such as TVM <cit.>, OpenVINO <cit.>, and Glow <cit.> aim to bridge this gap by taking DL models and converting them to optimized binary code targeting the multitude of hardware available.


Prior work has focused on developing <cit.> and testing DL compilers <cit.>, as well as empirical studies of DL compiler failures <cit.>. 

The introduction of DL compilers largely addresses the challenges of deploying to diverse hardware but it introduces challenges in the use of compilers. 
Many compilers do not support all frameworks thus the interoperability of frameworks and compilers poses a challenge in the deployment of DNNs.
To address this common representations such as ONNX act as intermediaries between DL frameworks and compilers <cit.>.
<ref> depicts how common representations can act as intermediaries between frameworks and compilers.
Model converters are used to convert between framework representations and ONNX such as tf2onnx <cit.>.




Prior work on interoperability has largely focused on common representations or model conversion.
Common representations such as ONNX <cit.> and NNEF <cit.> have been introduced to further interoperability.
Model converters like MMDnn <cit.> allow for faithful conversions between frameworks, or allow conversion to and from common representations. 


Though this type of software is largely understudied in a DL context.

Studies on converters have largely focused on 

DNN properties after conversion <cit.>.
ONNX conformance test generation has been proposed to ensure ONNX implementations match the ONNX specification <cit.>.







Recently, model converter failures have been studied in the context of ONNX <cit.>.
It was found that model converters exhibit two common failure symptoms: crashes and wrong outputs. 
Crashes are largely due to the converter being unable to convert operators of the DNN to ONNX. 
This can be due to the converter not yet implementing this conversion, or ONNX not supporting the operator. 

Wrong outputs are when a successfully converted model is not semantically equivalent to the original model.
Such failures suggest that engineers should weigh the risks of model conversion against potential benefits.



  
Establishing Trust in DL Supply Chains
Establishing trust in traditional software products is a difficult task <cit.>.
This is no different for DNNs.
In <ref> we discuss the wide array of challenges engineers face when attempting to adapt existing DNNs to solve different tasks.
Specifically, we mention many of the attacks which threaten how engineers can reuse models and that the reuse of DNNs creates a supply chain structure.
These attacks make the decision-making process difficult when adapting DNNs, but they also make it difficult for engineers to establish trust in the DNNs they are about to deploy.
In other words, once an organization decides to release a DNN into the wild, they have a hard time making sure users can trust it.











Novel characteristics of the DNN supply chain introduce new methods for attackers to degrade trust <cit.>.
Furthermore, users are often either unwilling or unable to check for these attacks <cit.>.
This means users must blindly trust the DNNs they download from open-source registries.
Although traditional security features such as software signing may help to verify file integrity, many attacks slip by these simple measures.
As an example, <ref> illustrates a common dependency structure for DNNs that makes it hard for users to validate DNN models and datasets at deployment time (see caption).
Cryptographic methods <cit.> exist to verify that particular files have not changed through deployment, but the relationships between files — and in particular, DNN dependency relationships — are not easily verified in this way.
Traditional software dependencies can be verified by checking dependencies through methods like Software Bills of Materials (SBOMs) and reproducible builds <cit.>.
Similar techniques are more difficult for DNNs because of non-determinism and training costs <cit.>.


Our results:  Our results suggest...

Closing remark or synthesis:  Change thisWhile there is progress to understand deployment reuse, further work is needed to advance the state of the field. See Section <ref> below.










§ DIRECTIONS
 



 §.§ Directions in Conceptual Reuse of DNNs
 



Comparing the conceptual reuse of DNNs to that of traditional software <cit.>, DNN reuse is mainly based on research products while traditional software reuse is focused on the outputs from engineering teams.
Consequently, the goal and focus of DNN reuse are different <cit.>.
Considering the differences of conceptual DNN reuse, we propose several research directions, including promoting reusable artifacts and developing engineering tools.



  §.§.§ Evaluating Artifacts for Reuse


Although conceptual reuse is primarily focused on methods presented in research papers and technical reports, there is a growing effort to include artifact evaluation to support the claims of conference and journal papers.
Typical artifact evaluation when it comes to machien learning includes a minimum-viable prototype, training and evaluation datasets, and results.
While the focus of artifact evaluation in machine learning is primarily on reproducibility of a paper's claims, evaluating the software engineering of these accepted artifacts would seemingly be a key ingredient of ensuring that a research artifact has some hope of being reproduced by others at the conceptual level (and beyond).
As more and more publication venues incentivize artifacts, an empirical software engineering study to evaluate the software engineering process across these venues, specifically in support of reuse, is a topic worthy of further study.
Separately, we would also encourage artifact evaluation to include a checklist of minimal expectations, which is already a practice in software-focused journals such as the Journal of Open Source Software.













  §.§.§ Testing Tools
 



Testing tools and frameworks are among the high-impact practices in software engineering and greatly improve the reuse potential of software libraries in general.
Testing can also help to improve the DNN reuse process.
Researchers have developed some tools for automated deep learning  testing <cit.>.
Despite these advancements, there is a noticeable lack of adoption of specialized testing techniques for conceptual DNN reuse.

We urge the research community to consider the application of comprehensive testing tools for conceptual DNN reuse tasks.
Since conceptual reuse includes comprehending documentation such as research papers, checklists and tools for extracting knowledge would be helpful.
Validation tools might leverage pre-existing model implementations.
For instance, emerging fuzzing technologies could use adversarial inputs to verify the accuracy of early-stage training, using the original model as a benchmark.
Refining unit testing methods could also reduce overall costs. We encourage exploration of strategies for effective unit and differential testing in DNN software.











 §.§ Directions in Adaptation Reuse of DNNs
 



Adapting DNNs presents challenges, including complicated decision-making processes, costly evaluation loops, and potential security and privacy risks.
We describe several research directions that support adaptation reuse:
  large-scale model audit,
  infrastructure optimization,
  recommendation systems,
  and
  attack detection. 



  §.§.§ Model Audit

Prior work found that the trustworthiness of DNNs are concerning due to the lack of DNN transparency. Future work can measure attributes of DNNs that are not currently accessible to engineers. For example, DL-specific attributes can be extracted from provided documentation, source code, and metadata <cit.>.
Potential risks could be identified by measuring the discrepancies among different DNN models.
These measurements could largely improve the transparency of DNNs and therefore facilitate better adaptation reuse.



  §.§.§ Infrastructure Optimization

Another challenge of adaptation reuse is the model selection.
Engineers struggle to compare different DNNs and identify a good way to adapt to their downstream task. To facilitate the adaptation, researchers can identify different approaches to support the model selection process.
For instance, providing enhanced documentation, similar to the badges used by GitHub, could offer greater transparency about the capabilities and limitations of a model. This could facilitate a more informed model selection process.

Standardization tools can also play a pivotal role. For example, the use of large language models (LLMs) could facilitate the extraction of metadata for model cards, enabling a systematic comparison of models' performance and requirements. Additionally, a standardized model interface or API could be developed. This would provide a uniform way to interact with and evaluate different models, thereby simplifying the model selection process.




  §.§.§ PTM Recommendation Systems

Existing literature highlights the challenges associated with technical adaptation and the resulting decision-making process to select a suitable starting point (<ref>).
Numerous studies have sought solutions to the problem of PTM selection.
For instance, You et al. proposed a transferability metric called LogME that is used to assess and rank a list of models <cit.>. Certain works have also employed deep learning techniques to enhance the AutoML process <cit.>. Despite these advancements, open-source PTMs remain under-utilized <cit.>, suggesting the need for a robust PTM recommendation system to aid engineers in adaptation reuse. We encourage researchers to consider various factors during the adaptation reuse process, including diverse fine-tuning approaches, necessary engineering efforts, and the trustworthiness of the model.



  §.§.§ Attack Detection Tool

Our work indicates that specific attack detection tools are currently missing in DL model registries. For example, Hugging Face only uses ClamAV which can only detect traditional malware but not applicable for DL-specific attacks <cit.>. The potential risks existing in the model registries make the adaptation reuse harder for engineers. Developing detection tools for DL-specific attacks can therefore improve the trustworthiness of DNNs and help engineers easier adapt existing DNNs.
Detection tools for copyright infringement such as DeepJudge <cit.> might be adapted for this purpose.



 §.§ Directions in Deployment Reuse of DNNs
 

In <ref> we identified interoperability and trust as key challenges for DNN deployment.
Here, we identify future research directions that may help engineers deploy DNNs more effectively.

Interoperability plays a key role in the deployment of DNNs, namely the use of model converters (ONNX) to connect frameworks to compilers (as shown in <ref>).
ONNX model converter failures have been studied <cit.>.
Converters often are not compatible with all ONNX operators, moreover, converted models often are not semantically equivalent to their original models.

Based on prior work, we propose the following directions related to enhancing interoperability, converter testing, and increasing DNN supply chain security.

    
  * Model Converter Testing: Model converters often produce models that are semantically inequivalent to the original models. 
    Consequently, testing to identify the source of semantic inequivalence in converters in important.
    
    
  * Supporting Model Converter Engineering: ONNX model converters suffer from incompatibilities with the evolution of intermediate representation.
    This results in converters needing updates as ONNX updates to ensure the specification is faithfully followed.
    It follows that these efforts must be supported. 
    Specifically, engineering efforts can be better focused by understanding operator popularity, and domain-specific languages can be used to automatically generate converter code.
    Additionally, these efforts can be avoided with the development of a small stable operator set that can represent all possible operators that can be used in a deep learning model <cit.> — similar to RISC <cit.> and JVM <cit.>.

    
  * Supply Chain Security for DNNs: The software engineering community has been working on systems such as TUF <cit.> and Sigstore <cit.> to increase the usability and effectiveness of signatures for package managers.
    The community has also began to develop standards such as Supply-chain Levels for Software Artifacts (SLSA) <cit.> and Software Supply Chain Best Practices from the Cloud Native Computing Foundation (CNCF) <cit.> to help engineers implement appropriate supply chain security measures.
    Similar efforts should be taken to create systems and standards for the DNN community, determining which concepts still apply to DNN environments and which concepts need to be changed.
    For example, <ref> shows how traditional signing methods may be inadequate in DNN supply chains.
    Future work could consider how to preserve the relationship between a particular DNN and the dataset(s) it was trained on.
    This might be accomplished by watermarking <cit.> or some form of limited reproduction, whereby users validate model-dataset relationships via retraining.
    
    
    




 §.§ Assessing the Software Engineering Process of DNNs
 





As with any other software engineering effort, conceptualizing, adapting, and deploying DNNs is a measurable process.
A high-quality software artifact is typically associated with an effective software engineering process <cit.>.
By measuring the software engineering process of DNNs, engineers can gain insights into the quality of the DNN.
These process measurements can assist engineering teams in evaluating DNNs as dependencies within their projects.

There are no tools that quantify what is and is not an effective software engineering process tailored to DNNs.
Existing understanding <cit.> and tooling <cit.> can be applied to the DNN engineering process.
However, as the reuse, conceptualizing, adapting, and deploying process of DNNs is different than traditional software projects, it is unclear as to what is and is not a good engineering process for DNNs.

<ref> illustrates the challenges of measuring the DNN engineering (and reuse) process, suggesting the difficulties in mining to elicit empirical data about effective processes.
Unlike traditional software engineering packages, DNN packages cannot be analyzed in isolation;[Of course, traditional software should also not be analyzed in isolation, but more useful data may be derived from an isolated view in that case.] the training dataset, config, and documentation all provide crucial information as to both what the model is, as well as the performance is.
Due to the additional information, the data extraction that is required to mine a DNN repository is more complex. 

To assist in the mining efforts of DNNs, the PTMTorrent dataset <cit.> provides a dataset of ∼60,000 PTMs from 5 model registries.
This dataset contains the full git repository for each DNN package, including the model, documentation, and configuration information.
The follow-up PeaTMOSS dataset adds connections to use in open-source projects from GitHub <cit.>.





















































































§ DISCUSSION
 












 §.§ DNN Reuse as an Accelerator


Reuse is a key engineering technique because it offers such substantial cost savings <cit.>.
Whether a software engineer reuses via the conceptual paradigm, the adaptation paradigm, or the deployment paradigm (or all three!), they benefit.










Our purpose in framing deep learning engineering in terms of reuse is to emphasize the potential benefits of deep learning reuse to software engineers.
However, we acknowledge that at present the benefit may not always be realized.
For example, in recent interviews we found that skilled software engineers sometimes take months to identify a good model to adapt and fine-tune to reach acceptable performance (adaptation paradigm) <cit.>.
We are not aware of any direct comparisons in engineering cost between from-scratch development and reuse development.
However, we expect that advances in DNN reuse techniques can substantially lower the current costs.
We challenge the research community to show the way forward.



 §.§ DNN Reuse in the Age of Foundational Models




The trend in deep learning has been to develop larger and larger models, supporting multiple modes of input and capable of solving a wide range of problems.
The resulting models are generalists.
One might wonder, when a single model like GPT-4 can solve math problems and interpret jokes <cit.>, why researchers and engineers should be concerned with model reuse as opposed to simply model application.
While large-language models at the time of writing are appearing to become less open as part of an industry “arms race” of sorts, investigating reuse is important regardless of whether building proprietary and/or open source deep learning solutions (similar to the corresponding situation in general software development).
We point out two weaknesses of the current trend towards a single powerful model.

First, this approach centralizes power in the hands of those who control the model <cit.>.
Foundational models such as ChatGPT and GPT-4 are trained by one organization with unclear data sources, and they impose a client-server model where one organization mediates all responses.
Centralization and unmonitored data processing bode poorly for user privacy <cit.> and the concomitant problems of a monopoly <cit.>.

Second, this approach is highly energy-consumptive <cit.>.
Resource-intensive models can achieve state-of-the-art performance, but sometimes this is not necessary <cit.>.
In resource-constrained environments, such as those involved in real-time decision-making, fast and adequate may suffice.
In this context, the reuse paradigms allow engineers to explore alternative approaches that trade off resource utilization and performance.

















§ CONCLUSION
 





This paper described the challenges of re-using deep neural networks (DNNs). 
DNNs have demonstrated exceptional performance in various domains, but their development and computational costs remain significant.
DNN re-use can reduce development costs.
However, re-use presents its own set of challenges, encompassing technical capabilities and engineering practices.
We hope this work improves understanding DNN re-use.
We discussed three types of reuse — conceptual, adaptation, and deployment.
By identifying the gaps in current re-use practices, we contribute to the understanding of DNN reuse and offer insights for future research in this area.















§ ACKNOWLEDGMENTS


We acknowledge financial support from
 Google,
 Cisco,
 and
 NSF awards 2229703, 2107230, 2107020, and 2104319. 



IEEEtran

 



