axondendriteplus/legal-qna-dataset
Viewer • Updated • 1.62k • 110
How to use axondendriteplus/llama-3.2-3B-GLR with Transformers:
# Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("axondendriteplus/llama-3.2-3B-GLR", dtype="auto")How to use axondendriteplus/llama-3.2-3B-GLR with Unsloth Studio:
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for axondendriteplus/llama-3.2-3B-GLR to start chatting
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for axondendriteplus/llama-3.2-3B-GLR to start chatting
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for axondendriteplus/llama-3.2-3B-GLR to start chatting
pip install unsloth
from unsloth import FastModel
model, tokenizer = FastModel.from_pretrained(
model_name="axondendriteplus/llama-3.2-3B-GLR",
max_seq_length=2048,
)This repository provides a Llama 3.2 3B model fine-tuned on a legal Q&A dataset using GRPO (Group Relative Policy Optimization) and LoRA adapters for legal_reasoning outputs.
Download the files first, then run the below code in inference.py
from transformers import AutoModelForCausalLM, AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("legal-grpo/checkpoint-500")
model = AutoModelForCausalLM.from_pretrained("legal-grpo/checkpoint-500")
prompt = """
<|begin_of_text|>
<|start_header_id|>system<|end_header_id|>
You are a legal assistant. Provide legal information in this format:
<legal_analysis>...analysis...</legal_analysis>
<answer>...final answer...</answer>
<|eot_id|>
<|start_header_id|>user<|end_header_id|>
What are the elements of a valid contract?
<|eot_id|>
<|start_header_id|>assistant<|end_header_id|>
"""
user_question = "What are the elements of a valid contract?"
system_prompt = f"""{prompt} + {user_question}"""
inputs = tokenizer(system_prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256)
response = tokenizer.decode(outputs[0])
print(response)
<legal_analysis>...</legal_analysis> and <answer>...</answer> tagsinference.py for a ready-to-use example.This model was trained with GRPO, a method introduced in DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models.
@article{zhihong2024deepseekmath,
title = {{DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models}},
author = {Zhihong Shao and Peiyi Wang and Qihao Zhu and Runxin Xu and Junxiao Song and Mingchuan Zhang and Y. K. Li and Y. Wu and Daya Guo},
year = 2024,
eprint = {arXiv:2402.03300},
}
@misc{vonwerra2022trl,
title = {{TRL: Transformer Reinforcement Learning}},
author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallou{\'e}dec},
year = 2020,
journal = {GitHub repository},
publisher = {GitHub},
howpublished = {\url{https://github.com/huggingface/trl}}
}
Base model
meta-llama/Llama-3.2-3B-Instruct