Better way to run local embeddings with Apple Metal than Ollama?

I would want to create local phoenix app to allow semantic search for local files.

In order to do this I need to calculate embeddings for my files and I’m wondering if we have good elixir integration for Apple Metal hardware acceleration to calculate the embeddings with nomic-embed-text or should I just use Ollama instead?

How is the MLX support in the current tooling?

1 Like

There’s emlx, a Metal-powered backend for Nx:

Haven’t tried it out lately, though

1 Like

EMLX with Nx 0.11 should work great for most things.

I have work in progress for even faster execution times, bringing back the original attempts at a compiled mode.
It didn’t work back then because of a bug in Nx that has been solved in the latest release.

Also, with Nx.runtime_call you can interleave external non-Nx code into your Nx computations, so you can do a best-of-both-worlds approach

5 Likes

The mixing of nx and non nx sound like pure alchemy for me :grinning_face_with_smiling_eyes:.

Links to examples would be amazing but I will anyway try it out :+1:

There are a few tests where you can get familiarized with the interface. The function docs should be enough, though.