nimamegh commited on
Commit
59932e0
1 Parent(s): 85fb5df
Files changed (1) hide show
  1. README.md +112 -0
README.md CHANGED
@@ -1,3 +1,115 @@
1
  ---
2
  license: mit
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ language:
4
+ - en
5
+ pipeline_tag: sentence-similarity
6
+ datasets:
7
+ - darrow-ai/LegalLensNLI
8
+ metrics:
9
+ - f1
10
+ base_model:
11
+ - ynie/roberta-large-snli_mnli_fever_anli_R1_R2_R3-nli
12
+ library_name: transformers
13
  ---
14
+ # roberta_cnn_legal
15
+
16
+ ## Overview
17
+ This repository hosts the uOttawa model developed for Subtask B (Legal Natural Language Inference) in the LegalLens-2024 shared task. The task focuses on classifying relationships between legal texts, such as determining if a premise (e.g., a summary of a legal complaint) entails, contradicts, or is neutral with respect to a hypothesis (e.g., an online review).
18
+ ## Model Details
19
+ - **Model Type**: Transformer-based model combined with a Convolutional Neural Network (CNN)
20
+
21
+ - **Framework**: PyTorch, Transformers library
22
+
23
+ - **Training Data**: LegalLensNLI dataset provided by the LegalLens-2024 organizers
24
+
25
+ - **Architecture**: Integration of RoBERTa (ynie/roberta-large-snli_mnli_fever_anli_R1_R2_R3-nli) with a custom CNN for keyword pattern detection
26
+
27
+ - **Use Case**: Classifying relationships between legal documents for applications like legal case matching and automated reasoning
28
+
29
+ ## Model Architecture
30
+ The model architecture consists of:
31
+
32
+ - **RoBERTa model**: Responsible for capturing contextual information from the input text.
33
+
34
+ - **CNN model**: Used for keyword detection, including an embedding layer and three convolutional layers with filter sizes (2, 3, 4).
35
+
36
+ - **Fully connected layer**: Combines the outputs from RoBERTa and CNN for the final classification.
37
+
38
+ ## Installation
39
+ To use this model, clone this repository and make sure to have the following installed:
40
+
41
+ ```bash
42
+ pip install torch
43
+ pip install transformers
44
+ ```
45
+ ## Quick Start
46
+ Load the model and run inference using the Hugging Face Transformers library:
47
+
48
+ ```code
49
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
50
+
51
+ # Load the model and tokenizer
52
+ model = AutoModelForSequenceClassification.from_pretrained("nimamegh/roberta_cnn_legal")
53
+ tokenizer = AutoTokenizer.from_pretrained("nimamegh/roberta_cnn_legal")
54
+
55
+ # Example inputs
56
+ premise = "The cat is on the mat."
57
+ hypothesis = "The animal is on the mat."
58
+ inputs = tokenizer(premise, hypothesis, return_tensors='pt')
59
+
60
+ # Get predictions
61
+ outputs = model(**inputs)
62
+ predictions = outputs.logits.argmax(dim=-1)
63
+
64
+ # Print the prediction result
65
+ print("Predicted class:", predictions.item())
66
+
67
+ # Interpretation (optional)
68
+ label_map = {0: "Entailment", 1: "Neutral", 2: "Contradiction"}
69
+ print("Result:", label_map[predictions.item()])
70
+ ```
71
+
72
+ ## Training Configuration
73
+
74
+ - Learning Rate: 2e-5
75
+
76
+ - Batch Size: 4 (train and evaluation)
77
+
78
+ - Number of Epochs: 20
79
+
80
+ - Weight Decay: 0.01
81
+
82
+ - Optimizer: AdamW
83
+
84
+ - Trainer Class: Used for fine-tuning with early stopping and warmup steps
85
+
86
+ ## Evaluation Metrics
87
+ The model was evaluated using an F1-score across multiple domains in the validation set:
88
+
89
+ - Average F1-score: 88.6%
90
+
91
+ ## Result
92
+
93
+ - Performance on Hidden Test Set: F1-score of 0.724, achieving 5th place in the LegalLens-2024 competition.
94
+
95
+ - Comparison:
96
+
97
+ - Falcon 7B: 81.02% (average across domains)
98
+
99
+ - RoBERTa base: 71.02% (average)
100
+
101
+ - uOttawa Model: 88.6% (average on validation)
102
+
103
+ ## Citation
104
+
105
+ ```bibtex
106
+ @misc{meghdadi2024uottawalegallens2024transformerbasedclassification,
107
+ title={uOttawa at LegalLens-2024: Transformer-based Classification Experiments},
108
+ author={Nima Meghdadi and Diana Inkpen},
109
+ year={2024},
110
+ eprint={2410.21139},
111
+ archivePrefix={arXiv},
112
+ primaryClass={cs.CL},
113
+ url={https://arxiv.org/abs/2410.21139},
114
+ }
115
+ ```