Skip to content

Instantly share code, notes, and snippets.

View toranb's full-sized avatar

Toran Billups toranb

View GitHub Profile
@toranb
toranb / ibf.py
Created July 19, 2025 12:20 — forked from hundredwatt/ibf.py
import cityhash
class Cell:
"""A cell in the Invertible Bloom Filter."""
def __init__(self, index, ibf):
self.index = index
self.item_sum = 0 # Now just a single integer instead of array
self.hash_sum = 0 # Store hash sum separately for verification
self.count = 0
self.ibf = ibf
@toranb
toranb / llama_three.ex
Created April 20, 2024 15:17
bumblebee hack to run llama 3
def llama() do
llama = {:hf, "meta-llama/Meta-Llama-3-8B-Instruct", auth_token: "abc123"}
{:ok, model_info} = Bumblebee.load_model(llama, type: :bf16, backend: {EXLA.Backend, client: :cuda})
{:ok, tokenizer} = Bumblebee.load_tokenizer(llama)
{:ok, generation_config} = Bumblebee.load_generation_config(llama)
tokenizer =
tokenizer
|> Map.put(:special_tokens, %{
pad: "<|eot_id|>",
@toranb
toranb / encoder.ex
Created May 10, 2025 15:35
updated cross encoder for nx 0.9x
defmodule Example.Encoder do
@moduledoc false
alias Bumblebee.Shared
def cross_encoder(model_info, tokenizer, opts \\ []) do
%{model: model, params: params, spec: _spec} = model_info
opts =
Keyword.validate!(opts, [
@toranb
toranb / turbo.elixir
Created November 9, 2024 19:11
elixir and bumblebee with turbo v3 large
Mix.install([
{:axon, "~> 0.7"},
{:bumblebee, "~> 0.6"},
{:exla, "~> 0.9"},
{:nx, "~> 0.9"},
{:mp3_duration, "~> 0.1.0"},
{:plug_cowboy, "~> 2.6"},
{:jason, "~> 1.4"},
{:phoenix, "~> 1.7.14"},
{:phoenix_html, "~> 4.1"},
@toranb
toranb / Nx_Decision_Trees.livemd
Created October 1, 2024 15:41 — forked from acalejos/Nx_Decision_Trees.livemd
Serving Spam Detection With XGBoost and Elixir

Nx-Powered Decision Trees

Mix.install(
  [
    {:exgboost, "~> 0.3.1", override: true},
    {:nx, "~> 0.6"},
    {:exla, "~> 0.5"},
@toranb
toranb / alternate-route.js
Created April 4, 2016 00:13
classic ember route with the redux service to dispatch with
import Ember from 'ember';
import ajax from 'example/utilities/ajax';
var UsersRoute = Ember.Route.extend({
redux: Ember.inject.service(),
model() {
var redux = this.get('redux');
return ajax('/api/users', 'GET').then(response => redux.dispatch({type: 'DESERIALIZE_USERS', response: response}));
}
});
@toranb
toranb / nx_fizzbuzz.ex
Last active April 16, 2024 19:29
fizzbuzz with Nx
defmodule Mlearning do
@moduledoc false
def mods(x) do
[rem(x, 3), rem(x, 5)]
end
def fizzbuzz(n) do
cond do
rem(n, 15) == 0 -> [0, 0, 1, 0]
@toranb
toranb / example.exs
Created November 17, 2023 18:07
Single file elixir web app with self hosted Zephyr LLM
Mix.install([
{:bumblebee, git: "https://github.com/toranb/bumblebee", branch: "main"},
{:nx, "~> 0.6.2", override: true},
{:exla, "~> 0.6.1"},
{:plug_cowboy, "~> 2.6"},
{:jason, "~> 1.4"},
{:phoenix, "~> 1.7"},
{:phoenix_live_view, "~> 0.20.0"}
])
@toranb
toranb / gemma.exs
Last active March 25, 2024 13:16
Single file elixir app to chat with Gemma 7B using the RTX 4090
Mix.install([
{:bumblebee, git: "https://github.com/toranb/bumblebee", branch: "main"},
{:nx, "~> 0.7", override: true},
{:exla, ">= 0.0.0"},
{:plug_cowboy, "~> 2.6"},
{:jason, "~> 1.4"},
{:bandit, "~> 1.2"},
{:phoenix, "~> 1.7"},
{:phoenix_live_view, "~> 0.20.0"}
])
@toranb
toranb / fizzbuzz.ex
Last active January 30, 2024 07:40
fizzbuzz with Axon (collaboration with Ian Warshak)
defmodule Mlearning do
@moduledoc false
def mods(x) do
[rem(x, 3), rem(x, 5)]
end
def fizzbuzz(n) do
cond do
rem(n, 15) == 0 -> [0, 0, 1, 0]