georgeguimaraes

georgeguimaraes

Alike :wavy_dash: - Semantic similarity testing for Elixir

Hey everyone! I’m excited to share Alike, a library for testing semantic similarity in Elixir.

The Problem

Testing LLM outputs, chatbots, or NLP pipelines is tricky. String matching is too brittle:

  # This fails even though the meaning is the same
  assert response == "Hi there! How can I help you?"
  # actual: "Hello! How may I assist you today?"

The Solution

Alike introduces the wave operator <~> for semantic similarity assertions:

  import Alike.WaveOperator

  # These pass - same meaning, different words
  assert "The cat is sleeping" <~> "A feline is taking a nap"
  assert "Hello! How can I help?" <~> "Hi there! What can I do for you?"

  # This fails - contradiction detected
  refute "The sky is blue" <~> "The sky is red"

The magic of ML in your test suite

What I find incredible about building this in Elixir is that we can run actual ML models inside our test suite, as naturally as any other code.

Thanks to Bumblebee and Nx, the models run as supervised Nx.Serving processes. They’re just GenServers! This means:

  • Parallel tests just work - With async: true, multiple test processes call the model concurrently, and Nx.Serving batches requests automatically
  • No external services - No Docker containers, no Python sidecars, no API calls. The models live in your BEAM instance
  • One model, many callers - Unlike Python where parallel test workers each need their own model copy (or a separate inference server), Elixir shares one model across all test processes efficiently

It’s the kind of thing that feels like it shouldn’t be this easy, but the BEAM + Nx ecosystem makes it natural.

How it works

Alike runs two models locally via Bumblebee + Nx:

  1. Sentence embeddings (all-MiniLM-L12-v2) for similarity
  2. NLI model (nli-distilroberta-base) for contradiction detection

No API keys needed - everything runs on your machine.

Installation

  def deps do
    [{:alike, "~> 0.2.0", only: :test}]
  end

Links

https://github.com/georgeguimaraes/alike

Would love to hear your feedback!

Showing Posts 1 to 2

spurgus

spurgus

That’s interesting! I have a test for image recognition where I ask the model, “What insect is this? One word only, downcased”, and I had to assert like this:

assert String.contains?(response.text, "ant") || String.contains?(response.text, "spider")

Maybe I can use Alike here :smiley:

georgeguimaraes

georgeguimaraes OP

That would be a cool use case. Let me know how it goes. The model used in Alike should be able to identify insect words

— All posts loaded —

Where Next? Top

Trending in Announcing Top

wojtekmach
Hey everyone! Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
handnot2
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application. This library uses Erlang esaml to provide plug enabl...
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
fuelen
Hi all! I want to present a small library which provides a mix task for generating an Entity-Relationship Diagram for Ecto schemas. You...
New
anuaralfetahe
Hello Published a new library - ProcessHub! ProcessHub is a library designed to manage process distribution within the Elixir cluster. ...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
AstonJ
This showed up on my feed.. anyone heard of it? Just hype? Ox Alpha is a reasoning model designed for coding, sustained ag...
New
sergio
It’s not that it’s vocabulary is too advanced. It’s something worse. I get lost trying to follow even a paragraph written by Claude. It’...
New
sorenone
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
akoutmos
@hugobarauna, Dr. Dimitrios Koutmos (my brother) and I (Alex Koutmos) have been hard at work on writing a book on how you can use Elixir ...
New
pferriby
Introductory paragraph I’ll be looking for a keen junior or someone that has a couple of years experience in the real world (so you’ve be...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews