Erland / Llama-3.2-1B-JAX

huggingface.co
Total runs: 15
24-hour runs: 0
7-day runs: -7
30-day runs: -58
Model's Last Updated: December 27 2024
text-generation

Introduction of Llama-3.2-1B-JAX

Model Details of Llama-3.2-1B-JAX

meta-llama/Llama-3.2-1B - JAX/Flax

This repository contains the JAX/Flax version of the meta-llama/Llama-3.2-1B model, originally a PyTorch model from {original_model_org}. This conversion enables efficient inference and training on TPUs and GPUs using the JAX/Flax framework.

Model Description

meta-llama/Llama-3.2-1B is a transformer-based language model developed by meta-llama.

Conversion Details

This model was converted from the original PyTorch implementation to JAX/Flax. The conversion process involved the following steps:

  1. Loading the PyTorch model and configuration: The pretrained PyTorch model and its configuration were loaded using the Hugging Face Transformers library.
  2. Creating an equivalent Flax model architecture: A Flax model with the same architecture as the original PyTorch model was created.
  3. Converting the PyTorch weights to Flax format: The weights from the PyTorch model were converted to the Flax format using the convert_pytorch_state_dict_to_flax utility function provided by Hugging Face.
  4. Verifying the converted weights: The converted Flax weights were compared against the original PyTorch weights to ensure that the conversion process was performed accurately.
Important Note about max_position_embeddings

During the conversion process, it was necessary to modify the max_position_embeddings parameter in the model's configuration. The original value of {original_max_pos_embed} led to out-of-memory (OOM) errors on the hardware used for conversion. To resolve this, max_position_embeddings was adjusted to {new_max_pos_embed}.

Implications of this change:

  • The model may not be able to handle sequences longer than 32768 tokens without truncation or other modifications.
  • If you fine-tune this model, keep in mind the revised max_position_embeddings when preparing your training data.
Weight Comparison

The following table summarizes the comparison between the weights of the original PyTorch model and the converted JAX/Flax model. This detailed verification confirms that the conversion was accurate and that both models should produce (approximately) the same outputs given the same inputs.

Layer PyTorch Shape Flax Shape Allclose Max Diff Mean Diff Std Diff
model.embed_tokens.weight (128256, 2048) (128256, 2048) True 0 0 0
model.layers.0.self_attn.q_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.0.self_attn.k_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.0.self_attn.v_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.0.self_attn.o_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.0.mlp.gate_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.0.mlp.up_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.0.mlp.down_proj.weight (8192, 2048) (8192, 2048) True 0 0 0
model.layers.0.input_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.0.post_attention_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.1.self_attn.q_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.1.self_attn.k_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.1.self_attn.v_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.1.self_attn.o_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.1.mlp.gate_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.1.mlp.up_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.1.mlp.down_proj.weight (8192, 2048) (8192, 2048) True 0 0 0
model.layers.1.input_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.1.post_attention_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.2.self_attn.q_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.2.self_attn.k_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.2.self_attn.v_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.2.self_attn.o_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.2.mlp.gate_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.2.mlp.up_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.2.mlp.down_proj.weight (8192, 2048) (8192, 2048) True 0 0 0
model.layers.2.input_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.2.post_attention_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.3.self_attn.q_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.3.self_attn.k_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.3.self_attn.v_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.3.self_attn.o_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.3.mlp.gate_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.3.mlp.up_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.3.mlp.down_proj.weight (8192, 2048) (8192, 2048) True 0 0 0
model.layers.3.input_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.3.post_attention_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.4.self_attn.q_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.4.self_attn.k_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.4.self_attn.v_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.4.self_attn.o_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.4.mlp.gate_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.4.mlp.up_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.4.mlp.down_proj.weight (8192, 2048) (8192, 2048) True 0 0 0
model.layers.4.input_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.4.post_attention_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.5.self_attn.q_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.5.self_attn.k_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.5.self_attn.v_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.5.self_attn.o_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.5.mlp.gate_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.5.mlp.up_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.5.mlp.down_proj.weight (8192, 2048) (8192, 2048) True 0 0 0
model.layers.5.input_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.5.post_attention_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.6.self_attn.q_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.6.self_attn.k_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.6.self_attn.v_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.6.self_attn.o_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.6.mlp.gate_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.6.mlp.up_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.6.mlp.down_proj.weight (8192, 2048) (8192, 2048) True 0 0 0
model.layers.6.input_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.6.post_attention_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.7.self_attn.q_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.7.self_attn.k_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.7.self_attn.v_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.7.self_attn.o_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.7.mlp.gate_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.7.mlp.up_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.7.mlp.down_proj.weight (8192, 2048) (8192, 2048) True 0 0 0
model.layers.7.input_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.7.post_attention_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.8.self_attn.q_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.8.self_attn.k_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.8.self_attn.v_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.8.self_attn.o_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.8.mlp.gate_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.8.mlp.up_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.8.mlp.down_proj.weight (8192, 2048) (8192, 2048) True 0 0 0
model.layers.8.input_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.8.post_attention_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.9.self_attn.q_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.9.self_attn.k_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.9.self_attn.v_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.9.self_attn.o_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.9.mlp.gate_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.9.mlp.up_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.9.mlp.down_proj.weight (8192, 2048) (8192, 2048) True 0 0 0
model.layers.9.input_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.9.post_attention_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.10.self_attn.q_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.10.self_attn.k_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.10.self_attn.v_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.10.self_attn.o_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.10.mlp.gate_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.10.mlp.up_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.10.mlp.down_proj.weight (8192, 2048) (8192, 2048) True 0 0 0
model.layers.10.input_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.10.post_attention_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.11.self_attn.q_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.11.self_attn.k_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.11.self_attn.v_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.11.self_attn.o_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.11.mlp.gate_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.11.mlp.up_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.11.mlp.down_proj.weight (8192, 2048) (8192, 2048) True 0 0 0
model.layers.11.input_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.11.post_attention_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.12.self_attn.q_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.12.self_attn.k_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.12.self_attn.v_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.12.self_attn.o_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.12.mlp.gate_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.12.mlp.up_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.12.mlp.down_proj.weight (8192, 2048) (8192, 2048) True 0 0 0
model.layers.12.input_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.12.post_attention_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.13.self_attn.q_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.13.self_attn.k_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.13.self_attn.v_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.13.self_attn.o_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.13.mlp.gate_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.13.mlp.up_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.13.mlp.down_proj.weight (8192, 2048) (8192, 2048) True 0 0 0
model.layers.13.input_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.13.post_attention_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.14.self_attn.q_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.14.self_attn.k_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.14.self_attn.v_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.14.self_attn.o_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.14.mlp.gate_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.14.mlp.up_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.14.mlp.down_proj.weight (8192, 2048) (8192, 2048) True 0 0 0
model.layers.14.input_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.14.post_attention_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.15.self_attn.q_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.15.self_attn.k_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.15.self_attn.v_proj.weight (2048, 512) (2048, 512) True 0 0 0
model.layers.15.self_attn.o_proj.weight (2048, 2048) (2048, 2048) True 0 0 0
model.layers.15.mlp.gate_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.15.mlp.up_proj.weight (2048, 8192) (2048, 8192) True 0 0 0
model.layers.15.mlp.down_proj.weight (8192, 2048) (8192, 2048) True 0 0 0
model.layers.15.input_layernorm.weight (2048,) (2048,) True 0 0 0
model.layers.15.post_attention_layernorm.weight (2048,) (2048,) True 0 0 0
model.norm.weight (2048,) (2048,) True 0 0 0
lm_head.weight (2048, 128256) (2048, 128256) True 0 0 0

Note:

  • Allclose indicates whether the weights are approximately equal within the specified relative ( rtol=1e-5 ) and absolute ( atol=1e-3 ) tolerances using jnp.allclose() .
  • Max Diff , Mean Diff , and Std Diff provide further details on the differences between the weights if Allclose is False , which might be expected for some layers due to numerical precision differences between frameworks.
Hardware Used for Conversion

The conversion process was performed on the following hardware configuration:

  • CPU:
  • RAM: 251.67 GB
  • OS: Linux-5.15.0-107-generic-x86_64-with-glibc2.36
  • JAX version: 0.3.22
  • Flax version: 0.6.2
  • Transformers version: 4.47.0
  • GPU: NVIDIA A100-SXM4-40GB

This conversion took approximately 130.21 seconds to complete.

Usage

Here's how you can use the converted model in JAX/Flax for text generation:

import jax
import jax.numpy as jnp
from transformers import FlaxAutoModelForCausalLM, AutoTokenizer

model_name = "Erland/Llama-3.2-1B-JAX"  # Replace with your repository name
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = FlaxAutoModelForCausalLM.from_pretrained(model_name, from_pt=False) # from_pt should be False since it's already flax

# Example prompt
prompt = "The quick brown fox"

# Tokenize the prompt
tokenized_prompt = tokenizer(prompt, return_tensors="np")

# Generate text
output_ids = model.generate(tokenized_prompt.input_ids, max_length=50)

# Decode the generated text
generated_text = tokenizer.decode(output_ids[0], skip_special_tokens=True)
Limitations

Sequence Length: As mentioned earlier, the max_position_embeddings has been modified to 32768. Be mindful of this limitation when working with long sequences.

Numerical Precision: Minor differences in outputs compared to the original PyTorch model might be observed due to numerical precision variations between PyTorch and JAX/Flax, particularly on different hardware.

Acknowledgements

We thank the original authors of meta-llama/Llama-3.2-1B at meta-llama for their groundbreaking work in developing this powerful language model.

We acknowledge the Hugging Face Transformers library for providing the essential tools and infrastructure that made this conversion possible.

Thanks to the JAX and Flax teams for developing such performant and flexible frameworks for numerical computation and deep learning.

License

This JAX/Flax model is released under the original model license.

Runs of Erland Llama-3.2-1B-JAX on huggingface.co

15
Total runs
0
24-hour runs
-2
3-day runs
-7
7-day runs
-58
30-day runs

More Information About Llama-3.2-1B-JAX huggingface.co Model

Llama-3.2-1B-JAX huggingface.co

Llama-3.2-1B-JAX huggingface.co is an AI model on huggingface.co that provides Llama-3.2-1B-JAX's model effect (), which can be used instantly with this Erland Llama-3.2-1B-JAX model. huggingface.co supports a free trial of the Llama-3.2-1B-JAX model, and also provides paid use of the Llama-3.2-1B-JAX. Support call Llama-3.2-1B-JAX model through api, including Node.js, Python, http.

Llama-3.2-1B-JAX huggingface.co Url

https://huggingface.co/Erland/Llama-3.2-1B-JAX

Erland Llama-3.2-1B-JAX online free

Llama-3.2-1B-JAX huggingface.co is an online trial and call api platform, which integrates Llama-3.2-1B-JAX's modeling effects, including api services, and provides a free online trial of Llama-3.2-1B-JAX, you can try Llama-3.2-1B-JAX online for free by clicking the link below.

Erland Llama-3.2-1B-JAX online free url in huggingface.co:

https://huggingface.co/Erland/Llama-3.2-1B-JAX

Llama-3.2-1B-JAX install

Llama-3.2-1B-JAX is an open source model from GitHub that offers a free installation service, and any user can find Llama-3.2-1B-JAX on GitHub to install. At the same time, huggingface.co provides the effect of Llama-3.2-1B-JAX install, users can directly use Llama-3.2-1B-JAX installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

Llama-3.2-1B-JAX install url in huggingface.co:

https://huggingface.co/Erland/Llama-3.2-1B-JAX

Url of Llama-3.2-1B-JAX

Llama-3.2-1B-JAX huggingface.co Url

Provider of Llama-3.2-1B-JAX huggingface.co

Erland
ORGANIZATIONS

Other API from Erland

huggingface.co

Total runs: 16
Run Growth: 2
Growth Rate: 9.52%
Updated:January 11 2025
huggingface.co

Total runs: 16
Run Growth: 12
Growth Rate: 75.00%
Updated:April 12 2025
huggingface.co

Total runs: 14
Run Growth: -6
Growth Rate: -37.50%
Updated:November 12 2024
huggingface.co

Total runs: 11
Run Growth: 0
Growth Rate: 0.00%
Updated:April 19 2026
huggingface.co

Total runs: 10
Run Growth: 2
Growth Rate: 16.67%
Updated:October 31 2024
huggingface.co

Total runs: 10
Run Growth: -2
Growth Rate: -15.38%
Updated:December 27 2024
huggingface.co

Total runs: 10
Run Growth: 3
Growth Rate: 23.08%
Updated:October 29 2024
huggingface.co

Total runs: 8
Run Growth: 4
Growth Rate: 50.00%
Updated:June 14 2025
huggingface.co

Total runs: 8
Run Growth: 2
Growth Rate: 25.00%
Updated:January 17 2026