ML API 需要何种类型的契约?
What Kinds of Contracts Do ML APIs Need?
AI总结:
通过对Stack Overflow上四大ML库的实证研究,发现ML API最需要的契约是检查单参数约束和API调用顺序,建议结合行为与时间契约挖掘方法以在流水线早期捕获错误。
摘要:
最近的研究表明,机器学习(ML)程序容易出错,并呼吁为 ML 代码引入契约。如同契约式设计方法学中的契约一样,契约有助于记录 API 并帮助 API 用户编写正确的代码。问题是:什么样的契约能为 API 用户提供最大的帮助?我们特别关注什么样的契约能帮助 API 用户在 ML 流水线的早期阶段捕获错误。我们描述了一项关于 Stack Overflow 上四个最常被讨论的 ML 库(TensorFlow、Scikit-learn、Keras 和 PyTorch)帖子的实证研究。对于这些库,我们的研究提取了 413 条非正式(英文)API 规范。我们使用这些规范来理解以下问题。ML 契约违规背后的根本原因和影响是什么?ML 契约违规是否存在共同模式?何时理解 ML 契约需要高级的 ML 软件专业知识?在 API 级别检查契约是否有助于在早期 ML 流水线阶段检测违规行为?我们的关键发现是,ML API 最常需要的契约要么是检查 API 单个参数上的约束,要么是检查 API 调用的顺序。软件工程社区可以采用现有的契约挖掘方法来挖掘这些契约,以促进对 ML API 的深入理解。我们还注意到需要结合行为契约挖掘和时间契约挖掘方法。我们报告了所需 ML 契约的类别,这可能会对契约语言的设计者有所帮助。
英文摘要:
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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。