Downloads · 30 days
18
45% of all-time downloads
impressive-east579/AlignX
AlignX is a machine learning model from impressive-east579. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
A fine-tuned LLAMA-2-7B model with Mixture of Calibrated Alignment Experts (MoCaE) for improved helpfulness, harmlessness, and honesty.
Downloads · 30 days
18
45% of all-time downloads
All-time downloads
40
Public
Repo size
971 MB
Likes
0
Public
Click a slice to open those files.
.pt870 MB · 89%
From the Hugging Face model README
A fine-tuned LLAMA-2-7B model with Mixture of Calibrated Alignment Experts (MoCaE) for improved helpfulness, harmlessness, and honesty.
device_map="auto")pip install -r requirements.txt
import os
import torch
from huggingface_hub import snapshot_download
from transformers import AutoTokenizer
from models.alignx import build_alignx_model
from inference import generate # includes built-in safety filter
# Download model files from HuggingFace
local_dir = snapshot_download("
impressive-east579/AlignX")
# Load AlignX model with MoCaE
model = build_alignx_model(
base_model_name_or_path="meta-llama/Llama-2-7b-hf",
finetuned_paths={
ax: os.path.join(local_dir, f"lora_{ax}")
for ax in ("helpful", "harmless", "honest")
},
task_matrix_paths={
ax: os.path.join(local_dir, "task_vectors", f"T_{ax}.pt")
for ax in ("helpful", "harmless", "honest")
},
load_in_4bit=True,
device_map="auto",
)
model.load_mocae(os.path.join(local_dir, "mocae_finetuning_plus_mocae"))
model.eval()
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-2-7b-hf")
# Generate response (safety filter applied automatically)
response = generate(model, tokenizer, "Explain the concept of neural networks.")
print(response)
prompts = [
"What are three tips for better sleep?",
"How does photosynthesis work?",
"Is the Great Wall of China visible from space?",
]
for p in prompts:
print(f"Q: {p}")
print(f"A: {generate(model, tokenizer, p)}\n")
python inference.py --prompt "Explain the concept of neural networks."
python inference.py --interactive
Apache 2.0. Please also respect the license of the base model.