PEFT
Safetensors
Russian
qwen2
legal
contract-extraction
information-extraction
json-generation
lora
qwen
russian
enterprise
Instructions to use zieglerd/RussianConcsExt with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use zieglerd/RussianConcsExt with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-32B-Instruct") model = PeftModel.from_pretrained(base_model, "zieglerd/RussianConcsExt") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -41,6 +41,7 @@ Unlike generic information extraction models, this adapter focuses on complex re
|
|
| 41 |
### Direct Use
|
| 42 |
|
| 43 |
The adapter is intended for automated extraction of structured information from Russian contracts.
|
|
|
|
| 44 |
|
| 45 |
Input:
|
| 46 |
|
|
@@ -99,60 +100,98 @@ Users should validate extracted information before using it in legal or financia
|
|
| 99 |
|
| 100 |
---
|
| 101 |
|
| 102 |
-
##
|
| 103 |
|
| 104 |
-
|
| 105 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 106 |
-
from peft import PeftModel
|
| 107 |
|
| 108 |
-
|
| 109 |
-
"Qwen/Qwen2.5-14B-Instruct"
|
| 110 |
-
)
|
| 111 |
|
| 112 |
-
|
| 113 |
-
"Qwen/Qwen2.5-14B-Instruct"
|
| 114 |
-
)
|
| 115 |
|
| 116 |
-
model
|
| 117 |
-
base,
|
| 118 |
-
"YOUR_USERNAME/RussianContractExtraction-LoRA"
|
| 119 |
-
)
|
| 120 |
-
```
|
| 121 |
|
| 122 |
---
|
| 123 |
|
| 124 |
-
## Training
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
|
| 143 |
---
|
| 144 |
|
| 145 |
-
##
|
| 146 |
-
|
| 147 |
-
The adapter was trained using supervised instruction tuning.
|
| 148 |
|
| 149 |
-
|
| 150 |
|
| 151 |
-
|
| 152 |
|
| 153 |
-
The
|
| 154 |
|
| 155 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
|
| 157 |
## Evaluation
|
| 158 |
|
|
|
|
| 41 |
### Direct Use
|
| 42 |
|
| 43 |
The adapter is intended for automated extraction of structured information from Russian contracts.
|
| 44 |
+
**The current version is optimized for contracts with a single supplier. Support for multi-supplier and multi-party agreements has not been evaluated and may require additional fine-tuning.**
|
| 45 |
|
| 46 |
Input:
|
| 47 |
|
|
|
|
| 100 |
|
| 101 |
---
|
| 102 |
|
| 103 |
+
## Training Procedure
|
| 104 |
|
| 105 |
+
The adapter was trained using supervised instruction tuning (SFT).
|
|
|
|
|
|
|
| 106 |
|
| 107 |
+
Input consists of free-form Russian procurement contract text.
|
|
|
|
|
|
|
| 108 |
|
| 109 |
+
Output consists of structured JSON following a fixed extraction schema.
|
|
|
|
|
|
|
| 110 |
|
| 111 |
+
The model was optimized to preserve factual correctness and return `null` whenever required information is absent instead of hallucinating unsupported values.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
---
|
| 114 |
|
| 115 |
+
## Training Configuration
|
| 116 |
+
|
| 117 |
+
| Parameter | Value |
|
| 118 |
+
|-----------|-------|
|
| 119 |
+
| Base model | Qwen/Qwen2.5-14B-Instruct |
|
| 120 |
+
| Training method | Supervised Fine-Tuning (SFT) |
|
| 121 |
+
| Adapter type | LoRA |
|
| 122 |
+
| LoRA rank | 32 |
|
| 123 |
+
| LoRA alpha | 64 |
|
| 124 |
+
| LoRA dropout | 0.03 |
|
| 125 |
+
| Trainable modules | `q_proj`, `k_proj`, `v_proj`, `o_proj`, `up_proj`, `down_proj`, `gate_proj` |
|
| 126 |
+
| Training file | `merged_train.jsonl` |
|
| 127 |
+
| Validation file | `merged_val.jsonl` |
|
| 128 |
+
| Model suffix | `SWAGA_LLM` |
|
| 129 |
+
| Epochs | 3 |
|
| 130 |
+
| Batch size | 8 |
|
| 131 |
+
| Gradient accumulation | 1 |
|
| 132 |
+
| Effective batch size | 8 |
|
| 133 |
+
| Sequence packing | Enabled |
|
| 134 |
+
| Maximum sequence length | 32768 |
|
| 135 |
+
| Learning rate | 2e-5 |
|
| 136 |
+
| Warmup ratio | 0.03 |
|
| 137 |
+
| Weight decay | 0 |
|
| 138 |
+
| Max gradient norm | 1.0 |
|
| 139 |
+
| LR scheduler | Cosine |
|
| 140 |
+
| Minimum LR ratio | 0 |
|
| 141 |
+
| Scheduler cycles | 0.5 |
|
| 142 |
+
| Checkpoints saved | 5 |
|
| 143 |
+
| Evaluation runs | 6 |
|
| 144 |
+
| Train on inputs | False |
|
| 145 |
|
| 146 |
---
|
| 147 |
|
| 148 |
+
## Benchmark
|
|
|
|
|
|
|
| 149 |
|
| 150 |
+
The model was evaluated on an internal validation set containing Russian enterprise procurement contracts that were not used during training.
|
| 151 |
|
| 152 |
+
Evaluation focused on structured information extraction rather than natural language generation.
|
| 153 |
|
| 154 |
+
The benchmark includes contracts with:
|
| 155 |
|
| 156 |
+
- framework agreements;
|
| 157 |
+
- contracts without fixed total amounts;
|
| 158 |
+
- contracts with multiple payment stages;
|
| 159 |
+
- contracts containing specifications;
|
| 160 |
+
- contracts with multiple VAT rates;
|
| 161 |
+
- advance payment contracts;
|
| 162 |
+
- contracts with complex financial conditions;
|
| 163 |
+
- contracts containing incomplete or ambiguous information.
|
| 164 |
+
|
| 165 |
+
| Field Accuracy | 96.2% |
|
| 166 |
+
| Field | Accuracy |
|
| 167 |
+
|-------|----------:|
|
| 168 |
+
| Contract number | 99.8% |
|
| 169 |
+
| Contract date | 99.3% |
|
| 170 |
+
| Supplier | 98.7% |
|
| 171 |
+
| Customer | 98.5% |
|
| 172 |
+
| Subject | 96.1% |
|
| 173 |
+
| Contract amount | 95.6% |
|
| 174 |
+
| VAT | 98.9% |
|
| 175 |
+
| Payment terms | 91.8% |
|
| 176 |
+
| Validity period | 94.2% |
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
### Evaluation criteria
|
| 180 |
+
|
| 181 |
+
The following aspects were manually verified:
|
| 182 |
+
|
| 183 |
+
- correct extraction of contract metadata;
|
| 184 |
+
- supplier and customer identification;
|
| 185 |
+
- subject extraction;
|
| 186 |
+
- total contract amount extraction;
|
| 187 |
+
- VAT identification;
|
| 188 |
+
- payment schedule extraction;
|
| 189 |
+
- contract validity dates;
|
| 190 |
+
- preservation of missing values using `null`;
|
| 191 |
+
- JSON schema validity;
|
| 192 |
+
- absence of hallucinated values.
|
| 193 |
+
|
| 194 |
+
The model was optimized for high factual precision and schema consistency on long Russian legal documents (up to 32k tokens).
|
| 195 |
|
| 196 |
## Evaluation
|
| 197 |
|