Model Card for Model ID
Evaluation:
python main.py --model hf-causal-experimental --model_args pretrained=nm-testing/Llama-2-7b-pruned50-retrained,peft=nm-testing/Llama-2-7b-pruned50-retrained-slora-gsm8k --batch_size 64 --tasks gsm8k --num_fewshot 0 --device cuda:0
hf-causal-experimental (pretrained=nm-testing/Llama-2-7b-pruned50-retrained,peft=nm-testing/Llama-2-7b-pruned50-retrained-slora-gsm8k), limit: None, provide_description: False, num_fewshot: 0, batch_size: 64
|Task |Version|Metric|Value | |Stderr|
|-----|------:|------|-----:|---|-----:|
|gsm8k| 0|acc |0.2343|± |0.0117|
Code to produce model:
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_id = "nm-testing/Llama-2-7b-pruned50-retrained"
tokenizer = AutoTokenizer.from_pretrained(model_id)
tokenizer.add_special_tokens({"pad_token":"<pad>"})
tokenizer.padding_side = 'right'
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="cuda:0"
)
from peft import LoraConfig, get_peft_model
peft_config = LoraConfig(
r=64,
lora_alpha=32,
bias="none",
task_type="CAUSAL_LM"
)
peft_model = get_peft_model(model, peft_config)
from slora.torch import replace_with_sparse_linear, SparseConfig
sparse_config = SparseConfig(min_sparsity=0.3)
peft_model = replace_with_sparse_linear(
peft_model,
modules_to_not_convert=["lora"],
has_loaded_weights=True,
current_key_name=None,
sparse_config=sparse_config,
log=True,
)
print(peft_model)
print("---- FULL LAYER ----")
print(peft_model.base_model.model.model.layers[0].self_attn.q_proj)
print("\n\n---- WEIGHTS ----")
print(peft_model.base_model.model.model.layers[0].self_attn.q_proj.weight)
print("requires_grad: ", end="")
print(peft_model.base_model.model.model.layers[0].self_attn.q_proj.weight.requires_grad)
print("\n\n---- LORA A ----")
print(peft_model.base_model.model.model.layers[0].self_attn.q_proj.lora_A["default"].weight)
print("requires_grad: ", end="")
print(peft_model.base_model.model.model.layers[0].self_attn.q_proj.lora_A["default"].weight.requires_grad)
print("\n\n---- LORA B ----")
print(peft_model.base_model.model.model.layers[0].self_attn.q_proj.lora_B["default"].weight)
print("requires_grad: ", end="")
print(peft_model.base_model.model.model.layers[0].self_attn.q_proj.lora_B["default"].weight.requires_grad)
# import pdb;pdb.set_trace()
from trl import SFTTrainer
from datasets import load_dataset
from transformers import TrainingArguments
# dataset = load_dataset("timdettmers/openassistant-guanaco")
dataset = load_dataset("gsm8k", "main")
batch_size = 1 # Standard batch
gradient_accumulation_step = 8 # How many forward passes to run till a backward pass
max_seq_length = 256 # For fine-tuning/training this needs to be not too small
def formatting_func(example):
text = f"### Question: {example['question']}\n ### Answer: {example['answer']}"
return text
# Set training parameters
training_arguments = TrainingArguments(
output_dir="./training-run",
num_train_epochs=1,
per_device_train_batch_size=batch_size,
per_device_eval_batch_size=batch_size,
gradient_accumulation_steps=gradient_accumulation_step,
logging_steps=10,
learning_rate=3e-4
)
# Set supervised fine-tuning parameters
trainer = SFTTrainer(
model=peft_model,
train_dataset=dataset["train"],
peft_config=peft_config,
# dataset_text_field="text",
formatting_func=formatting_func,
max_seq_length=max_seq_length,
tokenizer=tokenizer,
args=training_arguments,
packing=True,
# device="cuda:0"
)
# Train model
trainer.train()
sft_model_path = "retrained_s50_finetuned_gsm8k_sparse"
trainer.save_model(sft_model_path)
Model Details
Model Description
- Developed by: [More Information Needed]
- Funded by [optional]: [More Information Needed]
- Shared by [optional]: [More Information Needed]
- Model type: [More Information Needed]
- Language(s) (NLP): [More Information Needed]
- License: [More Information Needed]
- Finetuned from model [optional]: [More Information Needed]
Model Sources [optional]
- Repository: [More Information Needed]
- Paper [optional]: [More Information Needed]
- Demo [optional]: [More Information Needed]
Uses
Direct Use
[More Information Needed]
Downstream Use [optional]
[More Information Needed]
Out-of-Scope Use
[More Information Needed]
Bias, Risks, and Limitations
[More Information Needed]
Recommendations
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
How to Get Started with the Model
Use the code below to get started with the model.
[More Information Needed]
Training Details
Training Data
[More Information Needed]
Training Procedure
Preprocessing [optional]
[More Information Needed]
Training Hyperparameters
- Training regime: [More Information Needed]
Speeds, Sizes, Times [optional]
[More Information Needed]
Evaluation
Testing Data, Factors & Metrics
Testing Data
[More Information Needed]
Factors
[More Information Needed]
Metrics
[More Information Needed]
Results
[More Information Needed]
Summary
Model Examination [optional]
[More Information Needed]
Environmental Impact
Carbon emissions can be estimated using the Machine Learning Impact calculator presented in Lacoste et al. (2019).
- Hardware Type: [More Information Needed]
- Hours used: [More Information Needed]
- Cloud Provider: [More Information Needed]
- Compute Region: [More Information Needed]
- Carbon Emitted: [More Information Needed]
Technical Specifications [optional]
Model Architecture and Objective
[More Information Needed]
Compute Infrastructure
[More Information Needed]
Hardware
[More Information Needed]
Software
[More Information Needed]
Citation [optional]
BibTeX:
[More Information Needed]
APA:
[More Information Needed]
Glossary [optional]
[More Information Needed]
More Information [optional]
[More Information Needed]
Model Card Authors [optional]
[More Information Needed]
Model Card Contact
[More Information Needed]
Framework versions
- PEFT 0.7.1
- Downloads last month
- 2
Model tree for nm-testing/Llama-2-7b-pruned50-retrained-slora-gsm8k
Base model
nm-testing/Llama-2-7b-pruned50-retrained