scale.bythebay.io: Adam Pingel, Lawful AI
Recording: scale.bythebay.io: Adam Pingel, Lawful AI
hi everybody my name is Adam Pingel I spoke here a couple years ago I think it was hosted elsewhere over in Oakland at that time I was about to join Ravel Oz VP of engineering that company has since been acquired by LexisNexis that was back in June of this year I have I been the VP of engineering at Ravel law I'm currently senior director at LexisNexis my team span data science which includes computational linguistics and machine learning all the way up through and including the the client-side apps the products that we build and put in the hands of our customers I'm going to be speaking up less to my work experiences and a little bit more about kind of opinions and experiences from academia over the last quarter century and how I see that relating to the work that I do my background is in computer science I've got an undergrad degree in computer science and was in a ph.d program in computer science with major field in programming languages and minor fields in AI and linguistics I left that a little bit early came up back up to the Bay Area with a master's degree and I've mainly been in management over the last five years so I'm gonna be talking about a lot of things including category theory for instance that I'm you know in most respects not qualified to be speaking about but you know it's we bump into it a lot here in functional programming in Scala and I think I think talking about where that's headed it is important for this community and so I'm gonna describe how I view the state of the ecosystem here in Scala and talk about a few concrete things that I think we should be doing well a few things we should be doing one of which is fairly concrete and I think very defensible the second one is a little bit more vague and less clear and then third one I'm going to stick my neck way out it's very speculative assertion and I should say also I was originally intending to talk about this is a picture of the axle lane org it's a open-source project I've had running for the last six years or so I recently been adding more visualization capabilities to it but I decided that I wanted to focus on this question that Rob Norris asked last year I think was halfway through the last panel on the panel was what's the future of functional programming and he has this great question basically said we keep coming to these conferences year after year and I think he used the word craze five years ago we're talking about Monde ads two three years ago it's Fremont ads last year fixed-point types where is this going where is it going to settle down I think that the points also being it's not easy to keep up with this stuff my day job is management I only got so many hours a week to keep up with the latest theories and it's it's a lot it's a lot to to handle and I think there's also an argument that some of these abstractions get more powerful but more abstract and a little bit harder to learn so so where is this going to settle down and I that on the panel last year there was a great 10-minute response to that question and I think some of those themes are going to come about come up in my my response as well but another point I would make about the question is it's really really big and I think this is the kind of question we're focusing on a specific community or specific use case is really important so that the use case that I'm interested in talking about and thinking about is data science machine learning artificial intelligence natural language processing I also need to be building distributed systems I want to get concurrency right I want to handle errors correctly but I think there's this other set of concerns which have to do with building machine learning libraries that I want to focus on today so this is kind of I encoded my mental image of how I think about the Scylla ecosystem and these are both fairly subjective axes so on the x-axis here I've got kind of the degree of lawfulness of a library the vertical access is the interest level that that data scientists that I've known in my in my experience would have for those libraries so it is not hard at all to sell scikit-learn to a data scientist that's like that's one hundred percent score they love that on the other hand something like cats or Scala Zed I've had discussions with data scientists about those libraries and it's it's hard to motivate it's hard to get them really excited about it because it doesn't help them do their job certainly on the short-term and also I would add that a lot of the people that I've worked with in those roles don't really have they might have a statistics background but they don't really have a math background they don't have abstract algebra actually I don't know that I've worked with a single person who does maybe maybe one guy on my team currently and so what I think ends up happening then is that we we end up kind of neglecting this this upper right portion of the of this of the ecosystem now I do have some non scala projects listed here so I've got some Java stuff Hadoop guava juice out over there on the left side there's a couple of Python projects up there there's one Haskell project called H learn that I've put in the upper right there that's something that the pulse knively mentioned last year that I've spent a little bit of time looking with looking at but I think coming to these scala conferences we end up talking a lot about this stuff Scala Zed versus cats and matroyshka has an amazing library and we've got to get this stuff right but at the same time I think you know somebody I for one it kind of interested in using some of these techniques to implement some of the some of the algorithms that we see on kind of the upper left of this this plot and there's a lot of the stuff occupying the upper right quadrant here are written by current spire employees former Twitter employees things like algebra rush fire scalding frameless spire if you haven't used it is this incredible library that I think was released around 2013 it's got a lot of type classes from abstract algebra so if you think of the Haskell type class of pedia that has Mon add and and applicative functor and that sort of thing there's another set of type classes which complements that really nicely from abstract algebra those are things like vector space metric space group and that that sort of thing so why would we want to do this to to be building libraries in the upper right hand corner of that of that plot I think there are three categories of reasons one is for all the same reasons that any other software you would build could benefit and I'll give a couple of specific examples of that the other is to help us communicate with and leverage other fields and then kind of the most speculative one that you know I'll just I'll stick my neck out and say I think uh you know we're not done building AI algorithms yet and we need concepts that are going to help power those things and I think the mathematics that we're finding to to build lawful libraries could potentially be fodder for new generations of algorithms so the usual suspects why we why we use FP apply to machine learning systems just as they do anywhere else we're building distributed systems I at work I tended we tend to build a lot of supervised models so we're creating in-house annotation datasets we're training evaluating those models and we're deploying them quickly into the product so there's some new workflows there but if for the most part it's just software and so referential transparency is as important to those kinds of systems as they are anywhere else and also I think the the easy parallelization story is it works well we're able to get data scientists which don't necessarily have training and distributed systems to build to to build algorithms to scale out kind of naturally from from day one but the one specific example I might bring up about controlling side-effects that I've seen apply to machine learning is is tracking entropy consumption as side effect I've been kind of waiting my whole life to to run into that as a bug and I finally did a few months ago so consuming entropy whether you think about it as IO or not it's it's definitely a side effect and at work we we process our corpus every week anew we build a knowledge graph from the the legal case law every week and so because we're doing this we need to monitor very closely how it's changing week over week to make sure we haven't introduced any bugs so over the the months the many months year to two we've been finding those bugs and eliminating them but there was one lingering little issue that led to a little bit of noise week of a week and it took us several weeks to track this thing down but it turned out I think it was some kind of deep learning model was an h2o library that it turned out consumed a little bit of entropy when you applied applied the model and we had that shown up in the method signature we would have probably found and eliminated that bug a lot more quickly so I think that that's one little maybe machine learning specific side effect I think is worth noting the so to talk about each learn a little bit that was that point that was kind of in a farthest upper right point of that chart of the ecosystem because it's a it's a Haskell project it does make use of patterns from abstract algebra and I've stolen this this chart from its readme file in Scott you know a lot of kind of benefits listed in in that second column and these are things that I can sell to to data scientists and get them excited about so things like parallel batch training online training cross-validation weighted data points or fractionally weighted data points those are those are of interest to data scientists and the the way that this particularly this particular library happens to achieve them is by leveraging patterns from abstract algebra so those are listed in the first column mano ADA Balian group our modules vector spaces filters and Mon adds so I think that's that's great and it shows an example of what we can do if we bring two these two things however I would say you know those are not necessarily my pain points so the speed of cross-validation was was never necessarily a bottleneck but I think there's this other there's this other point that's made in the documentation that it currently has the fastest nearest neighbor implementation for arbitrary metric spaces that's pretty interesting to be able to kind of parameterize this algorithm in terms of arbitrary metric spaces is not something I've seen in a lot of machine learning libraries so in the fact that it's fast at least two other things that do that is is great so that the author spent a lot of time in performance optimization I think the challenge here though is to find an example of a sort of non-standard non Euclidean metric space that's gonna be really motivating that's gonna allow that data sense data scientists to solve a problem that they've not been able to solve previously so so that's sort of the concrete stuff there was a second set of issues around just being able to leverage what's going on in other communities and within our own community here of Scala and I think you know I think of the tower Babel the tale of this king building a tower and and making God angry and so he destroys the tower and you know he creates the what is it the confusion of the tongues turn creates all the languages on earth and I think sometimes I feel like that both in the Scala community or just as as a scientist learning about other fields is that we are speaking we're basically mutually unintelligible to one another and I had a specific example I'll try to get get through this anecdote quickly but I had a specific example of this in in grad school I was taking a course on causality from Professor pearl and I he was talking about the Simpsons paradox which comes up to statistics it's basically I think the canonical example is looking for gender you'd see the hiring or or its gender bias in hiring or application admissions and it doesn't show up when you look at UC Berkeley as a whole but when you look at each each department separately it's it's clear as day so that's Simpsons paradox and the way it was being described reminded me of the prisoner's dilemma iterated prisoner's dilemma something about the way collusion works with the iterated prisoner's dilemma reminded me of this kind of non-linearity that you see in Simpsons paradox and so I raised my hand made that point and basically got blank stares from everybody in the classroom now I think that's that's probably we sure the brain spread the blame around to a lot of parties there but I didn't have the language to be able to communicate what I was saying very effectively and I think that the writing style of the book that we were using wasn't something that worked well for me and then I asked the TA about it on the way up out of class and he didn't understand what I was trying to say either but it kept gnawing at me and it was either a few months or a year later I did some googling and sure enough this was a thing and it in fact the Nimrod megiddo who had done a lot of game theory research like he's local to the bay area he had written Perl making exactly this point and this letter was posted up online so you know I'm not the only one that's having trouble getting my point across between these fields and these are these are smart people Perl is brilliant Megiddo is brilliant but there's there's lots of debates and I think some of that energy we could focus a lot a lot better just as as a community so I think you know I think sometimes of programming and programming the communities as trying to compress our our symbols and our ideas we're looking for ideas that allow to allow us to express programs more succinctly more correctly and of course we the symbols that we're choosing have to also apply to enough situations and to that they're worth it but I think that's a lot what mathematics is doing the another field that I've had some exposure to is linguistics I see a lot of kind of you know we're basically trying to identify short elegant models that explain the phenomenon we're studying I think science in general is doing this to some extent so one of the things that that I found immediately upon leaving grad school coming back up to San Francisco in 2009 was there was this burgeoning scholar community and kind of adjacent to that category Theory meetups Vlad I don't know if he's in the room right now I saw him here today he was running a lot of these things and one of the first papers that came across my desk was this this paper known as the Rosetta paper it's it's called physics topology logic and computation a rosetta stone and again so we're getting at the point in the talk where I'm not really qualified to be speaking about this stuff but you know I it's it's at least inspiring to know that someone out there has in hand a theory that they can use to very deeply describe the these shared dynamics and shared structures across these four different fields so the the last two columns logic and computation we know that as the the Curie Howard isomorphism this deep correspondence between fox-fur programming and logic but using the category theory concept described on the leftmost column we can also make deep analogies to physics and topology I'm going to skip over a couple of anecdotes so the the last most speculative point I'd like to make is that I think a lot of machine learning and AI algorithms are using pretty old algebraic structures tensors for instance were formalized in the 1890s and they're the latest craze I don't think you know category theory may happen to be used in the implementation of some some algorithms but I don't think it's really central to the the understanding or the or the theory of any machine learning algorithm that I'm aware of and I think that there's potentially a lot of really interesting work ahead so I've got a got Dave here from 2001 on the on the the picture just to represent that I think this can be kind of mind-blowing especially that I don't have the kind of the mastery of category theory that I would need to be able to do this stuff but I I read about it I bump into it often enough that it I think there's something there and so I think about you know what what can I do to help you know if twenty years from now that's that's going to pan out what can I do to help myself get there and what can we do as a community to get us in a position where we're going to be able to rock that stuff and I think we need to start occupying this upper right hand space an easy way to think of project ideas is to just sort of pick two points here and then just kind of draw a line to the right draw a line up and and for instance you know spire is a great one implement some libraries from from implement some algorithms from pyro which is a new probabilistic programming library from uber implement some of those algorithms using some of the abstract algebra type classes from spire I think it's pretty easy to generate these things and I think then as the community will be better positioned to to take advantage of what I think will be a new generation of algorithms and I'm getting a little short on time but one thing I'll mention is there I think there's some evidence of this with a genetic programming a project called poly tope this I saw tweeted about several months ago someone's using shapeless to implement some of the aspects of genetic programming which if you haven't run into that it's basically an evolutionary search algorithm where we can think it's basically mimicking sexual reproduction the programs are floating around in you know in in an arena there's mate selection based on Fitness function and then instead of like DNA splicing we're basically taking Lisp expressions and kind of swapping sub expressions to create a new program well if you if you don't do that correctly or if you don't pay attention to the types you can that can easily result in a in an expression that's not well-formed that doesn't type check and so I think this this polytope project is using some techniques from shapeless to to address that and I think I'm gonna leave it at that so yeah happy to take any questions [Applause]