Mix.install(
[
{:exgboost, "~> 0.3.1", override: true},
{:nx, "~> 0.6"},
{:exla, "~> 0.5"},
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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|>", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"} | |
| ]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"} | |
| ]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ARG ELIXIR_VERSION=1.15.6 | |
| ARG OTP_VERSION=26.1.2 | |
| ARG DEBIAN_VERSION=buster-20230612-slim | |
| ARG BUILDER_IMAGE="hexpm/elixir:${ELIXIR_VERSION}-erlang-${OTP_VERSION}-debian-${DEBIAN_VERSION}" | |
| ARG RUNNER_IMAGE="debian:${DEBIAN_VERSION}" | |
| FROM ${BUILDER_IMAGE} as builder | |
| # install build dependencies |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def serving() do | |
| mistral = {:hf, "HuggingFaceH4/zephyr-7b-alpha"} | |
| {:ok, spec} = Bumblebee.load_spec(mistral, module: Bumblebee.Text.Mistral, architecture: :for_causal_language_modeling) | |
| {:ok, model_info} = Bumblebee.load_model(mistral, spec: spec, backend: {EXLA.Backend, client: :host}) | |
| {:ok, tokenizer} = Bumblebee.load_tokenizer(mistral, module: Bumblebee.Text.LlamaTokenizer) | |
| {:ok, generation_config} = Bumblebee.load_generation_config(mistral, spec_module: Bumblebee.Text.Mistral) | |
| generation_config = Bumblebee.configure(generation_config, max_new_tokens: 500) | |
| Bumblebee.Text.generation(model_info, tokenizer, generation_config, defn_options: [compiler: EXLA]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| defmodule Training.Example do | |
| def train() do | |
| Nx.default_backend(EXLA.Backend) | |
| {:ok, spec} = | |
| Bumblebee.load_spec({:hf, "prajjwal1/bert-medium"}, | |
| module: Bumblebee.Text.Bert, | |
| architecture: :for_sequence_classification | |
| ) |
NewerOlder