OpenMOSS-Team / Llama-2-7B-MLA-d_kv_64

huggingface.co
Total runs: 14
24-hour runs: 0
7-day runs: 7
30-day runs: -13
Model's Last Updated: March 13 2025
text-generation

Introduction of Llama-2-7B-MLA-d_kv_64

Model Details of Llama-2-7B-MLA-d_kv_64

Research Paper "Towards Economical Inference: Enabling DeepSeek's Multi-Head Latent Attention in Any Transformer-based LLMs"

Inference
wget https://raw.githubusercontent.com/JT-Ushio/MHA2MLA/refs/heads/main/src/mha2mla/monkey_patch.py
  • Step 2(Option): For MHA2MLA models using Partial-RoPE 2-nrom method, Download the qk_2-norm file . Take qk_tensor_7B.pth as an example:
wget https://github.com/JT-Ushio/MHA2MLA/raw/refs/heads/main/utils/qk_tensor_7B.pth
  • Step 3: Download the MHA2MLA models and run inference. Take fnlp/Llama-2-7B-MLA-d_kv_64 as an example:
import torch
from transformers import AutoConfig, AutoTokenizer, LlamaForCausalLM
from monkey_patch import infer_monkey_patch

model_name = "fnlp/Llama-2-7B-MLA-d_kv_64"

# Monkey Patch: MHA -> MLA
config = AutoConfig.from_pretrained(model_name)
if "RoPE" in config:
    config.RoPE["qk_tensor_path"] = "qk_tensor_7B.pth"  # Configuration for Specific Models
    infer_monkey_patch(config.RoPE)

tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
model = LlamaForCausalLM.from_pretrained(model_name, config=config, torch_dtype=torch.bfloat16).cuda()

# Generate
text = "Which American-born Sinclair won the Nobel Prize for Literature in 1930?"
inputs = tokenizer(text, return_tensors="pt").to(model.device)
generation_kwargs = {"do_sample": False, "use_cache": True, "max_new_tokens": 128}
output = model.generate(**inputs, **generation_kwargs)

print(tokenizer.decode(output[0], skip_special_tokens=True))
# - Sinclair Lewis
Citation
@misc{ji2025economicalinferenceenablingdeepseeks,
      title={Towards Economical Inference: Enabling DeepSeek's Multi-Head Latent Attention in Any Transformer-based LLMs}, 
      author={Tao Ji and Bin Guo and Yuanbin Wu and Qipeng Guo and Lixing Shen and Zhan Chen and Xipeng Qiu and Qi Zhang and Tao Gui},
      year={2025},
      eprint={2502.14837},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2502.14837}, 
}

Runs of OpenMOSS-Team Llama-2-7B-MLA-d_kv_64 on huggingface.co

14
Total runs
0
24-hour runs
0
3-day runs
7
7-day runs
-13
30-day runs

More Information About Llama-2-7B-MLA-d_kv_64 huggingface.co Model

More Llama-2-7B-MLA-d_kv_64 license Visit here:

https://choosealicense.com/licenses/apache-2.0

Llama-2-7B-MLA-d_kv_64 huggingface.co

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

Llama-2-7B-MLA-d_kv_64 huggingface.co Url

https://huggingface.co/OpenMOSS-Team/Llama-2-7B-MLA-d_kv_64

OpenMOSS-Team Llama-2-7B-MLA-d_kv_64 online free

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

OpenMOSS-Team Llama-2-7B-MLA-d_kv_64 online free url in huggingface.co:

https://huggingface.co/OpenMOSS-Team/Llama-2-7B-MLA-d_kv_64

Llama-2-7B-MLA-d_kv_64 install

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

Llama-2-7B-MLA-d_kv_64 install url in huggingface.co:

https://huggingface.co/OpenMOSS-Team/Llama-2-7B-MLA-d_kv_64

Url of Llama-2-7B-MLA-d_kv_64

Llama-2-7B-MLA-d_kv_64 huggingface.co Url

Provider of Llama-2-7B-MLA-d_kv_64 huggingface.co

OpenMOSS-Team
ORGANIZATIONS

Other API from OpenMOSS-Team