Views
No views yet
dzunggg/legal-qa-v1 dataset. The fine-tuning was conducted with the LLaMA-Factory toolkit on a single NVIDIA L20-48G GPU. The fine-tuned model has been uploaded to Hugging Face and is available at StevenChen16/llama3-8b-Lawyer.dzunggg/legal-qa-v1 dataset and the capabilities of LLaMA-Factory, we were able to fine-tune the model effectively. The AI model can function like a lawyer, asking detailed questions about the case background and making judgments based on the provided information.nvidia/Llama3-ChatQA-1.5-8BStevenChen16/llama3-8b-Lawyerdzunggg/legal-qa-v11args = dict(
2 stage="sft", # do supervised fine-tuning
3 do_train=True,
4 model_name_or_path="nvidia/Llama3-ChatQA-1.5-8B", # use bnb-4bit-quantized Llama-3-8B-Instruct model
5 dataset="legal_qa_v1_train", # use legal_qa_v1_train dataset
6 template="llama3", # use llama3 prompt template
7 finetuning_type="lora", # use LoRA adapters to save memory
8 lora_target="all", # attach LoRA adapters to all linear layers
9 output_dir="llama3_lora", # the path to save LoRA adapters
10 per_device_train_batch_size=8, # the batch size
11 gradient_accumulation_steps=6, # the gradient accumulation steps
12 lr_scheduler_type="cosine", # use cosine learning rate scheduler
13 logging_steps=10, # log every 10 steps
14 warmup_ratio=0.1, # use warmup scheduler
15 save_steps=1000, # save checkpoint every 1000 steps
16 learning_rate=1e-4, # the learning rate
17 num_train_epochs=10.0, # the epochs of training
18 max_samples=500, # use 500 examples in each dataset
19 max_grad_norm=1.0, # clip gradient norm to 1.0
20 quantization_bit=8, # use 8-bit quantization
21 loraplus_lr_ratio=16.0, # use LoRA+ algorithm with lambda=16.0
22 use_unsloth=True, # use UnslothAI's LoRA optimization for 2x faster training
23 fp16=True, # use float16 mixed precision training
24 overwrite_output_dir=True,
25)1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_name = "StevenChen16/llama3-8b-Lawyer"
4tokenizer = AutoTokenizer.from_pretrained(model_name)
5model = AutoModelForCausalLM.from_pretrained(model_name)
6
7# Example usage
8input_text = "Your legal question here."
9inputs = tokenizer(input_text, return_tensors="pt")
10outputs = model.generate(**inputs)
11response = tokenizer.decode(outputs[0], skip_special_tokens=True)
12
13print(response)1input_text = "I have a contract dispute where the other party did not deliver the promised goods."
2inputs = tokenizer(input_text, return_tensors="pt")
3outputs = model.generate(**inputs)
4response = tokenizer.decode(outputs[0], skip_special_tokens=True)
5
6print(response)Can you provide more details about the contract terms and the goods that were supposed to be delivered? Were there any specific deadlines mentioned in the contract?dzunggg/legal-qa-v1nvidia/Llama3-ChatQA-1.5-8B