dwyl / dwyl/image-classifier

Quantization?

Open
#146 4 comments 3 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
35
Forks
6
PR merge metrics
No merged PRs in 30d

Description

Does someone know if this can be used for our models. It seems that the coefficients can be turned into integers. Can we do it once, save it and use this new model into the codebase, potentially significantly lowering the size, memory impact, and thus loading speed?

[Screenshot 2024-09-06 at 11 10 05](https://dockyard.com/blog/2024/08/20/where-are-nx-axon-bumblebee-headed)

Extract from the blog:

```elixir
get_quantized_phi = fn ->
{:ok, %{params: model_state, model: model} = model_info} =
Bumblebee.load_model({:hf, "microsoft/Phi-3-mini-4k-instruct"})

IO.inspect(model_state, label: "Unquantized")
{quantized_model, quantized_model_state} = Axon.Quantization.quantize(model, model_state)
IO.inspect(quantized_model_state, label: "Quantized")
%{model_info | model: quantized_model, params: quantized_model_state}
end

quantized_model = get_quantized_phi.()

:ok
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.