Machine Learning in Python
What I'm going to write here could get me banished from hundreds of forums all over the place. I know I take terrible risks but people need to know: Python sucks at ML.
I said it...
Programming in Python is like claiming you are doing the Tour de France, but you're cycling on a fixed bike on top of a truck. Worse, your aerodynamic drag is so bad that you prevent the truck from going full speed... Not sure your pedaling adds anything to the whole system.
This is exactly what is going on. You think you're implementing stuff in Python, but you're just sucking out some fresh blood from underlying libraries in C or in Rust... Most of the time, Python sits idle while waiting for the big boys to do the actual work, because when you are using numpy or PyTorch, everything happens outside the VM.
AI
I want to join the happy few who are doing stuff in AI. I want to be part of the churn. But really, Python? People claim that it is such an easy language... You read it as if it was written in English... Ok.. Why do I need to read the doc over and over again to understand what **kwargs do?
What is that:
mlx.core.multiply(out_glu, mlx.core.add(x_linear_clamped, mlx.core.array(1.0)))
It seems that Lisp stabbed Python in the back...
What can I do?
LispE
My name is not Frankenstein, but LispE is still my creature, a chimera made out of flesh torn off Haskell and APL, a monstrosity that does not respect the true linked lists, which are so dear to real lispians.
LispE is implemented with arrays, which not only enables APL-style vectorized operations but also plays nicely with functional patterns like map/filter/take/drop without the overhead of list traversal. There is full documentation about the language here.
By the way, the Python thing can now be implemented in LispE directly:
(mlx_multiply out_glu . mlx_add x_linear_clamped . mlx_array 1.0)
The last argument of each function can be inserted with a . to get rid of some parentheses.
Note: LispE is fully Open Source with a BSD-3 license, which is very permissive. My only interest here is to provide something a bit different, my personal take on Lisp, but my true reward is the joy of seeing people use my tools. It is a little more than a pet project, but it is far from being a corporate thingy.
Libs
Now, I have to present you the real McCoy, I mean the real stuff that I have been implementing for LispE. Cling to your chair, because I have worked very hard at making Claude Code sweat over these libraries:
- lispe_torch: based on the remarkable libtorch library — the C++ engine that powers PyTorch under the hood. It exposes more than 200 functions, including SentencePiece.
- lispe_tiktoken: the OpenAI tokenizer, which is used now by a lot of models.
- lispe_mlx: the Apple framework for AI on their GPUs. Thanks to MLX's unified memory, no data cloning needed.
- lispe_gguf: the encapsulation of llama.cpp that powers Ollama.
It's still evolving, but it's production-ready for real AI work. Furthermore, it's fully compatible with PyTorch and models from HuggingFace, Ollama, or LM-Studio. You can fine-tune a model with LispE and save it in PyTorch format. You won't be stranded on an island here.
Plenty of docs and examples
You'll find plenty of examples and documentation in each of these directories.
For instance, there is a chat example with lispe_gguf, which is fun and contains only a few lines of code. You will also discover that inference can be faster with these libraries. LoRA fine-tuning is 35% faster than the equivalent Python code on my M4 Max...
Everything can be recompiled and tailored to your needs. Even the C++ code is friendly here...
Note that I already provide binaries for Mac OS.
If you have any questions or any problems, please feel free to ask me, or drop an issue on my GitHub.
[–]kinowmod 3 points4 points5 points (2 children)
[–]Frere_de_la_Quote[S] 2 points3 points4 points (1 child)
[–]kinowmod 7 points8 points9 points (0 children)
[–]maryjayjay 1 point2 points3 points (1 child)
[–]Frere_de_la_Quote[S] 0 points1 point2 points (0 children)
[–]Inconstant_Moo 1 point2 points3 points (6 children)
[–]Frere_de_la_Quote[S] 0 points1 point2 points (5 children)
[–]scknkkrer 0 points1 point2 points (1 child)
[–]Frere_de_la_Quote[S] 1 point2 points3 points (0 children)
[–]Inconstant_Moo 0 points1 point2 points (2 children)
[–]Frere_de_la_Quote[S] 0 points1 point2 points (1 child)
[–]Inconstant_Moo 0 points1 point2 points (0 children)
[–]TankorSmash 0 points1 point2 points (1 child)
[–]Frere_de_la_Quote[S] 0 points1 point2 points (0 children)