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

type1fool
WebAuthnLiveComponent WebAuthnComponents See this post about renaming the package. Passwordless authentication for Phoenix LiveView app...
New
GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
woylie
I released Doggo, a collection of unstyled Phoenix components. https://github.com/woylie/doggo Features Unstyled Phoenix components....
New
ahamez
Hi everyone, I’ve been working on this protobuf library for 3 years. We use it in the company I work for, EasyMile, to communicate with ...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
kip
I’ll shortly be launching Text, a nascent text analysis library. Current functionality In this early version (not ready for prime time) ...
New
kip
Following on from my CLDR lbraries I started work on Unicode transforms. But like everything related to CLDR there is a lot of yak-shavin...
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
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews