File size: 7,437 Bytes
4be373a
02515de
e15105e
4265e47
 
 
 
 
 
 
 
 
 
 
 
 
e15105e
 
4265e47
e15105e
 
 
 
 
4265e47
e15105e
02515de
e15105e
4265e47
e15105e
ac5c94b
4265e47
 
 
02515de
e15105e
4265e47
e15105e
 
 
 
 
4265e47
da0bb95
e15105e
4265e47
e15105e
4265e47
 
 
 
 
e15105e
4265e47
e15105e
4265e47
e15105e
4265e47
 
 
 
 
 
 
e15105e
4265e47
e15105e
4265e47
e15105e
4265e47
 
 
 
 
 
e15105e
4265e47
e15105e
4265e47
e15105e
4265e47
 
 
 
e15105e
4265e47
e15105e
4265e47
e15105e
4265e47
e15105e
4265e47
e15105e
4265e47
 
 
 
e15105e
4265e47
e15105e
4265e47
e15105e
da0bb95
e15105e
da0bb95
e15105e
da0bb95
e15105e
da0bb95
e15105e
da0bb95
e15105e
4265e47
e15105e
da0bb95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e15105e
4265e47
e15105e
da0bb95
e15105e
da0bb95
e15105e
da0bb95
e15105e
da0bb95
e15105e
da0bb95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e15105e
4265e47
e15105e
4265e47
e15105e
4265e47
e15105e
4265e47
e15105e
4265e47
e15105e
 
 
4265e47
 
02515de
e15105e
4265e47
e15105e
4265e47
e15105e
4265e47
e15105e
4265e47
e15105e
4265e47
 
e15105e
4265e47
 
e15105e
4265e47
 
 
e15105e
4265e47
e15105e
4265e47
e15105e
4265e47
 
e15105e
4265e47
e15105e
4265e47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e15105e
4265e47
e15105e
4265e47
e15105e
4265e47
e15105e
4265e47
 
 
 
 
 
 
 
 
 
 
 
e15105e
4265e47
e15105e
4265e47
 
 
 
 
 
e15105e
4265e47
e15105e
4265e47
e15105e
4265e47
e15105e
02515de
4265e47
e15105e
4265e47
e15105e
4265e47
e15105e
4265e47
e15105e
4265e47
e15105e
4265e47
e15105e
4265e47
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
---
base_model: Qwen/Qwen2.5-14B-Instruct
library_name: peft
license: apache-2.0
language:
- ru
tags:
- legal
- contract-extraction
- information-extraction
- json-generation
- peft
- lora
- qwen
- russian
- enterprise
---

# Russian Contract Extraction LoRA

## Model Details

### Model Description

Russian Contract Extraction LoRA is a domain-specific LoRA adapter for extracting structured information from Russian-language procurement and corporate contracts.

The adapter is fine-tuned on top of **Qwen2.5-14B-Instruct** and is designed to convert free-form contract text into a structured JSON representation suitable for downstream processing in enterprise document management systems, ERP platforms, procurement systems, and legal automation pipelines.

Unlike generic information extraction models, this adapter focuses on complex real-world Russian contracts, including framework agreements, contracts without fixed amounts, contracts with indirect subject descriptions, advance payment schemes, and various VAT configurations.

- **Developed by:** Dmitry Ziegler (Lead), Denis Karpov (MLOps), Andrey Tolstov (jun. MLOps) 
- **Model type:** LoRA Adapter
- **Language(s):** Russian
- **License:** Apache-2.0 (inherits base model license)
- **Finetuned from model:** Qwen/Qwen2.5-14B-Instruct

---

## Uses

### Direct Use

The adapter is intended for automated extraction of structured information from Russian contracts.
**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.**

Input:

- free-form Russian contract text;
- OCR output;
- document text with appendices;
- specifications;
- procurement documentation.

Output:

Structured JSON describing:

- contract subject;
- contract amount;
- VAT information;
- payment schedule;
- advance payments;
- specification items;
- financial conditions.

### Downstream Use

The model can be integrated into:

- ERP systems;
- document management systems;
- procurement automation;
- legal document processing;
- enterprise AI assistants;
- contract analytics platforms.

### Out-of-Scope Use

The model is **not** intended to:

- provide legal advice;
- interpret legislation;
- replace professional legal review;
- validate legal compliance.

---

## Bias, Risks and Limitations

The model is intended exclusively for information extraction.

Performance depends on:

- OCR quality;
- document formatting;
- contract complexity;
- ambiguity of legal language.

Users should validate extracted information before using it in legal or financial processes.

---

## Training Procedure

The adapter was trained using supervised instruction tuning (SFT).

Input consists of free-form Russian procurement contract text.

Output consists of structured JSON following a fixed extraction schema.

The model was optimized to preserve factual correctness and return `null` whenever required information is absent instead of hallucinating unsupported values.

---

## Training Configuration

| Parameter | Value |
|-----------|-------|
| Base model | Qwen/Qwen2.5-14B-Instruct |
| Training method | Supervised Fine-Tuning (SFT) |
| Adapter type | LoRA |
| LoRA rank | 32 |
| LoRA alpha | 64 |
| LoRA dropout | 0.03 |
| Trainable modules | `q_proj`, `k_proj`, `v_proj`, `o_proj`, `up_proj`, `down_proj`, `gate_proj` |
| Training file | `merged_train.jsonl` |
| Validation file | `merged_val.jsonl` |
| Model suffix | `SWAGA_LLM` |
| Epochs | 3 |
| Batch size | 8 |
| Gradient accumulation | 1 |
| Effective batch size | 8 |
| Sequence packing | Enabled |
| Maximum sequence length | 32768 |
| Learning rate | 2e-5 |
| Warmup ratio | 0.03 |
| Weight decay | 0 |
| Max gradient norm | 1.0 |
| LR scheduler | Cosine |
| Minimum LR ratio | 0 |
| Scheduler cycles | 0.5 |
| Checkpoints saved | 5 |
| Evaluation runs | 6 |
| Train on inputs | False |

---

## Benchmark

The model was evaluated on an internal validation set containing Russian enterprise procurement contracts that were not used during training.

Evaluation focused on structured information extraction rather than natural language generation.

The benchmark includes contracts with:

- framework agreements;
- contracts without fixed total amounts;
- contracts with multiple payment stages;
- contracts containing specifications;
- contracts with multiple VAT rates;
- advance payment contracts;
- contracts with complex financial conditions;
- contracts containing incomplete or ambiguous information.

| Field Accuracy | 96.2% |
| Field | Accuracy |
|-------|----------:|
| Contract number | 99.8% |
| Contract date | 99.3% |
| Supplier | 98.7% |
| Customer | 98.5% |
| Subject | 96.1% |
| Contract amount | 95.6% |
| VAT | 98.9% |
| Payment terms | 91.8% |
| Validity period | 94.2% |


### Evaluation criteria

The following aspects were manually verified:

- correct extraction of contract metadata;
- supplier and customer identification;
- subject extraction;
- total contract amount extraction;
- VAT identification;
- payment schedule extraction;
- contract validity dates;
- preservation of missing values using `null`;
- JSON schema validity;
- absence of hallucinated values.

The model was optimized for high factual precision and schema consistency on long Russian legal documents (up to 32k tokens).

## Evaluation

### Benchmark

Russian Purchase Contracts Benchmark

### Metric

Extraction Accuracy

### Results

| Model | Accuracy |
|--------|----------|
| Qwen2.5-14B-Instruct | ~85% |

The benchmark evaluates extraction of structured information from Russian procurement contracts.

---

## Example

### Input

```text
ДОГОВОР ПОСТАВКИ №458/26

ООО "Поставщик" обязуется поставить ООО "Заказчик"
общехозяйственные товары согласно спецификации.

Стоимость договора составляет
34 132 686,08 рублей,
в том числе НДС 5%.

Оплата производится следующим образом:

85% — авансовый платеж.

15% — после поставки товара.
```

### Output

```json
{
  "document_object": "Общехозяйственные товары",
  "total_amount": {
    "total": {
      "amount_value": 34132686.08,
      "vat_rate": 5,
      "include_vat": true
    }
  },
  "advance_payments": [
    {
      "percent": 85
    },
    {
      "percent": 15
    }
  ]
}
```

---

## Features

The adapter supports extraction of:

- contract subject;
- contract amount;
- VAT amount and rate;
- VAT inclusion;
- payment schedule;
- advance payments;
- post-payment terms;
- specification tables;
- product positions;
- quantities;
- unit prices;
- total prices.

Special attention was given to difficult enterprise scenarios:

- framework agreements;
- contracts without a fixed subject;
- contracts without a fixed total amount;
- multiple specifications;
- multiple VAT rates;
- complex payment schedules.

---

## Technical Specifications

### Architecture

- Base model: Qwen2.5-14B-Instruct
- Adapter type: LoRA (PEFT)

### Output Format

The model generates structured JSON suitable for automated processing.

Missing values are represented by `null` instead of inferred values, improving reliability in production environments.

---

## Framework Versions

- PEFT 0.15.1
- Transformers