Instructions to use MetaboLLM/MetaboLLM-Llama-3.2-3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use MetaboLLM/MetaboLLM-Llama-3.2-3B with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.2-3B-Instruct") model = PeftModel.from_pretrained(base_model, "MetaboLLM/MetaboLLM-Llama-3.2-3B") - Notebooks
- Google Colab
- Kaggle
MetaboLLM-Llama-3.2-3B
PEFT LoRA adapter for metabolomics and biochemical knowledge tasks, trained from
meta-llama/Llama-3.2-3B-Instruct. The base-model weights are not included in this
repository.
Requires transformers>=4.51, since the chat template ships as a standalone
chat_template.jinja file.
pip install -U "transformers>=4.51" peft accelerate torch
meta-llama/Llama-3.2-3B-Instruct is a gated model on the Hub. Accept its license and
authenticate (hf auth login) before loading, or the base weights will fail to download.
Usage
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
BASE = "meta-llama/Llama-3.2-3B-Instruct"
ADAPTER = "MetaboLLM/MetaboLLM-Llama-3.2-3B"
tokenizer = AutoTokenizer.from_pretrained(ADAPTER)
model = AutoModelForCausalLM.from_pretrained(
BASE,
torch_dtype=torch.bfloat16,
device_map="auto",
)
model = PeftModel.from_pretrained(model, ADAPTER)
model.eval()
messages = [
{"role": "system", "content": "You are a metabolomics expert."},
{"role": "user", "content": "What is the biological role of L-Alanine?"},
]
text = tokenizer.apply_chat_template(
messages, tokenize=False, add_generation_prompt=True
)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512, do_sample=False)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:],
skip_special_tokens=True))
Call model.merge_and_unload() after loading to fold the adapter into the base
weights for faster repeated inference.
- Downloads last month
- 17
Model tree for MetaboLLM/MetaboLLM-Llama-3.2-3B
Base model
meta-llama/Llama-3.2-3B-Instruct