When you’re programming an artificial intelligence application, you’re usually building statistical models that output discrete values. Is that image a human face? Whose face is it?
Is that face expressing a positive or negative emotion? Does that emotion fall outside the range of those that we would consider typical of this situation, or does it indicate someone who might require immediate intervention by family, mental health professionals or the police? And so on.
However, AI models rarely produce these statistical evaluations at confidence levels of 100 percent. Those confidence levels and probability distributions are themselves key statistical insights, and a programmer should, ideally, have tools, libraries, languages and application programming interfaces for outputting the underlying probability from AI models at runtime.
There are many tools on the market for probabilistic programming. One of the core approaches that most of them support is Bayesian analysis, for which there is a well-established set of specialized programming languages. As more data scientists shift their professional focus to deep learning, machine learning and other AI paradigms, they will require a new generation of probabilistic programming languages for these, as well as for Bayesian analysis, that are supported in their core development environments.
A month ago, Google Inc. made a wide range of product announcements designed to improve the productivity of developers working in its widely adopted open-source TensorFlow framework. At its big AI developer summit, one of those announcements was the new TensorFlow Probability library for probabilistic programming.
It provides modular abstractions that enable developers to factor the probability distributions of their data sets, not just the discrete data points and arithmetical operations on it, into their TensorFlow models. This capability can be essential when working with multidimensional training data who structure is a key input into program logic.
This new TensorFlow Probability library, along with associated APIs and language bindings, supports integrated probabilistic reasoning with deep neural networks that use gradient-based inferencing. Just as important, it enables TensorFlow models that incorporate probabilistic methods to execute rapidly, scalably and in distributed fashion on large datasets on graphics processing units, Tensor processing units and other optimized hardware substrates.
For TensorFlow developers, the key features of this new probabilistic programming library (for which the figure below provides a graphical overview) include:
- Prepackaged reusable probability distributions;
- Trainable implementationsof probability distributions with metrics that can be easily plugged into neural nets;
- A domain-specific languagefor programmatically specifying probabilistic models;
- Extensions to TensorFlow layersthat output probabilistic variables over the functions they express and extensions to TensorFlow optimizers to support stochastic optimization methods;
- Probabilistic algorithms for doing Markov chain, Monte Carloand variationalinferencing; and
- End-to-end exampleswith scripts and tutorial notebooks for programming in TensorFlow probability.
If you’re an AI developer wanting to get started in probabilistic programming, here’s a good reference site that provides code examples for building Bayesian agents for natural language processing, computer vision and semantic analytics.
If you’re involved in “AI safety” projects, you may need to make heavy use of probabilistic programming to build algorithmic guardrails apps that can adapt to changing confidence levels associated with any of all of the following operating scenarios:
- Throttling AI-driven decision making in circumstances where the uncertaintyis too great to justify autonomous actions;
- Triggering an AI-driven application to activate failsafe proceduresthat allow humans to take back control;
- Relying on probabilistic logic that promotes a more predictable AI model to runtime status when the current in-production model begins to decay in its ability to deliver consistent, predictable outcomesand that are free from unintended side effectsunder changing circumstances; and
- Ensuring that operationalized AI models fail gracefully — in terms of executing probabilistic logic that lowers their risk profile — rather than catastrophicallywhen the runtime environment deviates significantly from circumstances for which they were trained.
There are countless potential applications of probabilistic programming in driving real-time, adaptive patterns in the nondeterministic integration fabrics of cloud microservices, as I discussed here. If you want an in-depth study of the design, uses and constraints of these languages for AI applications, check out this recent IBM Research paper. And check out this recent video for a good tutorial on probabilistic programming languages: