11 ms·
From Python to Elixir Machine Learning
- mkranjec 3y agoAt first I thought what does Nx (nrwl/nx) has to do with machine learning, then I figured context is about Elixir lib named Nx. Naming things is hard.
- dsiegel2275 3y agoAgreed, naming things is hard. That and off by one errors are the three hardest things in software development, IMO.
- madspindel 3y agoInstead of moving to Elixir I believe it makes more sense to wait/move to Mojo when it's ready: https://www.modular.com/mojo https://www.modular.com/mojo
- weatherlight 3y agoElixir (NX) is ready now, Mojo might be, at some time in the future.... also Mojo won't have the BEAM or ergonomics around Functional Programming.
- nologic01 3y agoML is not an island, it is part of a much broader "data science" universe that is currently served fairly well (still imperfectly) by the Python/C++ stack and is not easy to replicate. Throwing BEAM or FP acronyms around won't really strike a chord with people working with data and models. Mojo will (as per promise) tap into the wider ecosystem. Other platforms are more than welcome to try but this ultimately requires a huge community of scientists / developers to become a real alternative.
- uoaei 3y agoThere are very real limitations to the tooling approach summarized as "slightly more ergonomic APIs to underlying C/C++ code" that is currently dominant in Python qua ML. One of the biggest is of course extensibility, which, if difficult enough (as is the case in most Python ML tools unless you're extending only at the relatively slow Python layer) drastically hinders progress in making tooling better while keeping performance good. Other languages have certain features that make extension and integration feel like first-class concerns which lowers the barrier to contributions from a wider range of people and also helps keep e.g. dependencies and build processes relatively simple.
- nologic01 3y agoI would not necessarily disagree with any of these points, just sceptical that these are enough to create the substantial investment by diverse actors to create real alternatives. The example of Julia non-adoption is very important to keep in mind. Python was not designed for ML, it happened to it, the way Android happened to Java etc. Loosely speaking the Mojo project serves a function similar to that of Kotlin in the Android mobile world. Trying to remedy some recognized friction points while maintaining the benefits of a widely established ecosystem. Obviously not holding a crystal ball: if the ML hype mutates into something more permanent and very widely embedded across different verticals (not just the big tech sponsored pytorch / tensorflow platforms and use cases) and if the Python/C++ combo becomes a recognized bottleneck then the conditions might spark another approach.
- formulathree 3y agoPython syntax has really good ergonomics around functional programming. I hardly write loops when I use the language now.
- pjmlp 3y agoGiven how Swift for Tensorflow went, how openai was equally pushing for it, I would rather take a "wait and see" approach to Mojo.
- AlchemistCamp 3y agoDo you mean OpenAI or do you maybe mean Fast.ai?
- pjmlp 3y agoIt might have been fast.ai, not sure.
- ilikehurdles 3y agoNo source code, no thanks.
- throwawaymaths 3y agoSince it aims to be transparently compatible with python Mojo will very likely suffer from the worst part of python: packaging Last week heard a story about an ML dev that would literally rebuild his system every week because python would break it
- mrdoops 3y agoMojo is pretty cool but its a difficult road to take - especially to implement the breadth of accrued functionality of a 20 year old language like Python. Elixir & Python are not an apples to apples comparison - there are fundamental differences in the programming model (functional, immutability, etc) and runtime (preemptive scheduling + OTP) that is the reason it has distinct advantages not available without heavy cost trade-offs elsewhere. Either way once Mojo is production ready Elixir will be able to use it as well like it does Rust, Zig, or Python.
- matt_daemon 3y agoI wish there wouldn’t be such a song and dance about “moving away from Python”. There’s nothing wrong with creating ML tools in Elixir, but it’s always Python is slow, Python has no concurrency support, blah blah
- sodapopcan 3y agoThis article in particular doesn't feel like there's any song and dance. The very first line is directed at people already using Elixir who are looking to stay in Elixir-land while getting deeper into ML.
- OJFord 3y ago"Everything is working fantastically with our python ML project but we're rewriting it in Elixir anyway" would be a weird article wouldn't it?
- substation13 3y agoThose are real issues though.
- lopatin 3y agoIs concurrency useful for ML?
- not-my-account 3y agoYou end up having to do a lot of things in a ML training run, some of which you can do in parallel because it’s not important now (eg saving metadata) or because you’d otherwise be resource limited (eg loading data and formatting batches for training)
- davidktr 3y agoAnd for this you cannot use Python's multiprocessing because ... ? Sure, moving data between processes is slow because of pickling [0]. However, I'm using parallel processing for the things you suggested, and for these it works great. If I really had the use case and needed threads, I'd much rather use C++ bindings in a Python package than rebuilding the whole thing. Guess it depends on the scale we are talking about. [0] https://pythonspeed.com/articles/faster-multiprocessing-pickle/ https://pythonspeed.com/articles/faster-multiprocessing-pick...
- thibaut_barrere 3y agoDon't miss the interesting book (which I just bought) in beta here: https://pragprog.com/titles/smelixir/machine-learning-in-elixir https://pragprog.com/titles/smelixir/machine-learning-in-eli...
- ricketycricket 3y agoRecommendation seconded. I'm only to chapter three due to time constraints, but it is well written and approachable for someone lacking ML experience.
- pawelduda 3y agoI use Elixir for a long time and wouldn't recommend it for ML over Python. Yes, maybe Elixir has some advantages and solutions for pain points because of VM architecture and other subjective reasons but doesn't come close to what Python offers in terms of tooling, support, community. Also, if you juggle more complex data in Elixir, it's something that you need to get used to coming from Python, it will be much much different and therefore harder to grok for someone not used to the style. You can always make Elixir app talk to Python ML backend and get the best of both worlds if you desire.
- dpflan 3y agoHave you used Numerical Elixir (Nx)?
- nesarkvechnep 3y agoSo you wouldn’t recommend it because it’s different than Python?
- bcardarella 3y agoNx solves all of the issues you're citing. That is how you do ML in Elixir
- jswny 3y agoWhat ML tooling is better in Python?
- pawelduda 3y agoI can no longer edit parent post so to further elaborate on tooling: even if Elixir was comparable to Python (let's assume it's true as of today), there is a lot going on in AI, so that won't necessarily be true tomorrow. There is no doubt Elixir will always be slower to catch up to recent development because of smaller community. This also applies to how quickly issues will be resolved as they appear. It's likely OK if you're toying with a hobby ML project on your own, but not something you'd want in a startup with stakeholders who have expectations in regards to timeline, and so on... I like Elixir for web development otherwise, it is a much more stable domain so above doesn't apply (although I've seen some claim otherwise, which is telling how much more of an issue it would be for niche ML use case). I'd be very happy to be proven wrong by some case studies of how companies leveraged Elixir in real ML projects and concluded it is superior to Python.
- bongobingo1 3y agoSomething not mentioned is Explorer (https://hexdocs.pm/explorer/Explorer.html https://hexdocs.pm/explorer/Explorer.html) which is a very nice dataframe library backed by Rusts Polars https://www.pola.rs/ https://www.pola.rs/ with great integrations for Livebook https://livebook.dev/ https://livebook.dev/.
- el_oni 3y agoI found explorer quite frustrating. I've used polars in python and loved it, but I brought in some financial data and couldn't strip off "£" from the start of a string so I could go on to cast it to a number. As far as I could tell I would have to bring that data into elixir, do the text processing and put it back into explorer, which to me defeated the whole point of a dataframe library. I imagine it's good for precleaned data, using it with the built in datasets has been fine
- ritchie46 3y agoYou can use str.slice or str.extract to clean the data: https://pola-rs.github.io/polars/py-polars/html/reference/expressions/api/polars.Expr.str.slice.html#polars.Expr.str.slice https://pola-rs.github.io/polars/py-polars/html/reference/ex...
- el_oni 3y agoYes for polars in python. This was an issue I had with explorer in elixir. There is no elixir binding to the str.slice or str.extract functions yet
- josevalim 3y agoJosé from the Nx/Explorer team here. Feel free to open up an issue! We have been focused more on high-level features (such as integration with S3, Postgres, Snowflake, SQLite, etc) and therefore we are missing many functions that already exist on Polars. Good news is that it is very quick to add them, so just let us know. :)
- 3y ago
- ranjanprj 3y agoI just ran a 2006 Java code to detect and read car license plate, and it ran in the first run on Java 17. The code is 17 years old and runs just fine without any issues. I think Java folks messed up AI/ML space due to licensing. But I still think it's best PL for AI/ML.
- frakt0x90 3y agoWhat makes it the best language for AI and ML? I've never heard that take so just curious your thoughts. It's nice that legacy code still runs but that's usually not people's concern in ML.
- itronitron 3y agoI (and my colleagues) have worked on statistical, data analysis, and ML in Java since before data science was even a career field, and before Python became popular. In my opinion Java has better IDE support, more stable and proven libraries, and high performance. Java does occasionally require that a person might have to implement their own code after reading a research paper, but I've always enjoyed that part of the job. I've never understood Python's popularity except that I've heard some people say that it's used at Google.
- realusername 3y agoYou would be happy in Elixir as well, the language is pretty much frozen and very small bug fixes and features are added. It's definitely not a fast moving language.
- paulluuk 3y agoShow me I can save a considerable amount of time training a 70b parameter huggingface model by switching to Elixir, then we can talk about me learning a new language.
- josevalim 3y agoThe training costs and performance at that scale are mostly driven by hardware and I personally don't think language will make a large difference (I may be wrong). Most of the Elixir Nx efforts are on inference, especially on how you can embed and scale it using concurrent and distributed patterns (see this post/video [1]). It may not be what you are looking for but we have more folks deploying than training models, so maybe they will find incentives to give Elixir a try. :) [1]: https://news.livebook.dev/distributed2-machine-learning-notebooks-with-elixir-and-livebook---launch-week-1---day-2-1aIlaw https://news.livebook.dev/distributed2-machine-learning-note...
- sodapopcan 3y agoSeems like you didn't read even the first line as this article is directed at people already using Elixir who are currently doing ML stuff with Python.
- paulluuk 3y agoI did actually read most of the article. Did you read the section immediately after that? > Why is Python not Sufficient? It then proceeds to make a case why Python would not have enough speed or support for parallel processing, which is what I'm disputing.
- throwawaymaths 3y agolots of negativity in here from people who have invested a lot of effort learning python, despite that there's also people who complain a lot about ML/DS in python. Is it an expression of sunk cost fallacy? If you don't support people who are trying to make a difference, nothing will change.
- mrdoops 3y agoIt's a weird mental block too - learning a language like Elixir, being so well designed and documented, is as comfortable as it gets. Devs we hire without direct Elixir experience pick it up really quick (within a couple weeks). The energy needed to "get good" with Elixir is really not much considering it provides veritable super powers on the backend and introduces a whole category of concurrency concepts that are not easy to grasp elsewhere.
- throwawaymaths 3y agospecifically over python, immutability in function passing is amazing for beginners and dealing with beginners. How confident are you that the junior you just hired is operating correctly in the other_code module they're responsible for import other_code, as: other def f: my_dict = {"foo": 1, "bar": 2} other.function(my_dict) return my_dict["foo"] # ==> you might be wrong about what's in my_dict
- codybontecou 3y agoDo you know which resources your devs are using to learn Elixir from scratch?
- mrdoops 3y ago* Elixir-lang Intro: https://elixir-lang.org/getting-started/introduction.html https://elixir-lang.org/getting-started/introduction.html * Exercism track: https://exercism.org/tracks/elixir https://exercism.org/tracks/elixir * Sasa Juric's book: https://www.manning.com/books/elixir-in-action-third-edition https://www.manning.com/books/elixir-in-action-third-edition * Dave Thomas's Elixir Course: https://codestool.coding-gnome.com/courses/elixir-for-programmers-2 https://codestool.coding-gnome.com/courses/elixir-for-progra... * Phoenix Guides: https://hexdocs.pm/phoenix/overview.html https://hexdocs.pm/phoenix/overview.html * Ecto Guides: https://hexdocs.pm/ecto/getting-started.html https://hexdocs.pm/ecto/getting-started.html The above covers the language basics/ideas/concepts and the main tooling (Phoenix/Ecto) if you're looking to build apps or get an Elixir job. I definitely recommend the Phoenix Guides or similar - they're very high quality and kept up to date with any new releases or changes while books can sometimes get out of date.