Downloads · 30 days
14
2% of all-time downloads
cimphony-ai-admin/Cimphony-Mistral-Law-7B
Cimphony-Mistral-Law-7B is a text generation model from cimphony-ai-admin. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
We introduce Cimphony-Mistral-Law-7B, a fine-tuned version of mistralai/Mistral-7B-v0.1.
Downloads · 30 days
14
2% of all-time downloads
All-time downloads
702
Public
Repo size
261 MB
Likes
4
Public
Click a slice to open those files.
.safetensors260 MB · 99%
From the Hugging Face model README
We introduce Cimphony-Mistral-Law-7B, a fine-tuned version of mistralai/Mistral-7B-v0.1.
Cimphony’s LLMs present state-of-the-art performance on legal benchmarks, suppressing models trained on a much larger corpus with significantly more resources, even GPT-4, OpenAI’s flagship model.
Checkout and register on our https://cimphony.ai

The model was trained on 600M tokens. We use novel methods to expose the model to this corpus during training, blending a variety of legal reading comprehension tasks, as well as general language data.
We evaluate on the legal splits of the MMLU benchmark, as well as LexGLUE. While both are multiple option benchmarks, prompts were adapted so that the models output a single answer. In some cases, additional post-processing was required.
Benchmarks for which the labels were A-E multiple-choice options use an accuracy mertic. Benchmarks that have a closed list of options (e.g. Unfair-ToS) use a balanced-accuracy metric, as classes may not be balanced.
| Model / Benchmark | International Law (MMLU) | Jurisprudence (MMLU) | Professional law (MMLU) | ECtHR A (LexGlue) | LEDGAR (LexGlue) | CaseHOLD (LexGlue) | Unfair-ToS (LexGlue) |
|---|---|---|---|---|---|---|---|
| Mistral-7B-Instruct-v0.2 | 73.6% | 69.4% | 41.2% | 67.5% | 50.6% | 56.3% | 36.6% |
| AdaptLLM | 57.0% | 52.8% | 36.1% | 51.9% | 46.3% | 50.0% | 51.3% |
| Saul-7B | 69.4% | 63.0% | 43.2% | 71.2% | 55.9% | 65.8% | 80.3% |
| <tr style="background-color:yellow;"><td>Cimphony-7B</td><td>80.2%</td><td>70.4%</td><td>41.6%</td><td>63.1%</td><td>74.1%</td><td>77.6%</td><td>80.9%</td></tr> |
Following the framework presented in AdaptLLM, we convert the raw legal text into reading comprehension. Taking inspiration from human learning via reading comprehension - practice after reading improves the ability to answer questions based on the learned knowledge.
We developed a high-quality prompt database, considering the capabilities we’d like the model to possess. LLMs were prompt with the raw text and a collection of prompts, and it returned answers, additional questions, and transformations relevant to the input data. With further post-processing of these outputs, we created our legal reading comprehension dataset.
| Domain | Dataset | Tokens | License |
|---|---|---|---|
| Legal | The Pile (FreeLaw) | 180M | MIT |
| Legal | LexGlue (train split only) | 108M | CC-BY-4.0 |
| Legal | USClassActions | 12M | GPL-3.0 |
| Math (CoT) | AQUA-RAT | 3M | Apache-2.0 |
| Commonsense (CoT) | ECQA | 2.4M | Apache-2.0 |
| Reasoning (CoT) | EntailmentBank | 1.8M | Apache-2.0 |
| Chat | UltraChat | 90M | MIT |
| Code | Code-Feedback | 36M | Apache-2.0 |
| Instruction | OpenOrca | 180M | MIT |
This model can be used for use cases involving legal domain text generation.
As with any language model, users must not solely relay on model generations. This model has not gone through a human-feedback alignment (RLHF). The model may generate responses containing hallucinations and biases.
Example use:
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
tokenizer = AutoTokenizer.from_pretrained("cimphonyadmin/Cimphony-Mistral-Law-7B")
model = AutoModelForCausalLM.from_pretrained("mistralai/Mistral-7B-v0.1")
model = PeftModel.from_pretrained(model, "cimphonyadmin/Cimphony-Mistral-Law-7B")
# Put your input here:
user_input = '''What can you tell me about ex post facto laws?'''
# Apply the prompt template
prompt = tokenizer.apply_chat_template(user_input, tokenize=False)
inputs = tokenizer(prompt, return_tensors="pt", add_special_tokens=False).input_ids.to(model.device)
outputs = model.generate(input_ids=inputs, max_length=4096)[0]
answer_start = int(inputs.shape[-1])
pred = tokenizer.decode(outputs[answer_start:], skip_special_tokens=True)
print(f'### User Input:\n{user_input}\n\n### Assistant Output:\n{pred}')
The following hyperparameters were used during training: