What Kinds of Contracts Do ML APIs Need?

Recent work has shown that Machine Learning (ML) programs are error-prone and called for contracts for ML code. Contracts, as in the design by contract methodology, help document APIs and aid API users in writing correct code. The question is: what kinds of contracts would provide the most help to API users? We are especially interested in what kinds of contracts help API users catch errors at earlier stages in the ML pipeline. We describe an empirical study of posts on Stack Overflow of the four most often-discussed ML libraries: TensorFlow, Scikit-learn, Keras, and PyTorch. For these libraries, our study extracted 413 informal (English) API specifications. We used these specifications to understand the following questions. What are the root causes and effects behind ML contract violations? Are there common patterns of ML contract violations? When does understanding ML contracts require an advanced level of ML software expertise? Could checking contracts at the API level help detect the violations in early ML pipeline stages? Our key findings are that the most commonly needed contracts for ML APIs are either checking constraints on single arguments of an API or on the order of API calls. The software engineering community could employ existing contract mining approaches to mine these contracts to promote an increased understanding of ML APIs. We also noted a need to combine behavioral and temporal contract mining approaches. We report on categories of required ML contracts, which may help designers of contract languages.

READ FULL TEXT

page 11

page 12

page 13

page 14

page 21

page 24

page 31

research
06/27/2019

What Do Developers Ask About ML Libraries? A Large-scale Study Using Stack Overflow

Modern software systems are increasingly including machine learning (ML)...
research
04/25/2023

What Causes Exceptions in Machine Learning Applications? Mining Machine Learning-Related Stack Traces on Stack Overflow

Machine learning (ML), including deep learning, has recently gained trem...
research
09/14/2017

Combining Static and Dynamic Contract Checking for Curry

Static type systems are usually not sufficient to express all requiremen...
research
08/23/2018

Runtime verification in Erlang by using contracts

During its lifetime, a program suffers several changes that seek to impr...
research
09/04/2023

MLGuard: Defend Your Machine Learning Model!

Machine Learning (ML) is used in critical highly regulated and high-stak...
research
05/18/2022

Realizability Checking of Contracts with Kind 2

We present a new feature of the open-source model checker Kind 2 which c...
research
04/21/2017

Governing Governance: A Formal Framework for Analysing Institutional Design and Enactment Governance

This dissertation is motivated by the need, in today's globalist world, ...

Please sign up or login with your details

Forgot password? Click here to reset