georgeguimaraes

georgeguimaraes

Arcana - Embeddable RAG library for Elixir/Phoenix

I’m excited to share Arcana, a RAG (Retrieval Augmented Generation) library I’ve been building for Elixir/Phoenix applications.

What is it?

Arcana lets you add vector search, document retrieval, and AI-powered Q&A to any Phoenix app. It’s designed to be embeddable - it uses your existing Ecto Repo and PostgreSQL with pgvector, no separate vector database needed.

Key Features

Simple API for basic RAG:

  {:ok, doc} = Arcana.ingest("Your content", repo: MyApp.Repo)
  results = Arcana.search("query", repo: MyApp.Repo, mode: :hybrid)
  {:ok, answer} = Arcana.ask("What is Elixir?", repo: MyApp.Repo, llm: "openai:gpt-4o")

Agentic RAG Pipeline for complex questions:

  ctx =
    Agent.new("Compare Elixir and Erlang")
    |> Agent.select(collections: ["elixir-docs", "erlang-docs"])
    |> Agent.expand()
    |> Agent.decompose()
    |> Agent.search()
    |> Agent.rerank(threshold: 7)
    |> Agent.answer(self_correct: true)

The pipeline includes query rewriting, collection routing, query expansion, question decomposition, re-ranking, and self-correcting answers (reduces hallucinations by verifying answers are grounded in context).

Embeddings with Nx/Bumblebee:

  • Local embeddings with bge-small-en-v1.5 - no API keys needed
  • Or use OpenAI embeddings
  • Or bring your own via the Arcana.Embedder behaviour

Pluggable Everything:

Every pipeline step has a behaviour you can implement:

defmodule MyApp.CrossEncoderReranker do
    @behaviour Arcana.Agent.Reranker

    @impl true
    def rerank(question, chunks, opts) do
      # Your cross-encoder logic
      {:ok, scored_chunks}
    end
  end

Other highlights:

  • Hybrid search (vector + fulltext with Reciprocal Rank Fusion)
  • In-memory HNSWLib backend for testing or smaller apps
  • Built-in telemetry for all operations
  • Evaluation metrics (MRR, Recall@k, Precision@k)
  • Optional LiveView dashboard
  • File ingestion (text, markdown, PDF)

Links

GitHub: GitHub - georgeguimaraes/arcana: Embeddable RAG library for Elixir/Phoenix with agentic pipelines and dashboard · GitHub
Hex: arcana | Hex
Demo app with Doctor Who corpus: GitHub - georgeguimaraes/arcana-adept: Example Phoenix app demonstrating Arcana RAG toolkit · GitHub

Would love feedback from the community!

https://github.com/georgeguimaraes/arcana

Most Liked

georgeguimaraes

georgeguimaraes

Dashboard example here:

georgeguimaraes

georgeguimaraes

Check GitHub - georgeguimaraes/arcana-adept: Example Phoenix app demonstrating Arcana RAG toolkit · GitHub

It’s not using PDF, but JSON files, but it’d give you a good overview of the whole workflow.

Also, Arcana has pdf “scraping” capabilities using https://poppler.freedesktop.org/. Not fancy, and not extremely exceptional. I want to experiment with GitHub - xberg-io/xberg: A polyglot document intelligence framework with a Rust core. Extract text, metadata, images, and structured information from PDFs, Office documents, images, and 97+ formats. Available for Rust, Python, Ruby, Java, Go, PHP, Elixir, C#, R, C, TypeScript (Node/Bun/Wasm/Deno)- or use via CLI, REST API, or MCP server. · GitHub to know how we can do better.

But remember, you can define your own PDF Parser and give it to Arcana.

Where Next?

Popular in Announcing Top

zorbash
I created Kitto a framework for dashboards inspired by Dashing. The distributed characteristics of Elixir and the low memory footprint...
New
mischov
import Meeseeks.CSS html = HTTPoison.get!("https://news.ycombinator.com/").body for story <- Meeseeks.all(html, css("tr.athing")) do...
New
mspanc
I am pleased to announce an initial release of the Membrane Framework - an Elixir-based framework with special focus on processing multim...
New
mbuhot
Leverage Open Api 3.0 (Swagger) to document, test, validate and explore your Plug and Phoenix APIs. Generate and serve a JSON Open API ...
New
benlime
LiveMotion enables high performance animations declared on the server and run on the client. As a follow up to my previous thread A libr...
New
kip
Image is an image processing library for Elixir. It is based upon the fabulous vix library that provides a libvips wrapper for Elixir. I...
622 19460 194
New
zachdaniel
Ash Framework What is Ash? Ash Framework is a declarative, resource-oriented application development framework for Elixir. A resource can...
New

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36654 110
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New

We're in Beta

About us Mission Statement