Downloads · 30 days
41
8% of all-time downloads
BarraHome/llama3_2-1B-deepseek
llama3_2-1B-deepseek is a text generation model from BarraHome. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as mit.
This directory contains a LLaMA 3.2-1B model that has been converted from the original Grouped Query Attention (GQA) architecture to Multi-head Latent Attention (MLA) using the TransMLA: Multi-head Latent Attention Is…
Downloads · 30 days
41
8% of all-time downloads
All-time downloads
494
Public
Parameters
1.3B
2.7 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors2.6 GB · 99%
From the Hugging Face model README
This directory contains a LLaMA 3.2-1B model that has been converted from the original Grouped Query Attention (GQA) architecture to Multi-head Latent Attention (MLA) using the TransMLA: Multi-head Latent Attention Is All You Need paper. The converted model is fully compatible with DeepSeek's MLA implementation and provides significant improvements in memory efficiency and inference speed.
Source Model: meta-llama/Llama-3.2-1B
Target Architecture: DeepSeek-MLA compatible
Conversion Parameters:
freqfold: 4kv-lora-rank: 512qk-mqa-dim: 64collapse: auto (computed as head_dim // qk_mqa_dim)| Metric | Value |
|---|---|
| Original Model PPL | 9.7531 |
| Partial RoPE PPL | 16.3391 |
| Final MLA PPL | 16.1404 |
| Memory Reduction | ~50% KV cache compression |
| Inference Speedup | 2-3x faster (hardware dependent) |
PPL (Perplexity) measured on WikiText-2 dataset
The conversion process transforms the model through several key steps:
The converted model includes:
config.json - Model configuration with MLA parameterspytorch_model.bin - Converted model weightstokenizer.json - Original LLaMA tokenizertokenizer_config.json - Tokenizer configurationspecial_tokens_map.json - Special token mappingsmodeling_llamamla.py - Custom modeling code for MLAconfiguration_llamamla.py - Configuration classmla.py - Core MLA implementationimport torch
from transformers import AutoModelForCausalLM, AutoTokenizer
# Load the converted model
model = AutoModelForCausalLM.from_pretrained(
"BarraHome/llama3_2-1B-deepseek",
trust_remote_code=True,
torch_dtype=torch.bfloat16
)
tokenizer = AutoTokenizer.from_pretrained("BarraHome/llama3_2-1B-deepseek")
# Generate text
inputs = tokenizer("The future of AI is", return_tensors="pt")
outputs = model.generate(**inputs, max_length=100, do_sample=True, temperature=0.7)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
from vllm import LLM, SamplingParams
# Initialize vLLM engine with MLA model
llm = LLM(
model="BarraHome/llama3_2-1B-deepseek",
trust_remote_code=True,
dtype="bfloat16"
)
sampling_params = SamplingParams(temperature=0.7, max_tokens=100)
outputs = llm.generate(["The future of AI is"], sampling_params)
# Use the provided DeepSpeed configuration
deepspeed train.py \
--model_name_or_path BarraHome/llama3_2-1B-deepseek \
--deepspeed configs/ds_config_zero3.json \
--trust_remote_code
Optional:
This model implements DeepSeek's Multi-head Latent Attention mechanism, which:
The conversion preserves the original model's capabilities while enabling significant performance improvements on modern hardware.
This converted model inherits the license from the original LLaMA 3.2-1B model. Please refer to Meta's Llama 3.2 Community License Agreement for usage terms and conditions.