Lately, we’ve been exploring several Ruby gems and wanted to share some of the most interesting ones we found.
Machine Learning in Ruby
First, we looked into how the Ruby ecosystem handles machine learning and whether it could be a viable alternative to Python for this kind of work.
At the end of the day, Python itself doesn’t do the heavy lifting, most of its ML libraries just call optimized C code under the hood. Ruby can do the same, so we wanted to see how feasible it would be to use Ruby for ML, especially since, well, we love Ruby more.
We came across this repository: arbox/machine-learning-with-ruby
It’s a great collection of Ruby libraries and tools for machine learning. However, most of them haven’t been updated recently and don’t seem to have much usage today.
The gem that caught our attention the most was neighbor. It provides an easy way to implement nearest neighbor search (similarity search) using embeddings, and it integrates nicely with pgvector.
This is particularly useful when working with models that include descriptive data, for example, finding the most similar companies based on text descriptions. Many LLMs can generate embeddings for this kind of data, and the AI frameworks we’ll mention next can integrate with it seamlessly.
Even though Ruby has some solid alternatives that mirror what Python libraries offer, the limited maintenance and smaller community make it hard to dethrone Python as the main ML language. Still, it’s clear that Ruby can do it.
AI Frameworks for Ruby on Rails
Next, we explored how AI is being integrated into everyday Rails applications.
In the past few months, several frameworks have emerged to make it easier to work with large language models (LLMs). They unify APIs from different providers and simplify the process of creating flows, agents, tools, structured outputs, and more.
Here are the main ones we found:
ActiveAgent
A Rails-friendly way to build AI agents following the MVC pattern, where the agent acts as a controller, and its tools function as actions.
It’s well-integrated with Rails (no need to reinvent the wheel), includes testing utilities and streaming support, but it has a learning curve and is less flexible than some of the others.
LangChain.rb
The Ruby on Rails version of the well-known Python library. It helps build more complex AI pipelines, embeddings, RAG, tools, memory, and so on.
It simplifies creating embeddings and chat/prompt completions, and it can be used for multi-agent orchestration or large-context workflows. However, it’s not the easiest to learn and lacks extensive documentation.
Raif
Raif stores all LLM calls as Raif::ModelCompletion records and lets you mount a simple web interface to view the logs.
It introduces concepts like Tasks (asking a model to perform a specific action, e.g. summarizing documentation), Conversations, and Agents (ReAct-style loops with tool calls).
While the syntax isn’t the simplest and it’s not the most beginner-friendly, it’s well-designed and even helps with testing.
RubyLLM
Finally, the one we found most interesting and easiest to use, RubyLLM.
It’s also the most widely adopted globally (it’s been “#1 repository of the day” on GitHub several times).
RubyLLM lets you define chat models, messages, and tool calls easily, often with a single command. While it’s slightly harder to build very complex agents, it gives you more flexibility to design your own structures.
It also integrates neatly with ActiveStorage, making it simple to send files to LLMs.
Of all the frameworks we tried, RubyLLM stood out as the most intuitive and well-supported, with an active community behind it, always a big plus.
Final Thoughts
Rails and AI are a surprisingly good match, especially with frameworks that keep the simplicity and “magic” that make Rails special. There’s still a lot to explore, but the future looks promising.
If you’ve tried (or plan to try) any of these tools, I’d love to hear your thoughts!

