Update thesis
This commit is contained in:
parent
0e1f8e6215
commit
73c6a1a0ec
23 changed files with 560 additions and 70 deletions
|
|
@ -1,11 +1,11 @@
|
||||||
\begin{abstract}
|
\begin{abstract}
|
||||||
|
|
||||||
\absdiv{Background}
|
\absdiv{Background}
|
||||||
Despite its long-standing history, artificial intelligence (AI) has only recently started enjoying widespread industry awareness and adoption; partly thanks to the prevalence of accessible frameworks exposing state-of-the-art models through simple API-s. However, in order to achieve robust deployments, the successful integration of AI components demands strong engineering methods. Concerningly, a tendency seems to be unfolding: even though industry professionals already have access to numerous frameworks for deploying AI correctly and responsibly, case-studies and developer surveys have found that a considerable fraction of deployments do not follow best practices.
|
Despite its long-standing history, artificial intelligence (AI) has only recently started enjoying widespread industry awareness and adoption; partly thanks to the prevalence of accessible frameworks exposing state-of-the-art models through simple API-s. In order to achieve robust production deployments, the successful integration of AI components demands strong engineering methods. Concerningly, a tendency seems to be unfolding: even though industry professionals already have access to frameworks for deploying AI correctly and responsibly, case-studies and developer surveys have found that a large fraction of deployments do not follow best practices.
|
||||||
\absdiv{Objective}
|
\absdiv{Objective}
|
||||||
This thesis sets out to investigate the reasons behind the asymmetry between the adoption of accessible AI libraries and preexisting reusable solutions to robust deployments. A software framework called \textit{GreatAI} is designed which aims to facilitate \underline{G}eneral \underline{R}obust \underline{E}nd-to-end \underline{A}utomated \underline{T}rustworthy AI deployments while attempting to overcome the practical drawbacks of similar, existing frameworks.
|
This thesis sets out to investigate the reasons behind the asymmetry between the adoption of accessible AI libraries and existing reusable solutions to robust deployments. A software framework called \textit{GreatAI} is designed which aims to facilitate \underline{G}eneral \underline{R}obust \underline{E}nd-to-end \underline{A}utomated \underline{T}rustworthy AI deployments while attempting to overcome the practical drawbacks of its predecessors.
|
||||||
\absdiv{Method}
|
\absdiv{Method}
|
||||||
The utility of \textit{GreatAI} is validated using the principles of design science methodology through iteratively designing its API and implementation along with the text mining pipeline of a commercial product. Subsequently, interviews are conducted among practitioners for validating the generalisability of the design.
|
The utility of \textit{GreatAI} is validated using the principles of design science methodology through iteratively designing its API and implementation along with the text mining pipeline of a commercial product. Subsequently, interviews are conducted with practitioners for validating the generalisability of the design.
|
||||||
\absdiv{Results}
|
\absdiv{Results}
|
||||||
To do.
|
To do.
|
||||||
\absdiv{Conclusions}
|
\absdiv{Conclusions}
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,11 @@ However, the successful integration of AI components into production-ready appli
|
||||||
|
|
||||||
Concerningly, a peculiar tendency seems to be unfolding: even though industry professionals already have access to numerous frameworks for deploying AI correctly and responsibly, case-studies and developer surveys have found that a considerable fraction of deployments do not follow best practices \cite{serban2020adoption,haakman2021ai,amershi2019software,de2019understanding,sculley2015hidden}. Utilising state-of-the-art machine-learning (ML) models has become reasonably simple; applying them properly is as difficult and nuanced as ever.
|
Concerningly, a peculiar tendency seems to be unfolding: even though industry professionals already have access to numerous frameworks for deploying AI correctly and responsibly, case-studies and developer surveys have found that a considerable fraction of deployments do not follow best practices \cite{serban2020adoption,haakman2021ai,amershi2019software,de2019understanding,sculley2015hidden}. Utilising state-of-the-art machine-learning (ML) models has become reasonably simple; applying them properly is as difficult and nuanced as ever.
|
||||||
|
|
||||||
This thesis sets out to investigate the reasons behind the apparent asymmetry between the adoption of accessible AI libraries and existing reusable solutions for robust AI deployments. It is hypothesised that the primary reason for the underwhelming adoption rate of best practises is the short supply or professionals equally proficient in the domains of both data science and software engineering. Nevertheless, even without their presence, practitioners could rely on frameworks for automated mature deployment processes. However, the barrier of entry for using such existing libraries is too high, especially when compared with the complexity of AI-libraries.
|
This thesis sets out to investigate the reasons behind the apparent asymmetry between the adoption of accessible AI libraries and existing reusable solutions for robust AI deployments. It is hypothesised that the primary reason for the underwhelming adoption rate of best practices is the short supply or professionals equally proficient in the domains of both data science and software engineering. Nevertheless, even without their presence, practitioners could rely on frameworks for automated mature deployment processes. However, the barrier of entry for using such existing libraries is too high, especially when compared with the complexity of AI-libraries.
|
||||||
|
|
||||||
Therefore, a software framework, named \textit{GreatAI}, is designed and its design is presented in this thesis. The principal motivation behind the construction of \textit{GreatAI} is to easily facilitate the responsible and robust deployment of algorithms and models in an attempt to overcome the practical drawbacks of other, similar frameworks. Its name stands for its main aim --- namely --- to assist creating \underline{G}eneral \underline{R}obust \underline{E}nd-to-end \underline{A}utomated, and \underline{T}rustworthy AI deployments.
|
Therefore, a software framework --- called \textit{GreatAI} --- is designed and its design is presented in this thesis. The principal motivation behind the construction of \textit{GreatAI} is to facilitate the responsible and robust deployment of algorithms and models by designing an accessible API in an attempt to overcome the practical drawbacks of other, similar frameworks. Its name stands for its main aim: to assist easily creating \underline{G}eneral \underline{R}obust \underline{E}nd-to-end \underline{A}utomated, and \underline{T}rustworthy AI deployments.
|
||||||
|
|
||||||
The utility of \textit{GreatAI} is validated using the principles of design science methodology \cite{wieringa2014design} through iteratively designing its API and implementation along with the text mining pipeline for a commercial product in collaboration with ScoutinScience B.V. The goal of the aforementioned product is to evaluate technical transfer opportunities in scientific publications. Subsequently, a survey is conducted among practitioners for validating the generalisability of the design.
|
The utility of \textit{GreatAI} is validated using the principles of design science methodology \cite{wieringa2014design} through iteratively designing its API and implementation along with the text mining pipeline for a commercial product in collaboration with ScoutinScience B.V. The goal of the aforementioned software suite is to evaluate technical transfer opportunities in scientific publications. Subsequently, interviews are conducted with practitioners for validating the generalisability of the design.
|
||||||
|
|
||||||
\section{Research questions}
|
\section{Research questions}
|
||||||
|
|
||||||
|
|
@ -19,32 +19,38 @@ I hypothesise that facilitating the adoption of AI deployment best practices is
|
||||||
\begin{rqlist}
|
\begin{rqlist}
|
||||||
\item Does the complexity of AI deployment frameworks hinder industrial projects?
|
\item Does the complexity of AI deployment frameworks hinder industrial projects?
|
||||||
\item What is an effective way of decreasing the complexity of existing frameworks?
|
\item What is an effective way of decreasing the complexity of existing frameworks?
|
||||||
\item Does \textit{GreatAI}'s design improve the efficiency of a team working with AI while also introducing best practices?
|
\item Does \textit{GreatAI}'s design improve the efficiency of working with AI while also introducing best practices?
|
||||||
\item Can the design of \textit{GreatAI} decrease the barrier of entry of applying best practices for other teams?
|
\item Can the design of \textit{GreatAI} decrease the barrier of entry for applying best practices in other contexts?
|
||||||
\end{rqlist}
|
\end{rqlist}
|
||||||
|
|
||||||
In this case, complexity is used to refer to the difficulty faced by professionals (data scientists and software engineers alike) when integrating libraries with their solutions. This could also be described as the barrier of entry or steepness of the learning curve. If the aforementioned hypothesis is correct, the adoption of best practices can be efficiently increased by decreasing this complexity.
|
In this case, complexity is used to refer to the difficulty faced by professionals (data scientists and software engineers alike) when integrating libraries with their solutions. This could also be described as the barrier of entry or steepness of the learning curve. If the aforementioned hypothesis is correct, the adoption of best practices can be efficiently increased by decreasing this complexity.
|
||||||
|
|
||||||
AI deployment best practices entail the technical steps that ought to be taken in order to achieve robust, end-to-end, automated, and trustworthy deployments. The exact definitions of these are shown in Section \ref{section:requirements}. The best practices with which the \textit{GreatAI} design is concerned are a subset of those compiled by Serban et al. \cite{serban2020adoption}.
|
AI deployment best practices entail the technical steps that ought to be taken in order to achieve robust, end-to-end, automated, and trustworthy deployments. These are detailed in Section \ref{section:requirements}.
|
||||||
|
|
||||||
The existence question regarding the problem itself (\textbf{RQ1}) is answered by reviewing the literature of the more than 30 published case-studies. \textbf{RQ2} and \textbf{RQ3} are closely connected, the design and evaluation phases utilised to answer them follow an iterative process. They are examined in Chapter \ref{chapter:design} and Chapter \ref{chapter:case} respectively. The final evaluation step is to ascertain the capability of the framework design to generalise beyond a single subdomain and problem context. This question, \textbf{RQ4}, is investigated through interviews with industry professionals in Chapter \ref{chapter:interviews}.
|
The existence question regarding the problem itself (\textbf{RQ1}) is answered by reviewing the literature of the more than 30 published case-studies. \textbf{RQ2} and \textbf{RQ3} are closely connected, the design and evaluation phases utilised to answer them follow an iterative process. They are examined in Chapter \ref{chapter:design} and Chapter \ref{chapter:case} respectively. The final evaluation step is to ascertain the capability of the framework design to generalise beyond a single subdomain and problem context. This question, \textbf{RQ4}, is investigated through interviews with industry professionals in Chapter \ref{chapter:interviews}.
|
||||||
|
|
||||||
\section{Core ideas}
|
\section{Requirements} \label{section:requirements}
|
||||||
|
|
||||||
Existing frameworks oftentimes suffer from the entanglement of numerous levels of abstractions. Complexity may be effectively reduced by preferring deep and narrow modules \cite{ousterhout2018philosophy}. Instead of exposing each implementation detail and encouraging users to interact with most of them, many of these can be abstracted away. Where configuration may be helpful for advanced users, default values can still be chosen automatically while providing an override option where necessary \cite{ousterhout2018philosophy,hermans2021programmer}.
|
The best practices (which will be referenced throughout the thesis) with which the \textit{GreatAI} design is concerned are a subset of those compiled by Serban et al. \cite{serban2020adoption}. The core requirements --- sets of covered best practices --- for a software solution that has the potential of improving our problem context are presented in the following along with some explanation and clarification of each of them.
|
||||||
|
|
||||||
For example, tracing the evaluations and the model versions used in a distributed fashion is very much expected of a trustworthy system. Hence, turning this feature on by default but allowing opting-out from it can result in less scaffolding required from the library's user. It also decreases their up-front cognitive load which by definition flattens the learning-curve \cite{hermans2021programmer}. Similar features can be imagined for providing an access API for the algorithms and for giving feedback, marking outliers, etc.
|
\paragraph{General} Albeit not explicitly in the list of best practices, compatibility is vital in encouraging adoption. Large projects oftentimes end up depending on numerous packages, each of which may impose some restrictions on the code: since these all have to be satisfied simultaneously, this can result in severe constraints on the application.
|
||||||
|
|
||||||
There are best practices which require more complex features, such as using shared infrastructure for storing the models and data \cite{serban2020adoption}. For simplifying this, we can reuse familiar API-s, such as the \texttt{open()} method from Python. A method is proposed which provides the same interface, however, the backing storage for it is a mixture of local disk space and any S3-compatible storage. Various features may be implemented using close to trivial API-s, including support for shadow deployments, automated regression tests, integrated documentation and model cards, etc.
|
The open-source scene of data-related libraries is vibrant. To take the example of data validation, there are at least 4 popular choices which offer varying but similar features: \href{https://github.com/SeldonIO/alibi-detect}{Alibi detect}, \href{https://github.com/PAIR-code/facets}{Facets}, \href{https://github.com/great-expectations/great_expectations}{Great Expectations}, and Data Linter \cite{hynes2017data}. The responsibility of choosing the most fitting solution falls on the user, thus, they should not be limited in this by \textit{GreatAI}.
|
||||||
|
|
||||||
Providing the users with only a high-level of abstraction is not unheard of in the domain of practical AI platforms. Many software-as-a-service products offer features for hiding the details of machine learning applications. However --- as we will see in Section \ref{section:existing} --- these tend to abstract away the details of both data science and AI-engineering, overall hindering the development process. The design proposed here aims to simplify only the deployment related concepts.
|
The programming language (PL) of the library should be its only non-general property. Fortunately, the de facto PL for data science is Python, hence, implementing the library in it should not significantly limit its applicability.
|
||||||
|
|
||||||
Nonetheless, simple API-s come with a high technical cost. The library has to implement these in a way that still allows high-performance in production \cite{kleppmann2017designing} and avoids being tied to specific libraries or technologies. Inspiration for the latter may be gained from the pipelines of Prado et al. \cite{prado2020bonseyes}: they show that more freedom can be achieved with plug-and-play steps and preconfigured defaults.
|
\paragraph{Robustness} in software development can be achieved by preparing the application to gracefully handle errors, even unexpected ones \cite{bishop1998robust}. Errors can and will happen in practice: storing and investigating what has led to them is required to prevent future ones. In the case of ML, errors might not be as obvious to detect as in more traditional applications (see the above mentioned data validators). Even if a single feature's value falls outside the expected distribution, unexpected results can happen. In cases where this might lead to real-world repercussions, extra care has to be taken to construct as many safe-guards as feasible. \textit{GreatAI} should support its clients in doing so.
|
||||||
|
|
||||||
With these kept in mind, \textit{GreatAI} has the potential to bridge the gap between data science and software engineering. Stemming from the bidirectional nature of bridges, we can look at the framework from two perspectives: for professionals closer to the field of data science, it provides an automatic scaffolding of software facilities that are required for deploying, monitoring, and iterating on their models. For software engineers, it highlights the necessary steps required for robust and improvable deployments, while at the same time saves them from the grunt work of implementing these constructs. While most importantly, it serves as a proxy for the design decisions through which they can be tested and evaluated in their practical context.
|
\paragraph{End-to-end} In this case, it refers to end-to-end feedback. That is, feedback should be gathered on the real-world performance of the system, and this should be taken into account when designing/training the next iteration of the model. Static datasets may fail to capture the changing nature of real-life and can become outdated if they are not revised continuously. A well packaged deployment should make it trivial to integrate new training data.
|
||||||
|
|
||||||
TODO
|
\paragraph{Automated} The available time of data scientists and software engineers is limited and expensive. For this reason, humans should only be involved when their involvement is necessary. Steps in the development process that can be automated without negative consequences must be automated in order to achieve efficient development processes and let the experts focus on the issues that require their attention the most.
|
||||||
|
|
||||||
|
\paragraph{Trustworthy} As detailed by the \textit{Ethics guidelines for trustworthy AI}\footnote{\href{https://digital-strategy.ec.europa.eu/en/library/ethics-guidelines-trustworthy-ai}{digital-strategy.ec.europa.eu/en/library/ethics-guidelines-trustworthy-ai}}, human oversight, transparency, and accountability are some of the key requirements for trustworthy AI applications. For increasing public acceptance and trust while minimising negative societal impact, trustworthiness is essential.
|
||||||
|
|
||||||
|
These requirements were chosen stemming from their general importance and potential to be mostly handled (implemented) by a software framework\footnote{The terms \textit{framework} and \textit{library} are used interchangeably in this work stemming from their vague and often holistic differentiation.}. That is why, these provide an ideal initial direction for tackling the issue. Of course, these do not cover all best practices, for instance, the ones relating to organisational processes fall outside the realm of software engineering.
|
||||||
|
|
||||||
|
\newpage
|
||||||
|
|
||||||
\section{Structure}
|
\section{Structure}
|
||||||
|
|
||||||
The rest of the thesis is organised as follows: Chapter \ref{chapter:background} approaches the problem and the state-of-the-art from three perspectives: the trends of AI library API design, the experiences gained from practical applications, and a comparison of existing deployment options. Next, the methodology utilised for the subsequent chapters is described in Chapter \ref{chapter:methods}. The design cycle is broken into two chapters, Chapter \ref{chapter:design} and \ref{chapter:case}. The former describes the main technological contributions of the novel design, while the latter details the specifics of the practical use-case and the framework's interaction with it. The results are further validated by conducting a survey in Chapter \ref{chapter:survey}. The thesis is concluded in Chapter \ref{chapter:conclusion}.
|
The rest of the thesis is organised as follows: Chapter \ref{chapter:background} approaches the problem and the state-of-the-art from three perspectives: the trends of AI library API design, the experiences gained from practical applications, and a comparison of existing deployment options. Next, the methodology utilised for the subsequent chapters is described in Chapter \ref{chapter:methods}. The design cycle is broken into two chapters, Chapter \ref{chapter:design} and \ref{chapter:case}. The former clarifies the scope and describes the design principles, while the latter details the specifics of the practical use-case and the framework's interaction with it, and technological contributions of the novel design. The results are further validated by conducting interviews with industry professionals in Chapter \ref{chapter:interviews}. The thesis is concluded in Chapter \ref{chapter:conclusion}.
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,11 @@ Despite the long-standing history of artificial intelligence (AI), industry awar
|
||||||
|
|
||||||
In the following, the context of the problem is presented from three perspectives. Starting with its possible cause: the democratisation of state-of-the-art AI algorithms and models. Subsequently, the challenges encountered when applying AI in practice is outlined by case studies and survey data. Lastly, the existing approaches and solutions are introduced.
|
In the following, the context of the problem is presented from three perspectives. Starting with its possible cause: the democratisation of state-of-the-art AI algorithms and models. Subsequently, the challenges encountered when applying AI in practice is outlined by case studies and survey data. Lastly, the existing approaches and solutions are introduced.
|
||||||
|
|
||||||
\section{Accessible AI}
|
\section{Accessible AI} \label{section:accessible-ai}
|
||||||
|
|
||||||
Most companies prefer not to develop new models but instead reuse prior ones \cite{bosch2021engineering} and they are able to do so increasingly easier. In recent years, there has been a proliferation of highly accessible AI libraries. For example, let us consider the domain of natural language processing (NLP). There are various options for finding AI solutions that work out of the box: FLAIR \cite{akbik2019flair} and Huggingface's transformers \cite{wolf2019huggingface} let developers access the state-of-the-art models and methods in only a couple of lines of code (in many cases 2 or 3). With the advent of fine-tuneable models such as BERT \cite{devlin2018bert} and its many improved variations, Huggingface enables developers to leverage vast amounts of knowledge learned by any particular model and fine-tune it for their specific use case. The API for this is also extremely accessible.
|
Most companies prefer not to develop new models but instead reuse prior ones \cite{bosch2021engineering} and they are able to do so increasingly easier. In recent years, there has been a proliferation of highly accessible AI libraries. For example, let us consider the domain of natural language processing (NLP). There are various options for finding AI solutions that work out of the box: FLAIR \cite{akbik2019flair} and Huggingface's transformers \cite{wolf2019huggingface} let developers access the state-of-the-art models and methods in only a couple of lines of code (in many cases 2 or 3). With the advent of fine-tuneable models such as BERT \cite{devlin2018bert} and its many improved variations, Huggingface enables developers to leverage vast amounts of knowledge learned by any particular model and fine-tune it for their specific use case. The API for this is also extremely accessible.
|
||||||
|
|
||||||
It is not just these two packages, the list of readily available tools for language processing is vast: SpaCy \cite{srinivasa2018natural}, Gensim \cite{vrehuuvrek2011gensim}, and scikit-learn \cite{pedregosa2011scikit} are other great examples. The situation is similar in all subdomains of artificial intelligence: some domain expertise is, admittedly, beneficial but not a hard-requirement. This, combined with the exponentially increasing computing power affordably available to consumers and business alike \cite{sun2019summarizing}, results in AI that is accessible by many.
|
It is not just these two packages, the list of readily available tools for language processing is vast: SpaCy \cite{srinivasa2018natural}, Gensim \cite{vrehuuvrek2011gensim}, and scikit-learn \cite{pedregosa2011scikit} are other great examples. The situation is similar in all subdomains of artificial intelligence: some domain expertise is --- admittedly --- beneficial but not a hard-requirement. This, combined with the exponentially increasing computing power affordably available to consumers and business alike \cite{sun2019summarizing}, results in AI that is accessible by many.
|
||||||
|
|
||||||
\section{State of the industry} \label{section:industry}
|
\section{State of the industry} \label{section:industry}
|
||||||
|
|
||||||
|
|
@ -18,7 +18,7 @@ When looking at ML code in practice through the lens of technical debt, Sculley
|
||||||
|
|
||||||
Haakman et al. \cite{haakman2021ai} interviewed 17 people at ING which is a well-known fintech company undergoing a digital transformation to embrace AI. They found that the existing tools for ML do not meet the particularities of the field. For instance, a Feature Engineer working in the Data \& Analytics department explained that regular spreadsheets are preferred over existing solutions like MLFlow for keeping track of experiment results. The reason behind this is simplicity. Additionally, multiple other interviewees described the need to self-develop (or highly-customize) dashboards for monitoring deployed models which results in many non-reusable solutions across the company for the same problem. The authors conclude that there is a research gap between the ever-improving SOTA techniques and the challenges of developing real-world ML systems. In short, additional tool support is needed for facilitating the ML lifecycle.
|
Haakman et al. \cite{haakman2021ai} interviewed 17 people at ING which is a well-known fintech company undergoing a digital transformation to embrace AI. They found that the existing tools for ML do not meet the particularities of the field. For instance, a Feature Engineer working in the Data \& Analytics department explained that regular spreadsheets are preferred over existing solutions like MLFlow for keeping track of experiment results. The reason behind this is simplicity. Additionally, multiple other interviewees described the need to self-develop (or highly-customize) dashboards for monitoring deployed models which results in many non-reusable solutions across the company for the same problem. The authors conclude that there is a research gap between the ever-improving SOTA techniques and the challenges of developing real-world ML systems. In short, additional tool support is needed for facilitating the ML lifecycle.
|
||||||
|
|
||||||
In a case study at Microsoft, Amershi et al. \cite{amershi2019software} interviewed 14 people and surveyed another 551 AI and ML professionals from the company. One of the main concerns surfaced was relating to automation which is a vital cross-cutting concern, especially for testing. At the same time, a human-in-the-loop is still favoured. The survey data pointed out the difficulty posed by integrating AI, especially in the case of less experienced respondents. This was elaborated on by describing the preferences of software engineers as striving for elegant, abstract, modular, and simple systems; in contrast, data tends to be of large volume, context-specific and heterogeneous. Reconciling these inherent differences requires significant effort, nevertheless, Microsoft manages to overcome this with a highly sophisticated internal infrastructure.
|
In a case study at Microsoft, Amershi et al. \cite{amershi2019software} interviewed 14 people and surveyed another 551 AI and ML professionals from the company. One of the main concerns surfaced was relating to automation which is a vital cross-cutting concern, especially for testing. At the same time, a human-in-the-loop is still favoured. The survey data pointed out the difficulty posed by integrating AI, especially in the case of less experienced respondents. This was elaborated on by describing the preferences of software engineers as striving for elegant, abstract, modular, and simple systems; in contrast, data tends to be of large volume, context-specific and heterogeneous. Reconciling these inherent differences requires significant effort, nevertheless, Microsoft manages to overcome this with highly sophisticated internal infrastructure.
|
||||||
|
|
||||||
Using AI is not unique to large companies, in a study conducted with the collaboration of three startups \cite{de2019understanding}, the aim was to fill in the gap of understanding how professionals develop ML systems in small companies. Overall, the results showed they have similar priorities to that of large companies, including an emphasis on the online monitoring of deployed models. However, less structure is present in the development lifecycle, as one interviewee had explained: some steps are left out from time to time because they are forgotten about.
|
Using AI is not unique to large companies, in a study conducted with the collaboration of three startups \cite{de2019understanding}, the aim was to fill in the gap of understanding how professionals develop ML systems in small companies. Overall, the results showed they have similar priorities to that of large companies, including an emphasis on the online monitoring of deployed models. However, less structure is present in the development lifecycle, as one interviewee had explained: some steps are left out from time to time because they are forgotten about.
|
||||||
%The paper does not give detail about the use or in-house development of ML tools.
|
%The paper does not give detail about the use or in-house development of ML tools.
|
||||||
|
|
@ -36,7 +36,7 @@ Given the nature of problems faced and amount of available resources, it is not
|
||||||
|
|
||||||
IBM's AutoAI \cite{wang2020autoai} promises to provide automation for the entire machine learning lifecycle, including deployment. It is a closed-sourced, paid service which --- from their documentation --- seems to focus mostly on non-technical users by providing them with a UI for authoring models. The restrictions caused by the encapsulation of the entire process can be severe. The challenges of integration were emphasised above \cite{sculley2015hidden}. Additionally, an engineer working on Microsoft's comparable solution, the Azure ML Studio, highlighted that once users gain enough understanding of ML, such visual tools can get in their way, and they may need to seek out other solutions \cite{amershi2019software}. Unfortunately, the main value proposition of Azure ML Studio is also to provide a UI for laypeople, and it has also been set to be retired by 2024. Its successor is Azure Machine Learning which shares many similarities with AWS's SageMaker suite \cite{joshi2020amazon}.
|
IBM's AutoAI \cite{wang2020autoai} promises to provide automation for the entire machine learning lifecycle, including deployment. It is a closed-sourced, paid service which --- from their documentation --- seems to focus mostly on non-technical users by providing them with a UI for authoring models. The restrictions caused by the encapsulation of the entire process can be severe. The challenges of integration were emphasised above \cite{sculley2015hidden}. Additionally, an engineer working on Microsoft's comparable solution, the Azure ML Studio, highlighted that once users gain enough understanding of ML, such visual tools can get in their way, and they may need to seek out other solutions \cite{amershi2019software}. Unfortunately, the main value proposition of Azure ML Studio is also to provide a UI for laypeople, and it has also been set to be retired by 2024. Its successor is Azure Machine Learning which shares many similarities with AWS's SageMaker suite \cite{joshi2020amazon}.
|
||||||
|
|
||||||
SageMaker offers the most comprehensive suite of tools and service; most importantly it has a set of features called \textit{AWS SageMaker MLOps}. This provides easy and/or default implementations for industry best practices described by Serban et al. \cite{serban2020adoption,serban2021practices}. Among others, it promotes the use of CI/CD, model monitoring, tracing, model versioning, storing both data and models on shared infrastructure, numerous collaboration tools, etc. Nonetheless, SageMaker does not enjoy universal adoption as indicated by survey data. The cause of this may be the lack of self-hosting option and its relatively high prices: many companies prefer on-premise hosting for privacy and financial reasons \cite{bosch2021engineering}. Additionally, vendor lock-in, and possibly --- in the case where it is not already used for the project --- the initial effort required for setting up AWS integration could be possible deterrents.
|
SageMaker offers the most comprehensive suite of tools and service; most importantly it has a set of features called \textit{AWS SageMaker MLOps}. This provides easy and/or default implementations for industry best practices described by Serban et al. \cite{serban2020adoption,serban2021practices}. Among others, it promotes the use of CI/CD, model monitoring, tracing, model versioning, storing both data and models on shared infrastructure, numerous collaboration tools, etc. Nonetheless, SageMaker does not enjoy universal adoption as indicated by the survey data. The cause of this may be the lack of self-hosting option and its relatively high prices: many companies prefer on-premise hosting for privacy and financial reasons \cite{bosch2021engineering}. Additionally, vendor lock-in, and possibly --- in the case where it is not already used for the project --- the initial effort required for setting up AWS integration could be possible deterrents.
|
||||||
|
|
||||||
When it comes to open-source libraries, we can find the MLOps libraries of both TensorFlow and PyTorch: TensorFlow Extended (TFX) \cite{baylor2017tfx} and TorchX\footnote{\href{https://pytorch.org/torchx/latest/}{pytorch.org/torchx/latest}}. TFX comes with a more mature set of features with the caveat that initial time-investment is needed for their setup. The features of TorchX only concern the distributed deployment to a wide range of providers, including Kubernetes, AWS Batch, or Ray. There is no augmentation for the SE4ML best practices. Given the tight coupling between these libraries and their corresponding ML frameworks, they cannot generalise to models\footnote{The Open Neural Network Exchange (\href{https://onnx.ai/}{onnx.ai}) format could be an option for overcoming these incompatibilities, however, a more universal support is needed for seamless integration.} or algorithms of other frameworks and technologies.
|
When it comes to open-source libraries, we can find the MLOps libraries of both TensorFlow and PyTorch: TensorFlow Extended (TFX) \cite{baylor2017tfx} and TorchX\footnote{\href{https://pytorch.org/torchx/latest/}{pytorch.org/torchx/latest}}. TFX comes with a more mature set of features with the caveat that initial time-investment is needed for their setup. The features of TorchX only concern the distributed deployment to a wide range of providers, including Kubernetes, AWS Batch, or Ray. There is no augmentation for the SE4ML best practices. Given the tight coupling between these libraries and their corresponding ML frameworks, they cannot generalise to models\footnote{The Open Neural Network Exchange (\href{https://onnx.ai/}{onnx.ai}) format could be an option for overcoming these incompatibilities, however, a more universal support is needed for seamless integration.} or algorithms of other frameworks and technologies.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
\chapter{Methods} \label{chapter:methods}
|
\chapter{Methods} \label{chapter:methods}
|
||||||
|
|
||||||
The chosen methodology for this study is Design Science which emphasises the need to design and investigate artifacts in their context \cite{wieringa2014design}. It consists of a design and an empirical cycle. The purpose of the former is to improve a problem context with a new or redesigned artifact. While in the latter, the problem is investigated and its treatment is validated concurrently. The design cycle shares many similarities with Action Research \cite{davison2004principles}, where the researchers attempt to solve a real-world problem while simultaneously studying the experience of solving said problem.
|
The chosen methodology for this study is Design Science which emphasises the need to design and investigate artifacts in their context \cite{wieringa2014design}. It consists of a design and an empirical cycle. The purpose of the former is to improve a problem context with a new or redesigned artifact. While in the latter, the problem is investigated and its potential treatment is validated concurrently. The design cycle shares similarities with Action Research \cite{davison2004principles}, where the researchers attempt to solve a real-world problem while simultaneously studying the experience of solving said problem.
|
||||||
|
|
||||||
As for the empirical cycle, the pragmatist approach is taken since the value of this research lies in its utility. Moreover, pragmatism adopts an engineering approach to research \cite{shull2007guide} which is inline with the philosophy of design science. Additionally, as no research method is without flaws, it is imperative to try to compensate their weaknesses by applying multiple methods. Hence, the study also relies on interviews with potential professionals for validating the design decisions of \textit{GreatAI}.
|
As for the empirical cycle, the pragmatist approach is taken since the value of this research lies in its utility. Moreover, pragmatism adopts an engineering approach to research \cite{shull2007guide} which is inline with the philosophy of design science. Additionally, as no research method is without flaws, it is imperative to try to compensate their weaknesses by applying multiple methods. Hence, the study also relies on interviews with professionals for validating the design decisions of \textit{GreatAI}.
|
||||||
|
|
||||||
\section{Problem context}
|
\section{Problem context}
|
||||||
|
|
||||||
The problem context is the difficulty in responsibly transitioning (while following best practices) from prototype industrial AI applications to production-ready deployments. With the possible treatment being libraries with high-level API-s and a set of default settings. It is important to note that \textit{GreatAI} is merely a proof-of-concept\footnote{As of now.}, and its aim is to serve as the proxy for the design decisions behind it. Through this, the design can be indirectly evaluated. Hopefully, a by-product will be a library that can be successfully applied to this problem context.
|
The problem context is the difficulty in responsibly transitioning (while following best practices) from prototype industrial AI applications to production-ready deployments. With the possible treatment being libraries with high-level API-s and a set of default settings. It is important to note that \textit{GreatAI} is merely a proof-of-concept, and its aim is to serve as the proxy for the design decisions behind it. Through this, the design can be indirectly evaluated. Hopefully, a by-product will be a library that can be successfully applied to this problem context.
|
||||||
|
|
||||||
The practical cases used for the evaluation are further elaborated in Chapter \ref{chapter:case}. In short, they focus on individual components of a growing commercial platform with the aim to find tech-transfer opportunities in academic publications. The main input of the system as a whole are individual PDF-files while the output is a list of metrics describing various aspects of the paper, such as interesting sentences, scientific domains, and the scientific contribution. The output also includes a predicted score used for ranking. This ranking is subsequently used by the business developers of Technology Transfer Offices (TTO-s) of multiple Dutch and German universities who later give feedback on the results.
|
The practical cases used for the evaluation are further elaborated in Chapter \ref{chapter:case}. In short, they focus on individual components of a growing commercial platform with the aim of finding tech-transfer opportunities in academic publications. The main input of the system as a whole are individual PDF-files while the output is a list of metrics describing various aspects of the paper, such as interesting sentences, scientific domains, and the scientific contribution. The output also includes a predicted score used for ranking. This ranking is subsequently processed by the business developers of Technology Transfer Offices (TTO-s) of multiple Dutch and German universities who later give feedback on the results.
|
||||||
|
|
||||||
Overall, this problem context carries the properties of typical industry use-cases: it utilises a wide-range of text mining methods, contains complex interactions between the services, benefits from the integration of end-to-end feedback, and has to provide the clients with a platform that they can rely on in their organisation's core processes. Since the final ranking affects real people, explainability and robustness are also central questions.
|
Overall, this problem context carries the properties of typical industry use-cases: it utilises a wide-range of text mining methods, contains complex interactions between the services, benefits from the integration of end-to-end feedback, and has to provide the clients with a platform that they can rely on in their organisation's core processes. Since the final ranking affects real people, explainability and robustness are also central questions.
|
||||||
|
|
||||||
|
|
@ -20,6 +20,8 @@ by finding a less complex framework design
|
||||||
which is easier to adopt
|
which is easier to adopt
|
||||||
to decrease the negative externality of misused AI.}
|
to decrease the negative externality of misused AI.}
|
||||||
|
|
||||||
However, before generalising, the design of the framework is iteratively refined using the feedback acquired from applying it in a practical context which in this case is the development of smaller and the rewriting of larger AI-based applications. The treatment is finding a simpler design which still leads to high-quality deployments. \textbf{RQ2} and \textbf{RQ3} captures this process; for investigating the feedback acquired from iteratively working --- which is the definition of action research --- on the case will be valuable.
|
However, before generalising, the design of the framework is iteratively refined using the feedback acquired from applying it in practical contexts which in this case is the research and development of a smaller and a more complex AI component followed by refactoring larger AI-based applications using the finished framework. The treatment is finding a simpler design which still leads to high-quality deployments as defined in Section \ref{section:requirements}. \textbf{RQ2} and \textbf{RQ3} captures this process; for investigating the feedback acquired from iteratively working --- which is the definition of action research --- on the case will be valuable.
|
||||||
|
|
||||||
To answer how well the design of \textit{GreatAI} can generalise (\textbf{RQ4}), interviews will be conducted from a population of software engineers and data scientists with varying levels of professional background. Since me and my colleagues are likely to have a bias for (or against) the proposed designs, the first step of checking its applicability in other practical contexts is to ask the opinion of non-affiliated fellow practitioners.
|
To answer how well the design of \textit{GreatAI} can generalise (\textbf{RQ4}), interviews will be conducted from a population of software engineers and data scientists with varying levels of professional background. Since me and my colleagues are likely to have a bias for (or against) the proposed designs, the first step of checking its applicability in other practical contexts is to ask the opinion of non-affiliated fellow practitioners.
|
||||||
|
|
||||||
|
\textit{GreatAI} might have the potential to bridge the gap between data science and software engineering. Stemming from the bidirectional nature of bridges, we can look at the framework from two perspectives: for professionals closer to the field of data science, it provides an automatic scaffolding of software facilities that are required for deploying, monitoring, and iterating on their models. For software engineers, it highlights the necessary steps required for robust and improvable deployments, while at the same time saves them from the grunt work of implementing these constructs. While most importantly, it serves as a proxy for the design decisions through which they can be tested and evaluated in their practical context.
|
||||||
|
|
|
||||||
|
|
@ -1,47 +1,62 @@
|
||||||
\chapter{Designing the framework} \label{chapter:design}
|
\chapter{Designing the framework} \label{chapter:design}
|
||||||
|
|
||||||
\footnote{Of course, given the saturation of MLOps libraries, extra care has to be taken to meaningfully extend the current state-of-the-art. \href{https://xkcd.com/927/}{xkcd.com/927}}
|
Providing the users with a high-level of abstraction is not unheard of in the domain of practical AI platforms. Many software-as-a-service products offer features for hiding the details of machine learning applications. However --- as we saw in Section \ref{section:existing} --- these tend to abstract away the details of both data science and AI-engineering, overall hindering the development process. The design proposed here aims to simplify only the deployment related concepts.
|
||||||
|
|
||||||
\section{Requirements} \label{section:requirements}
|
\section{Scope} \label{section:scope}
|
||||||
|
|
||||||
\paragraph{General}
|
As highlighted by several case studies in Chapter \ref{chapter:background}, the transition from prototypes to production-ready systems is often named as the source of unexpected struggle. Maybe it is not a coincidence that a significant portion of the SE4ML best practices should be implemented in this phase as well. Unfortunately, it is easy to gloss over them while tackling the underestimated difficulties of this \textit{transition}. Therefore, the aim of GreatAI is to ease this step of the life-cycle, consequently, its scope is limited to the \textit{transition} step.
|
||||||
\paragraph{Robust}
|
|
||||||
\paragraph{End-to-end}
|
|
||||||
\paragraph{Automated}
|
|
||||||
\paragraph{Trustworthy}
|
|
||||||
|
|
||||||
\subsection{Out of scope}
|
There have been attempts that at least partially address this issue, however, as we have seen in Chapter \ref{chapter:background}, these have limitations either from the perspective of best practices, or stemming from their difficulty to be adopted. To have the best chance of providing an easy-to-adopt solution, the scope has to be well-defined and limited. Because to understand the API of a library, users first have to understand its aim, surface, and have to become familiar with the problems it solves. Thus, focusing only on the \textit{transition} step seems reasonable. This step is highlighted in Figure \ref{fig:scope}.
|
||||||
% % just for data there are so many options, let the users choose
|
|
||||||
% % https://github.com/SeldonIO/alibi-detect: for "both" tensorflwo and torch drift detection
|
|
||||||
|
|
||||||
% % https://docs.seldon.io/projects/alibi-detect/en/stable/od/methods/llr.html
|
|
||||||
% % https://github.com/PAIR-code/facets
|
|
||||||
% % https://github.com/great-expectations/great_expectations
|
|
||||||
% % The data linter: Lightweight, automated sanity checking for ml data sets.
|
|
||||||
|
|
||||||
% % Git Large File System (LFS: bad
|
|
||||||
% % DVC - one more tool
|
|
||||||
|
|
||||||
% The obstacles coming from the intertwined nature of different models is widely recognised \cite{sculley2015hidden,haakman2021ai,amershi2019software}. This can lead to non-monotonic error propagation, meaning that improvements in one part of the system might decrease the overall system quality \cite{amershi2019software}. The importance of schema versioning in an environment of rapidly changing models and transformations is highlighted and solved for a specific use-case in \cite{van2017versioning}.
|
|
||||||
|
|
||||||
% The main requirements I have for it is to be library-agnostic, a PyTorch-based deep-learning module or a call to a web API should be handled the same way. Everything is included in a single python package. It's not a PaaS. It's a framework encapsulating the "AI" part of a service and turning it into a more classical piece of software that can be handled with well-known, proven technologies.
|
|
||||||
|
|
||||||
% The algorithm is exposed through a web API, predictions are followed from beginning to end, the traces are persisted (a db driver can be given, it can be local filesystem, s3, sql, nosql, hfs, etc.). A/B testing, shadow deployments, automatic versioning are supported by default. Input data statistics can be generated and exposed through a REST API (maybe a minimal frontend can also be part of the package). Using the feedback, the performance of the components can be observed real-time the same way.
|
|
||||||
|
|
||||||
% Basically, you define a pipeline in code with one or more of your algorithms. Visualisation and persistence steps can be also used. Each model must have a version, but defining A/B or shadow deployments works the same way. The models are uploaded to somewhere (S3 for example) from your machine, and when the service is deployed (though a pre-existing CI/CD system even). It can handle the training data as well, using it, regression tests can be run.
|
|
||||||
|
|
||||||
% I don't see too much reason to help clients with the training part, there are already a plethora of solutions for that, including some of the aforementioned ones. But it could have some integration with Ray Tune just to cover everything.
|
|
||||||
|
|
||||||
% In short, I believe that compliance with many of the best practices isn't too difficult once the developers and managers are aware of them and have the appropriate tooling to conduct the necessary steps. I would like to provide them with this tooling.
|
|
||||||
|
|
||||||
|
\begin{figure}
|
||||||
|
\centering
|
||||||
|
\includegraphics[width=\linewidth]{figures/scope.drawio.png}
|
||||||
|
\caption{Usual process steps in the development life-cycle of a data-heavy software solution. The dashed arrows denote optional paths: after a prototype has been completed, there are multiple options for its deployment. The steps with blue background show the scope of GreatAI.}
|
||||||
|
\label{fig:scope}
|
||||||
|
\end{figure}
|
||||||
|
|
||||||
|
It is interesting to mention that there is a proliferation\footnote{\href{https://xkcd.com/927/}{xkcd.com/927}} of platform/software as a service (PaaS/SaaS) products for deploying AI\footnote{Such as \href{https://mlem.ai/}{MLEM} or any AutoML SaaS platform, for example, \href{https://www.akkio.com/role/software-engineers}{Akkio} as these often have a one-click deployment feature as well.}. At first, these may look promising, however, they tend to only focus on getting code easily deployed in the cloud: AI best practices are not prioritised in this setup. Nevertheless, in many cases, it may be a suitable option to use such a service and these can also complement GreatAI as illustrated in Figure \ref{fig:scope}. First, the prototype is transformed into a GREAT service and materialised as a common software artifact implementing the best practices. Then, it is either deployed using a deployment SaaS, or by using the organisation's existing software deployment setup.
|
||||||
|
|
||||||
\section{Design principles}
|
\section{Design principles}
|
||||||
|
|
||||||
|
As implied in Section \ref{section:scope}, the Unix philosophy \cite{ritchie1978unix,salus1994quarter} of software design is followed. Most notably, the design goal that encourages to \textit{write programs that do one thing and do it well.}\footnote{Of course, \textit{write programs to work together} is also very much applicable, since allowing interoperability is one of the core requirements for GreatAI.}. Apart from providing a clear and simple picture of the intended use cases for the library, this is also in line with the main notion of \textit{A Philosophy of Software Design} \cite{ousterhout2018philosophy}: API-s should be narrow and deep. A narrow width refers to having a small exposed surface area, i.e. having a small number of functions and classes in the public API. While depth implies each of them accomplishing an involved, complex goal.
|
||||||
|
|
||||||
For principles of API design:
|
In a way, the API-s width is the price the users have to pay (the effort required for learning it) to use it, while the depth is analogous to the return they get from it. Having to learn little and being provided by a lot of functionality maximises return on investment, hence, developer experience (DX). The theoretical frameworks presented in \textit{The Programmer's Brain} \cite{hermans2021programmer} provides us with explanations and vocabulary from psychology for arguing about the cognitive aspects of API designs. In the following, two of them will be used for detailing the design principles: cognitive dimensions of code bases (CDCB) which is an extension of the cognitive dimensions of notation (CDN) framework \cite{blackwell2001cognitive}, and linguistic antipatterns \cite{arnaoudova2016linguistic}. The former comes with a set of dimensions which describe different (often competing) cognitive aspects of code that influence one's ability to perform certain tasks with it.
|
||||||
A Philosophy of Software Design \cite{ousterhout2018philosophy}
|
|
||||||
The Programmers Brain \cite{hermans2021programmer}
|
While linguistic antipatterns provide guidelines for improving consistency and decreasing the false sense of consistency when there is none. Also, choosing the right names for identifiers can help activate information stored in the long-term memory which makes it quicker to comprehend and easier to reason about the code \cite{deissenboeck2006concise}. Finding the most accurate and useful names is harder than it first seems. Accuracy and usefulness are already often competing goals. The more precise the name, the longer and therefore less convenient to use \cite{butler2009relating}. In short, good names are key to good API-s; consciously considering the implications of names has to be an integral part of the design process.
|
||||||
“12. Designing and improving larger systems”
|
|
||||||
“ We call this version cognitive dimensions of code bases (CDCB) and use it to examine a codebase to understand how it”
|
Nonetheless, simple API-s come at a high technical cost. The library has to implement these in a way that still allows high-performance in production \cite{kleppmann2017designing} and avoids being tied to specific libraries or technologies. Inspiration for the latter may be gained from the pipelines of Prado et al. \cite{prado2020bonseyes}: they show that more freedom can be achieved with plug-and-play steps and preconfigured defaults.
|
||||||
\cite{kleppmann2017designing}
|
|
||||||
|
Before diving into the concrete issues solved, let us detail the principles that should be used for implementing them in the scope of this framework.
|
||||||
|
|
||||||
|
\subsection{Default configuration}
|
||||||
|
|
||||||
|
Existing frameworks oftentimes suffer from the entanglement of numerous levels of abstractions. Instead of exposing each implementation detail and encouraging users to interact with most of them, many of these could be abstracted away. Where configuration may be helpful for advanced users, default values can still be chosen automatically while providing an override option where necessary.
|
||||||
|
|
||||||
|
For example, tracing the evaluations and the model versions used in a distributed fashion is very much expected of a trustworthy system. Hence, turning this feature on by default but allowing opting-out from it can result in less scaffolding required from the library's user. It also decreases their up-front cognitive load which by definition flattens the learning-curve \cite{hermans2021programmer}. Similar features can be imagined for providing an access API for the algorithms and for giving feedback, marking outliers, etc.
|
||||||
|
|
||||||
|
Being \textit{automated} is listed as a requirement but it is imperative to only automate for simplifying and not for hiding decisions. More precisely, guessing must not be a part of automation. For instance --- an otherwise incredibly useful WebGL library --- TWGL.js\footnote{\href{https://twgljs.org/}{twgljs.org}} has a feature for automatically guessing the type of vectors based on their names. If it matches the \texttt{/colou?r/i} pattern, it is treated as a vector with 3 components\footnote{\href{https://github.com/greggman/twgl.js/blob/e3a8d0ed09f7f5cd4be0e4cb5976081c2b5013aa/src/attributes.js\#L139}{\tiny github.com/greggman/twgl.js/blob/e3a8d0ed09f7f5cd4be0e4cb5976081c2b5013aa/src/attributes.js\#L139}}. It is easy to imagine that this can help in certain scenarios, but it does so at the cost of immense confusion when renaming a variable breaks the application. In CDCB, this equates to scoring high on the dimension of \textit{Hidden dependencies} and low on \textit{Visibility}.
|
||||||
|
|
||||||
|
Learning from this, any kind of guessing must be avoided for creating a pleasant API. However, this is in conflict with providing defaults for each configuration value. Even if these would be reasonable defaults derived from educated guesses, they are still merely guesses. Nevertheless, if the users are required to specify each configuration option, that leads to considerably more boilerplate code. This verbosity is captured by the \textit{Diffuseness} dimension of CDCB and, of course, should be minimised.
|
||||||
|
|
||||||
|
To resolve this conflict, GreatAI should have recommended values instead of defaults. This can mean a context object (as suggested in \cite{ousterhout2018philosophy}), which contains the result of each design decision that has to be made for a service's deployment. If not configured manually, the recommended values are applied, just like defaults. The values chosen for each parameter must be clearly highlighted. Coming from the library's single responsibility, the number of parameters should not be immense, hence, the user can be expected to comprehend them instead of just being overwhelmed and skimming it.
|
||||||
|
|
||||||
|
This way, the library attempts to notify its user about the existence of these decisions but does not force them to manually decide. As a result, no initial configuration is needed for starting out with the library (high \textit{Provisionality}, low \textit{Diffuseness}) and the dependencies are not hidden since they are explicitly highlighted.
|
||||||
|
|
||||||
|
\subsection{Documentation}
|
||||||
|
|
||||||
|
Without a doubt, good documentation is a prerequisite for adoption. Documentation comes in multiple forms: modern integrated development environments (IDEs) tend to show a popup of a function's documentation when requested, at the same time a more comprehensive online documentation and example projects are also still expected. But descriptive error messages can be also viewed as documentation. The library should have quality documentation for all categories.
|
||||||
|
|
||||||
|
Once again, we might notice two competing interests: the level-of-detail and the length of the documentation. For example, FastAPI\footnote{\href{https://fastapi.tiangolo.com/async/\#concurrent-burgers}{fastapi.tiangolo.com}}, a popular Python web framework, has extensive descriptions and explanations on all topics related to Python's import system, the HTTP protocol, concurrency, deployment, etc. The actual framework's documentation is sprinkled over these very broad topics. This is certainly helpful for beginners to acquire knowledge from a single place. Nevertheless, this high-level of accessibility actually hinders the process of finding the relevant sections (in CDCB, this shows a trade-off between the support of Searching and Comprehension tasks). My opinion is that linking to external resources about the library's domain are welcome, but the documentation must have a single responsibility: describing the library itself.
|
||||||
|
|
||||||
|
A large portion of software documentations is automatically generated from source code. This has the advantage of always keeping it in sync with code changes, however, it might also signal that the API is too large, since it is inconvenient for the developers to document it by hand.
|
||||||
|
|
||||||
|
When it comes to example code, showing at least the minimal starter code, and the way of customising it has to be showcased front and centre. It is a well-known observation that developers only read documentation when they are stuck and there might be some merit to this. Making them not get stuck --- by providing a starter code from which they can explore the API using IntelliSense-like solutions --- should be preferred. For example, another widely popular Python web framework, Flask\footnote{\href{https://flask.palletsprojects.com/en/2.1.x/}{flask.palletsprojects.com/en/2.1.x}}, at this time, has 324 uniformly styled links on its landing page. Out of these, only 2 lead to the quick start code. Of course, it is not hidden, but I argue that the DX could be improved by displaying it more prominently.
|
||||||
|
|
||||||
|
\subsection{Developer experience}
|
||||||
|
|
||||||
|
Subjectively, the key to good DX is consistency and discoverability. To give an example, the MySQL connector's Python implementation\footnote{\href{https://dev.mysql.com/doc/connector-python/en/}{dev.mysql.com/doc/connector-python/en/}} has a cursor object which exposes a \texttt{fetchone} method. Even though this naming scheme is not conventional in Python since it does not follow \href{https://peps.python.org/pep-0008/}{PEP 8}, at least the API is logical: changing \texttt{sql\_cursor.fetchone()} to \texttt{sql\_cursor.fetchall()} returns all items instead of just one. Using good and consistent names is the key to good DX.
|
||||||
|
|
||||||
|
Also, Python codebases are rarely strictly object-oriented (OO), they are a mix of functional, data-driven, and OO programming. Consequently, relying on classes for grouping related functions is not always desirable. Therefore, it is even more imperative to name similar functions similarly. This helps discoverability and chunking \cite{hermans2021programmer} which amount to quicker comprehension.
|
||||||
|
|
||||||
|
There is one more reason to prefer consistency. Humans have a limited short-term memory (STM) \cite{miller1956magical}. Even though flags as function parameters are frowned upon by some \cite{martin2009clean}, they are useful, especially, when configuring libraries. However, if there is no convention for the default value of a flag, clients have to remember the flag's name and initial value at the same time, quickly overloading their STM. Thus, in the codebase, all defaults must be \texttt{False}. Sometimes, it can result in a \textit{disable} prefix, which turn into a double negation, users shouldn't ever encounter this themselves since the doubly-negated version is the default, thus when overriding it, it is only singly-negated. This approach also implies, that something may be recommended to be turned on by default.
|
||||||
|
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
||||||
\chapter{The ScoutinScience platform} \label{chapter:case}
|
|
||||||
\cite{jurafsky2019speech}
|
|
||||||
35
thesis/chapters/5_case/2-stage.tex
Normal file
35
thesis/chapters/5_case/2-stage.tex
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
\section{A complex case}
|
||||||
|
|
||||||
|
Let us now turn our attention towards a more complex component. The ScoutinScience Dashboard contains a full-page evaluation view for each academic publication. On this, the known metadata, historical data about the paper's topics, social media mentions, a PDF viewer showing the document, and other augmentation tools are displayed. One of these is the \textit{interesting sentences} section, which aims to summarise the paper from a technology-transfer perspective.
|
||||||
|
|
||||||
|
The current approach uses a simple heuristic based on a set of phrases selected by business developers and extended with the help of a word2vec model \cite{mikolov2013efficient}. The user feedback deemed this implementation slightly helpful but not adequate for providing an accurate overview. Thus, this is the baseline that I attempt to improve on in this section.
|
||||||
|
|
||||||
|
\begin{displayquote}
|
||||||
|
Compared with Section \ref{section:simple-case}, this time around, the toolset of GreatAI is at our disposal. Hopefully, this will streamline the development and --- especially --- the deployment. Given its arguably higher complexity, this experiment falls closer to industrial use-cases, and hence, can give a more accurate feedback on how to further improve the API.
|
||||||
|
\end{displayquote}
|
||||||
|
|
||||||
|
\subsection{Background}
|
||||||
|
|
||||||
|
Automatic text summarisation (ATS) is one of earliest established problems of text analysis and boasts numerous promising results \cite{el2021automatic}. However, our problem requires generating a special type of summary: it must only concern a single aspect (tech-transfer) of the document. Aspect-based text summarisation has also seen some progress over the last decades \cite{berkovsky2008aspect,hayashi2021wikiasp}, but these approaches require concretely defined topics. Unfortunately, \textit{tech-transfer potential} is anything but a clear topic definition.
|
||||||
|
|
||||||
|
Our numerous discussions and interviews with business developers over the last years made it clear that there is no universally agreed on definition for it. At least, all of them agrees that they know it when they see it. Additionally, most of them agree that they can confidently make a decision at the granularity of sentences. This gives rise to an obvious idea: show the experts something that they can annotate. Because the time of experts is valuable, and relevant sentences are few and far between, extra care needs to be taken to improve the ratio of positive examples in the dataset. The research of Iwatsuki Kenichi on formulaic expressions (FE) \cite{iwatsuki2020evaluation,iwatsuki2021extraction,iwatsuki2021communicative,iwatsuki2022extraction} provides a promising direction to do so.
|
||||||
|
|
||||||
|
A formulaic expression is a phrase with zero or more slots that expresses a certain intent. In the context of scientific texts, an example\footnote{Taken from the ground-truth data at \href{https://github.com/Alab-NII/FECFevalDataset/blob/master/human_evaluation/background.tsv}{github.com/Alab-NII/FECFevalDataset}} could be: \texttt{it was not until * that}. The asterisk can be substituted with multiple terms and the intention of this expression is (likely) to describe the \textit{History of the related topics}. Iwatsuki et al. identified a set of 39 intentions, compiled a manually labelled dataset \cite{iwatsuki2020evaluation}, and developed multiple approaches for automatically extracting and classifying formulaic expressions in large corpora \cite{iwatsuki2021communicative,iwatsuki2022extraction}.
|
||||||
|
|
||||||
|
\subsection{Methods}
|
||||||
|
|
||||||
|
In the following, we explore a 2-stage retrieval approach \cite{schutze2008introduction} commonly used in the field of information retrieval. The first stage is expected to filter out sentences that are certainly not relevant from a technology-transfer perspective using Iwatsuki's formulaic expression intention labels. Subsequently, the second stage utilises a fine-tuned SciBERT model to rank the remaining sentence based on a model learned from expert annotations.
|
||||||
|
|
||||||
|
This approach has multiple shortcoming, for the first stage, we must assume the independence of sentences and that the FE intentions are strongly correlated with the sought after aspect. Additionally, the reranking only considers the individual relevance of the sentences instead of the overall relevance (utility) of the summary. It is expected, that stemming from the length of the documents and the sparseness of the selected sentences, that any combination of them is likely to have low redundancy.
|
||||||
|
|
||||||
|
TODO
|
||||||
|
|
||||||
|
Finetuning SciBERT \cite{jurafsky2019speech}.
|
||||||
|
|
||||||
|
\subsection{Results}
|
||||||
|
|
||||||
|
For measuring the interrater agreement, Cohen's kappa \cite{cohen1960coefficient} is calculated as shown in Equation \ref{equation:kappa}.
|
||||||
|
|
||||||
|
\begin{equation} \label{equation:kappa}
|
||||||
|
\kappa_{agreement} \equiv \frac{p_{observed} - p_{expected}}{1 - p_{expected}} = 1 - \frac{1 - p_{observed}}{1 - p_{expected}}
|
||||||
|
\end{equation}
|
||||||
40
thesis/chapters/5_case/features.tex
Normal file
40
thesis/chapters/5_case/features.tex
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
\section{Bridging \textbf{the gap} with GreatAI}
|
||||||
|
|
||||||
|
This section briefly explores how the problems raised can be solved using GreatAI, and the API it provides to best fit the needs of its users. We first focus on the aspects of data, then, the automated wrapping of service, lastly we discuss the utility of helper functions.
|
||||||
|
|
||||||
|
First, let us revisit the scope. As concluded in Section \ref{section:scope}, GreatAI should ease the \textit{transition} step between prototypes and production-ready deployments. However, this leaves open the question of what constitutes to this step? There are cross-cutting concerns such as the feature extraction code: for example, feature extraction is implemented and used in the training phase but it is also deployed alongside the model. The robustness criterion has to be met by this procedure after deployment even though its implementation is only in focus at the earlier stage of the project. Since having an untested function deployed into production can have severe repercussions, I believe, assuring its correctness lies within the scope of GreatAI.
|
||||||
|
|
||||||
|
\subsection{Data}
|
||||||
|
|
||||||
|
There are two kinds of data storage need we need to address: training data and trained models. Because our code is probably already tracked under Git (and likely synced with GitHub), using the Git Large File Storage (LFS)\footnote{\href{https://git-lfs.github.com/}{https://git-lfs.github.com/}} might seem intriguing. However, it is a paid (and surprisingly expensive) service of GitHub especially when we factor in the expected sizes of the models and train data with the fact that the only way remove files counting towards our quota is to \href{https://docs.github.com/en/repositories/working-with-files/managing-large-files/removing-files-from-git-large-file-storage#git-lfs-objects-in-your-repository}{recreate the repository}.
|
||||||
|
|
||||||
|
The Data Version Control (DVC)\footnote{\href{https://dvc.org/}{https://dvc.org/}} open-source project provides a nearly perfect solution. It comes with a command-line interface (CLI) inspired by git's, and it can be integrated with several backend storage servers. Its only downside is of course that it is one more tool that increases the complexity of the project and the initial setup time. If this is an acceptable price to pay, then I personally recommend opting for DVC. Nevertheless, if this may prohibit a team from properly handling data according to the best practices, I present a simpler solution in the following.
|
||||||
|
|
||||||
|
The complexity of an API can be decreased by relying on its users preexisting knowledge. Therefore, we can reuse familiar API-s, such as the \texttt{open()} method from Python. A method is proposed which provides the same interface, however, the backing storage for it is a mixture of local disk space, S3-compatible storage, MongoDB, or any other storage backend. It provides a superset of \texttt{open()}'s interface; the same parameters can be used with it.
|
||||||
|
|
||||||
|
Easing development isn't just about automating everything but also making the code easy to change (which is the \textit{Viscosity} dimension of CDCB). Going from opening a local file on the disk with the built-in open method, to opening a file from S3 is as easy as changing \texttt{with open('file.txt', 'w' as f: ...} to \texttt{with LargeFileS3('file.txt', 'w' as f: ...}. In the case of the latter, an additional \texttt{version} keyword argument can also be given to lock ourselves in using as certain version which is very much desired in the case of models.
|
||||||
|
|
||||||
|
The obstacles coming from the intertwined nature of different models is widely recognised \cite{sculley2015hidden,haakman2021ai,amershi2019software}. This can lead to non-monotonic error propagation, meaning that improvements in one part of the system might decrease the overall system quality \cite{amershi2019software}. The importance of schema versioning in an environment of rapidly changing models and transformations is highlighted and solved for a specific use-case in \cite{van2017versioning}.
|
||||||
|
|
||||||
|
The expected features: progress bar, caching, automatically purging the cache, automatically deleting old remote version if requested are all present and come with recommended --- but easy to see and change --- configuration.
|
||||||
|
|
||||||
|
\subsection{Utilities}
|
||||||
|
|
||||||
|
|
||||||
|
utilities: clean, language, parallel map \textit{Enable Parallel Training Experiments}
|
||||||
|
|
||||||
|
traces
|
||||||
|
|
||||||
|
\textit{Deployment approach}
|
||||||
|
|
||||||
|
% Should the order of the decorators matter? all except in one case, they're written in a way that the order doesn't matter even with the original semantics of decorators. In that one case, it cannot be written in that way. Instead of correcting a user's error, there's a mechanism looking for this error and the user is notified. Guessing the unspecified is cool, but correcting the wrong is not
|
||||||
|
|
||||||
|
to do
|
||||||
|
|
||||||
|
% During development, I wanted to check out which types of request fail -> log errors in traces
|
||||||
|
% Even production systems are not perfect, saving and letting the users filter on the errors is useful. e.g. they can correlate it with the input
|
||||||
|
|
||||||
|
% I use a toy example when quickly experimenting, it's important not to overfit on it ( moving it into the library would result in a online for it, so I have to consciously avoid that), but having a very simple
|
||||||
|
|
||||||
|
% Argumetn/parameter names were confusing
|
||||||
|
% offlinemode -> cacheonly mode
|
||||||
11
thesis/chapters/5_case/introduction.tex
Normal file
11
thesis/chapters/5_case/introduction.tex
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
\chapter{The ScoutinScience platform} \label{chapter:case}
|
||||||
|
|
||||||
|
The core product of ScoutinScience B.V. is its platform. The clients are technology-transfer offices of Dutch and German universities, government organisations (e.g.: Wetsus), and corporates (e.g.: Heraeus Group, Ruma Rubber B.V.) who wish to extend the scope of their R\&D activities. ScoutinScience connects to multiple data sources of academic publications and integrates them into a single database. Each new publication is evaluated with a suite of AI components that ultimately determine its technology transfer potential. Other features are also extracted that help the users get a quick overview of the authors, topics, and contributions of a given piece of research.
|
||||||
|
|
||||||
|
Each client organisation gets to see a different filtered view of this database ranked by the predicted probability of technology transfer opportunities being present. The main motivation is to make these business developers' and other professionals work more efficient by showing them which papers have the largest likelihood of being considered interesting by them.
|
||||||
|
|
||||||
|
To achieve this, we have a service-based architecture \cite{kleppmann2017designing} on the backend, apart from the data integration, communication, and business logic, it is made up of services wrapping simpler (phrase-matching, Naive Bayes) and more sophisticated (conditional random fields, transformer) models. As we will soon see, these can also depend on each other, for instance, based on the predicted scientific domain, a different model may be applied for scoring the paper's certain aspects.
|
||||||
|
|
||||||
|
I was the first software engineer on the team which has grown considerably in the past two years. While architecting, designing, and integrating more and better models into our software solution, we noticed the same difficulties as described in Chapter \ref{chapter:background}. The gap between prototypes and production-ready services is larger than it seems. It is also larger than it should be. This motivated me to investigate the state-of-the-art and had found that it is insufficient in many cases. Since the ScoutinScience platform is a quite typical example of applying AI in the industry, it will serve as the real-life case, problem context, and testbed for attempting to design a solution which can advance the state-of-the-art.
|
||||||
|
|
||||||
|
In this chapter, the process of designing GreatAI is described along with how it fits into real-life use cases. First, a simple experiment is presented which leads to the implementation of a service, then, as the featureset of the library grows and matures, a more complex service is developed. Subsequently, the close to final library version is used to refactor existing ScoutinScinece services in order to further refine the API of GreatAI. Lastly, the final version of the design is presented and qualitatively evaluated to verify how well it satisfies the requirements described in Section \ref{section:requirements}.
|
||||||
10
thesis/chapters/5_case/main.tex
Normal file
10
thesis/chapters/5_case/main.tex
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
\input{chapters/5_case/introduction}
|
||||||
|
|
||||||
|
\input{chapters/5_case/naive-bayes}
|
||||||
|
\input{chapters/5_case/features}
|
||||||
|
|
||||||
|
\input{chapters/5_case/2-stage}
|
||||||
|
|
||||||
|
\input{chapters/5_case/refactoring}
|
||||||
|
|
||||||
|
\input{chapters/5_case/results}
|
||||||
97
thesis/chapters/5_case/naive-bayes.tex
Normal file
97
thesis/chapters/5_case/naive-bayes.tex
Normal file
|
|
@ -0,0 +1,97 @@
|
||||||
|
\section{A simple case} \label{section:simple-case}
|
||||||
|
|
||||||
|
Using different models for slight variations of the same problem is quite commonplace in the industry. For instance, UberEats has a vast, hierarchical set of models for every country, region, and city for calculating the estimated time of delivery \cite{li2017scaling}. We have also found, that in order to best process an academic publication, knowing its domain is essential. The reason for this can be (among others) the wildly different vocabularies of different domains. For example, the term \textit{framework} in computer science almost always refers to a software artifact (usually implying high tech-transfer potential), while in every other domain, \textit{framework} is used to describe theoretical models that are less central to practical applications. Of course, it is not merely the meaning of the terms but more importantly, their distribution that varies significantly. Therefore, the topic of this section is to design and develop a domain prediction model for academic papers.
|
||||||
|
|
||||||
|
\subsection{Background}
|
||||||
|
|
||||||
|
Fortunately, this is one of the oldest subjects of text classification. In fact, Maron introduced the Naive Bayes classifier in 1961 for exactly this purpose: classifying documents' subjects. To look at a more recent approach, SciBERT \cite{beltagy2019scibert} --- a BERT \cite{devlin2018bert} model pretrained on academic publications --- was also used for a similar task in which the domains of sentences have to be decided\footnote{\href{https://paperswithcode.com/sota/sentence-classification-on-paper-field}{paperswithcode.com/sota/sentence-classification-on-paper-field}}. It achieved an F1-score of $0.6571$ after being pretrained on the Semantic Scholar Corpus (SSC) \cite{Lo2020S2ORCTS} and finetuned on the train split of the Microsoft Academic Graph (MAG) dataset \cite{wang2019review}\footnote{SciBERT was applied to a preprocessed version of this dataset available at \href{https://github.com/allenai/scibert/tree/master/data/text_classification/mag}{github.com/allenai/scibert/tree/master/data/text\_classification/mag}}.
|
||||||
|
|
||||||
|
\begin{displayquote}
|
||||||
|
\textbf{Design note} After getting familiar with the context, it is time to focus on experimenting and developing our domain prediction service. At the same time, the difficulties encountered should be noted and integrated into GreatAI's design.
|
||||||
|
\end{displayquote}
|
||||||
|
|
||||||
|
\subsection{Data}
|
||||||
|
|
||||||
|
Two datasets will be considered for the experiments. SciBERT's MAG and the SSC. The former is used to compare the results with SciBERT's, while the latter is utilised for training a model for production purposes because it has 19 labels compared with MAG's 7 and it also contains abstracts instead of just sentences, thus, it is more fitting for our use-case.
|
||||||
|
|
||||||
|
SciBERT's version of the MAG dataset has 84 thousand and 22.3 thousand sentences in its train and test splits respectively. These are mostly in English and have all punctuation and casing removed. Each sentence is classified as belonging to one of seven fields. Figure \ref{fig:mag-distribtion} shows that the classes have a uniform distribution.
|
||||||
|
|
||||||
|
\begin{figure}
|
||||||
|
\centering
|
||||||
|
\includegraphics[width=\linewidth]{figures/mag-distribution.png}
|
||||||
|
\caption{Class distribution of the MAG \cite{wang2019review} dataset's 84000 sentences in its \textit{train} split.}
|
||||||
|
\label{fig:mag-distribtion}
|
||||||
|
\end{figure}
|
||||||
|
|
||||||
|
SSC is much larger: it contains over 80 million abstracts. Having more data certainly helps in sampling the term distribution more accurately, the law of diminishing returns apply, especially when using simple models. Therefore, the data will be randomly downsampled to leave us with a more manageable couple of hundred megabytes of abstracts. We can see the distribution of class labels in Figure \ref{fig:ss-distribution}. The dataset is considerably less balanced: \textit{medicine} is by far the most popular field.
|
||||||
|
|
||||||
|
\begin{figure}
|
||||||
|
\centering
|
||||||
|
\includegraphics[width=\linewidth]{figures/ss-distribution.png}
|
||||||
|
\caption{Label distribution of the Semantic Scholar dataset \cite{Lo2020S2ORCTS}. The \textit{variable} refers to the position of the domain in the list of domains assigned to a paper.}
|
||||||
|
\label{fig:ss-distribution}
|
||||||
|
\end{figure}
|
||||||
|
|
||||||
|
\begin{displayquote}
|
||||||
|
\textbf{Where should we store this data?} "On my machine" seems like an easy answer. However, if we have a team working with the data or it has intrinsic value, it must be stored in an easy-to-access, potentially redundant way. Serban et al. \cite{serban2020adoption} expressed this need in the following best practice: \textit{Make Data Sets Available on Shared Infrastructure (private or public)}. Meanwhile, wherever data is stored, it should also be versioned to satisfy the next best practice: \textit{Use Versioning for Data, Model, Configurations and Training Scripts}.
|
||||||
|
\end{displayquote}
|
||||||
|
|
||||||
|
MAG needs no further preprocessing if we aim to match SciBERT's setup \cite{beltagy2019scibert}. But since SSC contains a heap of metadata, the relevant parts have to be extracted and preprocessed. In this case, these are the the concatenation of the abstract's text, paper's title and the journal's name along with the paper's domains (there can be multiple domains for a single paper, it is a mulitlabel classification task). Lastly, the non-English entries are discarded because we only expect to process papers in English.
|
||||||
|
|
||||||
|
\begin{displayquote}
|
||||||
|
\textbf{How should we preprocess the data?} These simple processing steps (filter, map, project) are almost always present in the data science life-cycle. For example, cleaning the input text from various HTML, OCR, PDF, or \LaTeX \hskip 0.12cm extraction artifacts is almost always necessary for text analysis. This is captured in the AI best-practices collection under the following category: \textit{Write Reusable Scripts for Data Cleaning and Merging}. Also, the best practice of \textit{Test all Feature Extraction Code} is somewhat applicable: the applied processing steps must not introduce unwanted artifacts.
|
||||||
|
\end{displayquote}
|
||||||
|
|
||||||
|
\subsection{Methods}
|
||||||
|
|
||||||
|
Since the aim is to classify papers to allow the ScoutinScience platform to select models which have been trained on a matching vocabulary (and domain), it seems reasonable that only considering the distribution (frequencies) of individual terms may be sufficient. To test this hypothesis, a unigram language model (Multinomial Naive Bayes) is constructed and its accuracy is compared with SciBERT's. The former definitely aligns with the advice to \textit{Use The Most Efficient Models}.
|
||||||
|
|
||||||
|
Using the MNB implementation of scikit-learn \cite{pedregosa2011scikit}, it only took a couple of lines to create, hyperparameter-optimise, and test a text classifier. Including data loading and visualisations, it takes 71 LOC to be more precise. \footnote{The code is available at \href{https://github.com/ScoutinScience/great-ai/blob/main/examples/simple-mag/train.ipynb}{github.com/ScoutinScience/great-ai/blob/main/examples/simple-mag/train.ipynb}} This further proves relatively how simple it is to apply existing algorithms. The code can be considered for satisfying the \textit{Automate Hyper-Parameter Optimisation} best-practice, since it also implements an automated hyperparameter sweep.
|
||||||
|
|
||||||
|
The sentences are tokenised into words and vectorised with TF-IDF (with logarithmic term frequency) \cite{buckley1985implementation}, the hyperparameters found via 3-fold cross-validation on the \textit{train} split lead to filtering out tokens which occur in fewer than 5 documents or more than 5\% of the documents.
|
||||||
|
|
||||||
|
\begin{displayquote}
|
||||||
|
\textbf{What could be automated here?} As discussed in Section \ref{section:accessible-ai}, libraries exposing algorithms and state-of-the-art models can already be considered mature and accessible. In this case, only scikit-learn was utilised, but subjectively, most popular libraries have a similarly easy to use use API. Therefore, I see no urgent need for further action regarding the \textit{experimentation} step of the life-cycle in connection with the AI best practices.
|
||||||
|
\end{displayquote}
|
||||||
|
|
||||||
|
\subsection{Results \& Discussion}
|
||||||
|
|
||||||
|
\begin{figure}
|
||||||
|
\centering
|
||||||
|
\includegraphics[width=0.8\linewidth]{figures/confusion-matrix.png}
|
||||||
|
\caption{Confusion matrix of a Naive Bayes classifier on the MAG dataset's sentences. The matrix is normalised column-wise. Notice, how most mistakes happen between semantically similar classes, for instance: \textit{politics} -- \textit{sociology} or \textit{business} -- \textit{economics}.}
|
||||||
|
\label{fig:mag-confusion}
|
||||||
|
\end{figure}
|
||||||
|
|
||||||
|
\begin{figure}
|
||||||
|
\centering
|
||||||
|
\includegraphics[width=\linewidth]{figures/ss-confusion.png}
|
||||||
|
\caption{Confusion matrix of a Naive Bayes classifier on the SSC dataset's sentences. The matrix is normalised column-wise. Notice, how most mistakes happen between semantically similar classes, for instance: \textit{philosohpy} -- \textit{sociology} or \textit{history} -- \textit{art}.}
|
||||||
|
\label{fig:ss-confusion}
|
||||||
|
\end{figure}
|
||||||
|
|
||||||
|
When this model is applied to the \textit{test} split of MAG, we get the confusion matrix of Figure \ref{fig:mag-confusion}. This Naive Bayes classifier achieves a whopping $0.6795$ F1-score. This is $3.4\%$ better than SciBERT's on the same dataset. Thus, it seems, MNB clearly outperforms SciBERT for this particular use-case: it is not only more accurate, its model is magnitudes smaller, while it is also considerably faster to train (or finetune in the case of SciBERT) and use.
|
||||||
|
|
||||||
|
It is, of course, not entirely surprising that the sophisticated transformer architecture of SciBERT is not necessary for a plain task like this. Apart from phrases, the relation between separate words of a sentence do not carry nearly as much discriminative power as the identity of the terms\footnote{On a similar note, the independence assumption of Naive Bayes is often less wrong than it might seem \cite{hand2001idiot}.}, hence there is little reason for using an attention mechanism. The fact that SciBERT even works in any way on this task is already a testament to its general applicability. Nevertheless, this short experiment has proved that we can safely opt for using MNB for production.
|
||||||
|
|
||||||
|
Since Multinomial Naive Bayes is best at returning a single label and SSC is has multiple labels per datapoint: for evaluation purposes, it is checked whether the returned label is contained in the labels of the ground truth. On this dataset, MNB achieves a significantly lower macro-average F1-score which is 0.49. The weighted-average F1 is 0.61 and the overall accuracy is 62\%. The large difference between the macro and weighted averages come from the unbalanced distribution of the labels, better performance could be achieved by uniformly sampling from each class.
|
||||||
|
|
||||||
|
The lower F1-score is not surprising because there are more than twice as many classes in this dataset, Additionally, the mistakes made are defendable when we look at Figure \ref{fig:ss-confusion}: most of them are between close or related classes.
|
||||||
|
|
||||||
|
\begin{displayquote}
|
||||||
|
This is the usual point where papers conclude: a proof-of-concept/prototype has been built and its performance demonstrated, measured --- and usually --- explained. Nonetheless, in an industrial setting, our problem is far from being solved: it has yet to be deployed.
|
||||||
|
\end{displayquote}
|
||||||
|
|
||||||
|
\subsection{Deployment}
|
||||||
|
|
||||||
|
First, an inference function needs to be written that can take an input on the fly and calculate a corresponding prediction. Since we aim to follow the best practices, namely: \textit{Explain Results and Decisions to Users} and \textit{Employ Interpretable Models When Possible}, giving an explanation of the results is expected. Fortunately, with our simple model it's easy to determine the most influential weights, thus, words. The last deployment step may be to provide access to our model for others.
|
||||||
|
|
||||||
|
\begin{displayquote}
|
||||||
|
\textbf{How do we provide an interface for the inference function?} We either have an offline or online inference workflow (or both). For the former, we have to provide a way to use it in batch processing; a simple Python function may be adequate for this purpose, though, allowing it to be easily (or automatically) parallelised would make its consumers' DX better. If it is an online-workflow, we must have a service running continuously and accepting input at any time. This can be achieved by a remote procedure call (RPC) interface, or more commonly, a web API. Developers usually refer to these as REST API-s, sometimes, they even follow the conventions of REST. Either ways, we must develop a wrapper over the service in order to make it available for other internal/external consumers.
|
||||||
|
\end{displayquote}
|
||||||
|
|
||||||
|
According to the research on the adoption of best practices, this is where many real-world projects conclude. This happens to be \textbf{the gap}. Believing that solely focusing on the research and experiments is good enough is a fallacy: when following this approach, the deployment step ends up being a rushed attempt of wrapping the \textit{AI} and putting it in the production environment. This is inarguably a deployment. However, it follows very few of the best practices. This can lead to suboptimal real-life performance, lack of accountability, lack of opportunity to improve, and can overall lead to negative societal impact \cite{o2016weapons}.
|
||||||
|
|
||||||
|
\begin{displayquote}
|
||||||
|
\textbf{How could we implement more best practices?} The most notable missing best practices are the lack of automated deployment, automated regression testing, online monitoring, persisting the traces, graceful error-handling, taking feedback on the results (if possible in the use-case), calculating the online accuracy based on the feedback, and retraining the model if necessary using novel data. These all correspond to a best practice.
|
||||||
|
\end{displayquote}
|
||||||
1
thesis/chapters/5_case/refactoring.tex
Normal file
1
thesis/chapters/5_case/refactoring.tex
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
\section{Refactoring with GreatAI}
|
||||||
38
thesis/chapters/5_case/results.tex
Normal file
38
thesis/chapters/5_case/results.tex
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
\section{Results}
|
||||||
|
|
||||||
|
\begin{table}
|
||||||
|
\centering
|
||||||
|
\caption{A subset of the AI lifecycle \href{https://se-ml.github.io/practices/}{best practices identified by Serban et al.} \cite{serban2020adoption,serban2021practices} and the level of support GreatAI provides for them. \textit{Full} requires no action from the user, \textit{Partial} requires at least some involvement, while \textit{Slight} provides some useful features but the client is still expected to make a significant effort.}
|
||||||
|
\label{table:best-practices}
|
||||||
|
\begin{tabular}{p{7cm}@{\hskip 0.5cm}c@{\hskip 0.5cm}c}
|
||||||
|
\hline
|
||||||
|
\textbf{Best practice} & \textbf{Implementation} & \textbf{Level of support} \\\hline
|
||||||
|
|
||||||
|
Use Sanity Checks for All External Data Sources & \texttt{great\_ai.parameter} & Partial \\\hline
|
||||||
|
Check that Input Data is Complete, Balanced and Well Distributed & Type-checked input & Slight \\\hline
|
||||||
|
Write Reusable Scripts for Data Cleaning and Merging & \texttt{great\_ai.utilities} & Partial \\\hline
|
||||||
|
Make Data Sets Available on Shared Infrastructure (private or public) & \texttt{great\_ai.large\_file} & Full \\\hline
|
||||||
|
|
||||||
|
Test all Feature Extraction Code & \texttt{great\_ai.utilities} & Partial \\\hline
|
||||||
|
Employ Interpretable Models When Possible & \texttt{great\_ai} & Slight \\\hline
|
||||||
|
Enable Parallel Training Experiments & \texttt{great\_ai.parallel\_map} & Partial \\\hline
|
||||||
|
Continuously Measure Model Quality and Performance & \texttt{great\_ai} & Full \\\hline
|
||||||
|
Use Versioning for Data, Model, Configurations and Training Scripts & \texttt{great\_ai.large\_file} & Full \\\hline
|
||||||
|
|
||||||
|
Run Automated Regression Tests & \texttt{great\_ai} & Full \\\hline
|
||||||
|
Use Continuous Integration & Docker Images \& scripts & Partial \\\hline
|
||||||
|
Use Static Analysis to Check Code Quality & Typed API & Partial \\\hline
|
||||||
|
Assure Application Security & GreatAI is audited & Partial \\\hline
|
||||||
|
|
||||||
|
Automate Model Deployment & Docker Images \& scripts & Partial \\\hline
|
||||||
|
TODO: Enable Shadow Deployment & GreatAI & Full \\\hline
|
||||||
|
Continuously Monitor the Behaviour of Deployed Models & \texttt{great\_ai} & Full \\\hline
|
||||||
|
Enable Automatic Roll Backs for Production Models & Docker Images & Partial \\\hline
|
||||||
|
Log Production Predictions with the Model's Version and Input Data & GreatAI & Full \\\hline
|
||||||
|
|
||||||
|
Explain Results and Decisions to Users & GreatAI & Slight \\\hline
|
||||||
|
\end{tabular}
|
||||||
|
\end{table}
|
||||||
|
|
||||||
|
|
||||||
|
Table \ref{table:best-practices} summarises the implemented best practices.
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
\chapter{Conclusion} \label{chapter:conclusion}
|
\chapter{Conclusion} \label{chapter:conclusion}
|
||||||
|
|
||||||
|
% even if you already implemented these solutions by hand, you no longer have to -> you have more time -> you can spend that time implementing more advanced best practices
|
||||||
|
|
||||||
\section{Future work}
|
\section{Future work}
|
||||||
|
|
||||||
\section{Concluding remarks}
|
\section{Concluding remarks}
|
||||||
|
|
||||||
% I feel I could relate to many of them, either because I had faced them or I'm still facing the issues described in them. They inspired me to help in facilitating the general adoption of best practices.
|
|
||||||
|
|
|
||||||
BIN
thesis/figures/confusion-matrix.png
Normal file
BIN
thesis/figures/confusion-matrix.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 57 KiB |
BIN
thesis/figures/mag-distribution.png
Normal file
BIN
thesis/figures/mag-distribution.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
BIN
thesis/figures/scope.drawio.png
Normal file
BIN
thesis/figures/scope.drawio.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 MiB |
BIN
thesis/figures/ss-confusion.png
Normal file
BIN
thesis/figures/ss-confusion.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 160 KiB |
BIN
thesis/figures/ss-distribution.png
Normal file
BIN
thesis/figures/ss-distribution.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 64 KiB |
|
|
@ -2,7 +2,6 @@
|
||||||
\usepackage{graphicx}
|
\usepackage{graphicx}
|
||||||
\usepackage[ddmmyyyy]{datetime}
|
\usepackage[ddmmyyyy]{datetime}
|
||||||
|
|
||||||
|
|
||||||
\setlength{\textheight}{24.7cm}
|
\setlength{\textheight}{24.7cm}
|
||||||
\setlength{\textwidth}{16cm}
|
\setlength{\textwidth}{16cm}
|
||||||
\setlength{\unitlength}{1mm}
|
\setlength{\unitlength}{1mm}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,11 @@
|
||||||
\usepackage{enumitem}
|
\usepackage{enumitem}
|
||||||
\usepackage{threeparttable}
|
\usepackage{threeparttable}
|
||||||
\usepackage{multicol}
|
\usepackage{multicol}
|
||||||
|
\usepackage[compact]{titlesec}
|
||||||
|
\usepackage{framed}
|
||||||
|
\usepackage{quoting}
|
||||||
|
\usepackage{xcolor}
|
||||||
|
|
||||||
|
|
||||||
% Header & footer
|
% Header & footer
|
||||||
\pagestyle{fancy}
|
\pagestyle{fancy}
|
||||||
|
|
@ -55,6 +60,19 @@
|
||||||
rightmargin=1.25cm
|
rightmargin=1.25cm
|
||||||
}
|
}
|
||||||
|
|
||||||
|
% Block quote
|
||||||
|
\definecolor{bg}{RGB}{186, 233, 255}
|
||||||
|
\colorlet{shadecolor}{bg}
|
||||||
|
\usepackage{lipsum}
|
||||||
|
\newenvironment{displayquote}
|
||||||
|
{\begin{shaded*}
|
||||||
|
\quoting[leftmargin=0pt, vskip=0pt]
|
||||||
|
}
|
||||||
|
{\endquoting
|
||||||
|
\end{shaded*}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
\begin{document}
|
\begin{document}
|
||||||
|
|
||||||
\includepdf[pages=-]{frontpage/frontpage.pdf}
|
\includepdf[pages=-]{frontpage/frontpage.pdf}
|
||||||
|
|
@ -65,8 +83,8 @@
|
||||||
\input{chapters/2_background}
|
\input{chapters/2_background}
|
||||||
\input{chapters/3_methods}
|
\input{chapters/3_methods}
|
||||||
\input{chapters/4_design}
|
\input{chapters/4_design}
|
||||||
\input{chapters/5_case}
|
\input{chapters/5_case/main}
|
||||||
\input{chapters/6_survey}
|
\input{chapters/6_interviews}
|
||||||
\input{chapters/7_conclusion}
|
\input{chapters/7_conclusion}
|
||||||
|
|
||||||
\clearpage
|
\clearpage
|
||||||
|
|
|
||||||
221
thesis/ref.bib
221
thesis/ref.bib
|
|
@ -306,3 +306,224 @@
|
||||||
year={1999},
|
year={1999},
|
||||||
publisher={Annual Reviews 4139 El Camino Way, PO Box 10139, Palo Alto, CA 94303-0139, USA}
|
publisher={Annual Reviews 4139 El Camino Way, PO Box 10139, Palo Alto, CA 94303-0139, USA}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@article{ritchie1978unix,
|
||||||
|
title={The UNIX time-sharing system},
|
||||||
|
author={Ritchie, Dennis M and Thompson, Ken},
|
||||||
|
journal={Bell System Technical Journal},
|
||||||
|
volume={57},
|
||||||
|
number={6},
|
||||||
|
pages={1905--1929},
|
||||||
|
year={1978},
|
||||||
|
publisher={Wiley Online Library}
|
||||||
|
}
|
||||||
|
|
||||||
|
@book{salus1994quarter,
|
||||||
|
title={A quarter century of UNIX},
|
||||||
|
author={Salus, Peter H},
|
||||||
|
year={1994},
|
||||||
|
publisher={ACM Press/Addison-Wesley Publishing Co.}
|
||||||
|
}
|
||||||
|
|
||||||
|
@inproceedings{hynes2017data,
|
||||||
|
title={The data linter: Lightweight, automated sanity checking for ml data sets},
|
||||||
|
author={Hynes, Nick and Sculley, D and Terry, Michael},
|
||||||
|
booktitle={NIPS MLSys Workshop},
|
||||||
|
volume={1},
|
||||||
|
year={2017}
|
||||||
|
}
|
||||||
|
|
||||||
|
@article{bishop1998robust,
|
||||||
|
title={Robust programming},
|
||||||
|
author={Bishop, Matt},
|
||||||
|
journal={handout for},
|
||||||
|
year={1998}
|
||||||
|
}
|
||||||
|
|
||||||
|
@article{arnaoudova2016linguistic,
|
||||||
|
title={Linguistic antipatterns: What they are and how developers perceive them},
|
||||||
|
author={Arnaoudova, Venera and Di Penta, Massimiliano and Antoniol, Giuliano},
|
||||||
|
journal={Empirical Software Engineering},
|
||||||
|
volume={21},
|
||||||
|
number={1},
|
||||||
|
pages={104--158},
|
||||||
|
year={2016},
|
||||||
|
publisher={Springer}
|
||||||
|
}
|
||||||
|
|
||||||
|
@inproceedings{blackwell2001cognitive,
|
||||||
|
title={Cognitive dimensions of notations: Design tools for cognitive technology},
|
||||||
|
author={Blackwell, Alan F and Britton, Carol and Cox, Anna and Green, Thomas RG and Gurr, Corin and Kadoda, Gada and Kutar, Maria S and Loomes, Martin and Nehaniv, Chrystopher L and Petre, Marian and others},
|
||||||
|
booktitle={International conference on cognitive technology},
|
||||||
|
pages={325--341},
|
||||||
|
year={2001},
|
||||||
|
organization={Springer}
|
||||||
|
}
|
||||||
|
|
||||||
|
@inproceedings{butler2009relating,
|
||||||
|
title={Relating identifier naming flaws and code quality: An empirical study},
|
||||||
|
author={Butler, Simon and Wermelinger, Michel and Yu, Yijun and Sharp, Helen},
|
||||||
|
booktitle={2009 16th Working Conference on Reverse Engineering},
|
||||||
|
pages={31--35},
|
||||||
|
year={2009},
|
||||||
|
organization={IEEE}
|
||||||
|
}
|
||||||
|
|
||||||
|
@article{deissenboeck2006concise,
|
||||||
|
title={Concise and consistent naming},
|
||||||
|
author={Deissenboeck, Florian and Pizka, Markus},
|
||||||
|
journal={Software Quality Journal},
|
||||||
|
volume={14},
|
||||||
|
number={3},
|
||||||
|
pages={261--282},
|
||||||
|
year={2006},
|
||||||
|
publisher={Springer}
|
||||||
|
}
|
||||||
|
|
||||||
|
@article{hand2001idiot,
|
||||||
|
title={Idiot's Bayes—not so stupid after all?},
|
||||||
|
author={Hand, David J and Yu, Keming},
|
||||||
|
journal={International statistical review},
|
||||||
|
volume={69},
|
||||||
|
number={3},
|
||||||
|
pages={385--398},
|
||||||
|
year={2001},
|
||||||
|
publisher={Wiley Online Library}
|
||||||
|
}
|
||||||
|
|
||||||
|
@article{beltagy2019scibert,
|
||||||
|
title={SciBERT: A pretrained language model for scientific text},
|
||||||
|
author={Beltagy, Iz and Lo, Kyle and Cohan, Arman},
|
||||||
|
journal={arXiv preprint arXiv:1903.10676},
|
||||||
|
year={2019}
|
||||||
|
}
|
||||||
|
|
||||||
|
@inproceedings{Lo2020S2ORCTS,
|
||||||
|
title={S2ORC: The Semantic Scholar Open Research Corpus},
|
||||||
|
author={Kyle Lo and Lucy Lu Wang and Mark Neumann and Rodney Michael Kinney and Daniel S. Weld},
|
||||||
|
booktitle={ACL},
|
||||||
|
year={2020}
|
||||||
|
}
|
||||||
|
@article{wang2019review,
|
||||||
|
title={A review of microsoft academic services for science of science studies},
|
||||||
|
author={Wang, Kuansan and Shen, Zhihong and Huang, Chiyuan and Wu, Chieh-Han and Eide, Darrin and Dong, Yuxiao and Qian, Junjie and Kanakia, Anshul and Chen, Alvin and Rogahn, Richard},
|
||||||
|
journal={Frontiers in Big Data},
|
||||||
|
volume={2},
|
||||||
|
pages={45},
|
||||||
|
year={2019},
|
||||||
|
publisher={Frontiers Media SA}
|
||||||
|
}
|
||||||
|
|
||||||
|
@techreport{buckley1985implementation,
|
||||||
|
title={Implementation of the SMART information retrieval system},
|
||||||
|
author={Buckley, Chris},
|
||||||
|
year={1985},
|
||||||
|
institution={Cornell University}
|
||||||
|
}
|
||||||
|
|
||||||
|
@article{mikolov2013efficient,
|
||||||
|
title={Efficient estimation of word representations in vector space},
|
||||||
|
author={Mikolov, Tomas and Chen, Kai and Corrado, Greg and Dean, Jeffrey},
|
||||||
|
journal={arXiv preprint arXiv:1301.3781},
|
||||||
|
year={2013}
|
||||||
|
}
|
||||||
|
|
||||||
|
@article{el2021automatic,
|
||||||
|
title={Automatic text summarization: A comprehensive survey},
|
||||||
|
author={El-Kassas, Wafaa S and Salama, Cherif R and Rafea, Ahmed A and Mohamed, Hoda K},
|
||||||
|
journal={Expert Systems with Applications},
|
||||||
|
volume={165},
|
||||||
|
pages={113679},
|
||||||
|
year={2021},
|
||||||
|
publisher={Elsevier}
|
||||||
|
}
|
||||||
|
|
||||||
|
@inproceedings{berkovsky2008aspect,
|
||||||
|
title={Aspect-based personalized text summarization},
|
||||||
|
author={Berkovsky, Shlomo and Baldwin, Timothy and Zukerman, Ingrid},
|
||||||
|
booktitle={International Conference on Adaptive Hypermedia and Adaptive Web-Based Systems},
|
||||||
|
pages={267--270},
|
||||||
|
year={2008},
|
||||||
|
organization={Springer}
|
||||||
|
}
|
||||||
|
|
||||||
|
@article{hayashi2021wikiasp,
|
||||||
|
title={WikiAsp: A dataset for multi-domain aspect-based summarization},
|
||||||
|
author={Hayashi, Hiroaki and Budania, Prashant and Wang, Peng and Ackerson, Chris and Neervannan, Raj and Neubig, Graham},
|
||||||
|
journal={Transactions of the Association for Computational Linguistics},
|
||||||
|
volume={9},
|
||||||
|
pages={211--225},
|
||||||
|
year={2021},
|
||||||
|
publisher={MIT Press}
|
||||||
|
}
|
||||||
|
|
||||||
|
@article{iwatsuki2022extraction,
|
||||||
|
title={Extraction and evaluation of formulaic expressions used in scholarly papers},
|
||||||
|
author={Iwatsuki, Kenichi and Boudin, Florian and Aizawa, Akiko},
|
||||||
|
journal={Expert Systems with Applications},
|
||||||
|
volume={187},
|
||||||
|
pages={115840},
|
||||||
|
year={2022},
|
||||||
|
publisher={Elsevier}
|
||||||
|
}
|
||||||
|
|
||||||
|
@inproceedings{iwatsuki2021communicative,
|
||||||
|
title={Communicative-Function-Based Sentence Classification for Construction of an Academic Formulaic Expression Database},
|
||||||
|
author={Iwatsuki, Kenichi and Aizawa, Akiko},
|
||||||
|
booktitle={Proceedings of the 16th Conference of the European Chapter of the Association for Computational Linguistics: Main Volume},
|
||||||
|
pages={3476--3497},
|
||||||
|
year={2021}
|
||||||
|
}
|
||||||
|
|
||||||
|
@article{iwatsuki2021extraction,
|
||||||
|
title={Extraction of Formulaic Expressions from Scientific Papers},
|
||||||
|
author={Iwatsuki, Kenichi and Aizawa, Akiko},
|
||||||
|
journal={methods},
|
||||||
|
volume={362},
|
||||||
|
pages={7--469},
|
||||||
|
year={2021}
|
||||||
|
}
|
||||||
|
|
||||||
|
@inproceedings{iwatsuki2020evaluation,
|
||||||
|
title={An evaluation dataset for identifying communicative functions of sentences in English scholarly papers},
|
||||||
|
author={Iwatsuki, Kenichi and Boudin, Florian and Aizawa, Akiko},
|
||||||
|
booktitle={12th Conference on Language Resources and Evaluation (LREC 2020)},
|
||||||
|
year={2020}
|
||||||
|
}
|
||||||
|
|
||||||
|
@article{cohen1960coefficient,
|
||||||
|
title={A coefficient of agreement for nominal scales},
|
||||||
|
author={Cohen, Jacob},
|
||||||
|
journal={Educational and psychological measurement},
|
||||||
|
volume={20},
|
||||||
|
number={1},
|
||||||
|
pages={37--46},
|
||||||
|
year={1960},
|
||||||
|
publisher={Sage Publications Sage CA: Thousand Oaks, CA}
|
||||||
|
}
|
||||||
|
|
||||||
|
@book{schutze2008introduction,
|
||||||
|
title={Introduction to information retrieval},
|
||||||
|
author={Sch{\"u}tze, Hinrich and Manning, Christopher D and Raghavan, Prabhakar},
|
||||||
|
volume={39},
|
||||||
|
year={2008},
|
||||||
|
publisher={Cambridge University Press Cambridge}
|
||||||
|
}
|
||||||
|
|
||||||
|
@article{miller1956magical,
|
||||||
|
title={The magical number seven, plus or minus two: Some limits on our capacity for processing information.},
|
||||||
|
author={Miller, George A},
|
||||||
|
journal={Psychological review},
|
||||||
|
volume={63},
|
||||||
|
number={2},
|
||||||
|
pages={81},
|
||||||
|
year={1956},
|
||||||
|
publisher={American Psychological Association}
|
||||||
|
}
|
||||||
|
|
||||||
|
@book{martin2009clean,
|
||||||
|
title={Clean code: a handbook of agile software craftsmanship},
|
||||||
|
author={Martin, Robert C},
|
||||||
|
year={2009},
|
||||||
|
publisher={Pearson Education}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue