data-science

Andriy Levitskyy 2024-08-06T13:44:23.716719Z

Regarding the post above, I have seen some Clojure wrappers around TensorFlow Java/JavaScript API on GitHub and was wondering why those projects stopped being developed / didn`t get a following? What are some problems a developer can encounter when making those wrappers, other than TensorFlow Java API documentation being lacking? Even though TensorFlow is hard to use, it has a lot of advantages especially for Clojure programmers: 1. Has very good performance on MacOS or other operating systems 2. Has both Java and Javascript API, so can easily run trained models in browser 3. There are many pre-trained models available for TensorFlow I was thinking that Jax-style functional wrapper for TensorFlow could be something that Clojure is very good at, and was wondering if there are some difficulties I don`t know about since I haven`t done much interop with Clojure yet.

phronmophobic 2024-08-06T16:36:15.715459Z

Do you have links to the wrappers you're thinking of?

Daniel Slutsky 2024-08-06T16:56:31.033719Z

Probably this is not the one Andriy is talking about, but https://djl.ai/ seems to be https://djl.ai/engines/tensorflow/, among other things, and it has https://github.com/scicloj/clj-djl. There used to be more direct wrappers a few years ago.

Daniel Slutsky 2024-08-06T16:58:07.146409Z

@levitskyyandriy I'm curious about what you have in mind for a Jax-style wrapper, and whether you've considered wrapping Jax itself.

Andriy Levitskyy 2024-08-07T00:58:43.842879Z

Just googling "tensorflow clojure github" there are like 5 different projects, all of which were developed 4-7 years ago and then discontinued. Top 3 with around 100 stars each are: https://github.com/kieranbrowne/clojure-tensorflow https://github.com/bpiel/guildsman https://github.com/enragedginger/tensorflow-clj

Andriy Levitskyy 2024-08-07T01:09:52.125739Z

@daslu IMO running models on client-side is still a hard problem, and Clojure may offer a good solution. I was considering wrapping Jax itself, but I think it is unbearable amount of effort for me as even Google (that owns both Jax and TensorFlow) suggests converting to TensorFlow first https://blog.tensorflow.org/2022/08/jax-on-web-with-tensorflowjs.html The reason why I mentioned TensorFlow, because it is the only mature framework that runs on Javascript and it also has both Java and Javascript API. I mentioned Jax, because of it is functional design which may resonate more with Clojure. Potentially, there could be a problem of mismatch between a functional API of Jax and non-functional core of TensorFlow

🙏 1
phronmophobic 2024-08-07T01:10:22.013959Z

What kinds of models would you like to run?

phronmophobic 2024-08-07T01:13:27.816889Z

llama.cpp (and by extension, llama.clj) supports many of the LLM models.

Andriy Levitskyy 2024-08-07T01:18:29.849919Z

I don`t use LLM models for now, but over career worked with time-series, tabular, image and text data, including models such as ResNet, UNet, WaveNet and BERT. I used PyTorch exclusively for all those, and currently just reading on what Clojure has to offer

👍 1
phronmophobic 2024-08-07T01:19:11.579279Z

llama.clj supports BERT

👍 1
phronmophobic 2024-08-07T01:21:32.315219Z

How do you work with the other *Net models? Do you train them yourself? Do you use a predefined architecture provided by a pytorch library?

Andriy Levitskyy 2024-08-07T01:27:13.887079Z

Image Classification: torchvision usually has good pre-defined architectures with downloadable pre-trained weights usually on ImageNet dataset Other Image/Video related tasks: there are frameworks on top of PyTorch such as https://github.com/open-mmlab/mmdetection that provide training/inference API Time-Series models: usually just build from scratch given layers in PyTorch NLP: https://github.com/huggingface/transformers huggingface transformers library on top of PyTorch would be my go-to place, they also provide their own training/inference API

🆒 1
phronmophobic 2024-08-07T01:29:25.221379Z

I'm still pretty new to to this, but it seems like almost all of the models are mostly just a bunch of matrix multiplications. However, I haven't been able to figure out if there's a better way of figuring out how to implement these models other than reading a bunch of dense c++, python, or academic papers.

phronmophobic 2024-08-07T01:31:40.150709Z

I've been playing around with a clojure wrapper of https://github.com/ggerganov/ggml?tab=readme-ov-file#updates, which I know can run several real-world models (like llama, yolo, and stable diffusion). I haven't been able to figure out if there's some straightforward way to port models to ggml that aren't yet supported.

Andriy Levitskyy 2024-08-07T01:35:46.110479Z

I am looking at ggml repo, and I only see inference examples, I will need to dig deeper later to see how it can be used for training, how good is the auto-differentiation capabilities etc

phronmophobic 2024-08-07T01:36:46.085369Z

Cool, it would be cool to hear what you think.

👍 1
Andriy Levitskyy 2024-08-07T01:37:16.505329Z

I think the devil is usually in optimizations of calculations, i.e. implementing a transformer is relatively easy, but implementing a transformer that can handle big data fast requires a lot of man-hours to build

Andriy Levitskyy 2024-08-07T02:37:18.079319Z

@smith.adriane https://petewarden.com/2023/10/15/the-unstoppable-rise-of-disposable-ml-frameworks/ this article may be helpful about the differences between Pytorch/TenorFlow and llama.cpp/ggml

🙏 2