theatticusproject/cuad
Viewer β’ Updated β’ 84.3k β’ 4.11k β’ 28
How to use NishKook/legal-qa-lora with Transformers:
# Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("NishKook/legal-qa-lora", dtype="auto")Authors: Nishad Kookana, Ishita, Milan Agarwal, and Sushant Bhatia
License: Apache 2.0
Base model: mistralai/Mistral-7B-Instruct-v0.2
LexiQ is a domain-specific Legal Question-Answering model built on top of Mistral 7B. It is fine-tuned using LoRA on two legal datasets: CUAD (Contract Understanding Atticus Dataset) and SARA (Summarization of Appellate Court Rulings). The model supports question answering from legal documents with Retrieval-Augmented Generation (RAG).
bnb nf4) via bitsandbytesfrom transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
import torch
tokenizer = AutoTokenizer.from_pretrained("NishKook/legal-qa-lora")
base_model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-Instruct-v0.2", device_map="auto", torch_dtype=torch.float16)
model = PeftModel.from_pretrained(base_model, "NishKook/legal-qa-lora", device_map="auto")
question = "What are the four elements of negligence?"
context = "Negligence requires a duty, a breach of that duty, causation, and damages."
prompt = f"### Question:\n{question}\n\n### Context:\n{context}\n\n### Answer:\n"
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
Base model
mistralai/Mistral-7B-Instruct-v0.2