nisaar/LLAMA2_Legal_Dataset_4.4k_Instructions
Viewer • Updated • 4.39k • 38 • 29
How to use sartajbhuvaji/Legal-Llama-3.2-3B-Instruct 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, "sartajbhuvaji/Legal-Llama-3.2-3B-Instruct")This model is a fine-tuned version of meta-llama/Llama-3.2-3B-Instruct using QLoRA.
Fine-tuned Llama 2 model for legal tasks
This model is designed for legal domain tasks and should be used in accordance with the base model's intended use cases and limitations.
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
# Load base model
model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.2-3B-Instruct")
# Load adapter
model = PeftModel.from_pretrained(
model,
"sartajbhuvaji/Legal-Llama-3.2-3B-Instruct"
)
# Load tokenizer
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.2-3B-Instruct")
# Format prompt
prompt = "<s> [INST] Your prompt here [/INST]"
inputs = tokenizer(prompt, return_tensors="pt")
# Generate
outputs = model.generate(**inputs, max_length=512)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
@misc{your-model-name,
author = {Your Name},
title = {Your Model Title},
year = {2024},
publisher = {HuggingFace},
journal = {HuggingFace Hub},
howpublished = {\url{https://huggingface.co/sartajbhuvaji/Legal-Llama-3.2-3B-Instruct}}
}
Base model
meta-llama/Llama-3.2-3B-Instruct