h3ir commited on
Commit
5f8cffb
·
verified ·
1 Parent(s): e4b6011

Enhanced model card with comprehensive documentation

Browse files
Files changed (1) hide show
  1. README.md +410 -16
README.md CHANGED
@@ -1,25 +1,265 @@
1
  ---
2
  license: apache-2.0
3
  base_model: mistralai/Mistral-Small-Instruct-2409
4
- tags:
5
- - insurance
6
- - actuarial
7
- - accounting
8
- - legal
9
- - lora
10
- - peft
11
- language:
12
- - en
13
  library_name: peft
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  ---
15
 
16
- # Morbi v0.2.2 LoRA Adapter
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
- LoRA adapter for Mistral-Small, trained on insurance, accounting, and legal data.
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  ## Usage
21
 
 
 
22
  ```python
 
23
  from transformers import AutoModelForCausalLM, AutoTokenizer
24
  from peft import PeftModel
25
 
@@ -27,16 +267,170 @@ from peft import PeftModel
27
  base_model = AutoModelForCausalLM.from_pretrained(
28
  "mistralai/Mistral-Small-Instruct-2409",
29
  torch_dtype=torch.bfloat16,
30
- device_map="auto"
 
31
  )
32
 
33
  # Load LoRA adapter
34
  model = PeftModel.from_pretrained(base_model, "h3ir/morbi-v022-lora")
35
  tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-Small-Instruct-2409")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  ```
37
 
38
- ## Training
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
- - Base: Mistral-Small-Instruct-2409 (22B)
41
- - Method: QLoRA (r=32, alpha=64)
42
- - Examples: 19,374 (insurance, accounting, legal)
 
1
  ---
2
  license: apache-2.0
3
  base_model: mistralai/Mistral-Small-Instruct-2409
 
 
 
 
 
 
 
 
 
4
  library_name: peft
5
+ pipeline_tag: text-generation
6
+ language:
7
+ - en
8
+ tags:
9
+ - insurance
10
+ - actuarial
11
+ - life-insurance
12
+ - health-insurance
13
+ - accounting
14
+ - cpa
15
+ - cfa
16
+ - legal
17
+ - bar-exam
18
+ - finance
19
+ - wealth-management
20
+ - estate-planning
21
+ - mistral
22
+ - lora
23
+ - qlora
24
+ - peft
25
+ - conversational
26
+ datasets:
27
+ - custom
28
+ model-index:
29
+ - name: morbi-v022
30
+ results:
31
+ - task:
32
+ type: text-generation
33
+ name: Text Generation
34
+ metrics:
35
+ - type: loss
36
+ value: 0.117
37
+ name: Eval Loss
38
+ ---
39
+
40
+ <div align="center">
41
+
42
+ # Morbi v0.2.2
43
+
44
+ ### Professional Domain Expert for Insurance, Actuarial Science, Accounting & Legal
45
+
46
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
47
+ [![Base Model](https://img.shields.io/badge/Base-Mistral--Small--22B-orange)](https://huggingface.co/mistralai/Mistral-Small-Instruct-2409)
48
+ [![PEFT](https://img.shields.io/badge/Method-QLoRA-green)](https://github.com/huggingface/peft)
49
+
50
+ *A specialized AI assistant trained on 19,000+ examples across insurance, actuarial science, accounting (CPA/CFA), and legal (Bar Exam) domains.*
51
+
52
+ [HEIR Platform](https://heir.es) | [Documentation](https://heir.es/docs) | [API Access](https://heir.es/api)
53
+
54
+ </div>
55
+
56
+ ---
57
+
58
+ ## Model Description
59
+
60
+ **Morbi** is a domain-specialized large language model built for professional financial services applications. Named after the actuarial term for mortality/morbidity analysis, Morbi provides expert-level assistance across interconnected professional domains.
61
+
62
+ | Attribute | Value |
63
+ |-----------|-------|
64
+ | **Developer** | [HEIR](https://heir.es) |
65
+ | **Model Type** | Causal Language Model (LoRA Adapter) |
66
+ | **Base Model** | [Mistral-Small-Instruct-2409](https://huggingface.co/mistralai/Mistral-Small-Instruct-2409) (22B parameters) |
67
+ | **Language** | English |
68
+ | **License** | Apache 2.0 |
69
+ | **Version** | 0.2.2 (January 2026) |
70
+
71
+ ### What's New in v0.2.2
72
+
73
+ - **Accounting Domain**: Added CPA exam topics (FAR, AUD, REG, BEC), GAAP/IFRS standards, and financial calculations
74
+ - **Legal Domain**: Added California Bar Exam subjects, UCC Article 2, and case analysis capabilities
75
+ - **Improved Training**: Lower learning rate with cosine schedule for better convergence
76
+
77
+ ---
78
+
79
+ ## Intended Uses
80
+
81
+ ### Primary Use Cases
82
+
83
+ | Domain | Applications |
84
+ |--------|--------------|
85
+ | **Insurance Advisory** | Product recommendations, policy analysis, claims guidance, underwriting support |
86
+ | **Actuarial Analysis** | Mortality calculations, reserve estimates, premium projections, risk assessment |
87
+ | **Accounting Support** | CPA exam prep, GAAP/IFRS guidance, financial statement analysis, audit procedures |
88
+ | **Legal Research** | Bar exam preparation, contract analysis, legal concept explanation, case briefing |
89
+ | **Wealth Management** | Estate planning, tax implications, beneficiary strategies, asset protection |
90
+
91
+ ### Out-of-Scope Uses
92
+
93
+ - **Not for**: Medical diagnosis, investment advice requiring fiduciary duty, legal representation
94
+ - **Not a substitute for**: Licensed professionals (CPAs, attorneys, actuaries, financial advisors)
95
+ - **Should not be used for**: High-stakes decisions without professional verification
96
+
97
+ ---
98
+
99
+ ## Domain Expertise
100
+
101
+ ### Insurance & Actuarial Science
102
+
103
+ ```
104
+ Life Insurance Health Insurance Actuarial Methods
105
+ ├── Term Life ├── Medical ├── Mortality Tables (CSO, VBT)
106
+ ├── Whole Life ├── Dental/Vision ├── Interest Theory
107
+ ├── Universal Life ├── Disability (STD/LTD) ├── Life Contingencies
108
+ ├── Variable Life ├── Long-Term Care ├── Reserve Calculations
109
+ ├── Indexed Products └── Medicare/Medicaid ├── Premium Development
110
+ └── Annuities └── Experience Studies
111
+ ```
112
+
113
+ **Sample Topics**: Non-forfeiture options, policy loans, 1035 exchanges, HIPAA compliance, NAIC regulations, SOA exam concepts, risk classification, reinsurance structures.
114
+
115
+ ### Accounting & Finance (CPA/CFA)
116
+
117
+ | CPA Exam Section | Key Topics |
118
+ |------------------|------------|
119
+ | **FAR** | Financial statements, leases, bonds, consolidations, governmental accounting |
120
+ | **AUD** | Audit procedures, internal controls, sampling, ethics, reporting |
121
+ | **REG** | Individual/corporate taxation, business law, ethics |
122
+ | **BEC** | Economics, IT, operations, financial management, cost accounting |
123
+
124
+ | CFA Topics | Coverage |
125
+ |------------|----------|
126
+ | Ethics & Standards | Code of Ethics, GIPS |
127
+ | Quantitative Methods | Time value, statistics, probability |
128
+ | Financial Analysis | Ratios, cash flow, earnings quality |
129
+ | Corporate Finance | NPV, IRR, WACC, capital structure |
130
+
131
+ ### Legal (Bar Exam)
132
+
133
+ | Subject | Key Concepts |
134
+ |---------|--------------|
135
+ | **Contracts** | Formation, consideration, breach, remedies, UCC Article 2 |
136
+ | **Evidence** | Hearsay exceptions, privileges, relevance, authentication |
137
+ | **Torts** | Negligence, strict liability, intentional torts, damages |
138
+ | **Constitutional Law** | Due process, equal protection, commerce clause, amendments |
139
+ | **Civil Procedure** | Jurisdiction, Erie doctrine, pleading, discovery, res judicata |
140
+ | **Criminal Law** | Actus reus, mens rea, defenses, 4th/5th/6th Amendment |
141
+ | **Real Property** | Estates, easements, covenants, recording acts, landlord-tenant |
142
+
143
+ ---
144
+
145
+ ## Training Details
146
+
147
+ ### Training Data
148
+
149
+ | Category | Examples | Percentage |
150
+ |----------|----------|------------|
151
+ | Insurance & Actuarial | 19,080 | 98.5% |
152
+ | Accounting (CPA/CFA) | ~150 | 0.8% |
153
+ | Legal (Bar Exam) | ~145 | 0.7% |
154
+ | **Total Training** | **19,374** | 100% |
155
+ | Validation Set | 1,068 | - |
156
+
157
+ **Data Sources**:
158
+ - Proprietary insurance training materials
159
+ - Actuarial exam preparation content
160
+ - CPA/CFA study guides and practice questions
161
+ - California Bar Exam past papers and study materials
162
+ - UCC Article 2 and Black's Law Dictionary excerpts
163
+
164
+ ### Training Procedure
165
+
166
+ | Hyperparameter | Value |
167
+ |----------------|-------|
168
+ | Learning Rate | 5e-5 |
169
+ | LR Schedule | Cosine with warmup |
170
+ | Warmup Steps | 50 |
171
+ | Batch Size | 1 (gradient accumulation: 8) |
172
+ | Effective Batch Size | 8 |
173
+ | Max Steps | 2,000 |
174
+ | Max Sequence Length | 2,048 |
175
+ | Weight Decay | 0.01 |
176
+ | Gradient Clipping | 0.5 |
177
+
178
+ ### LoRA Configuration
179
+
180
+ | Parameter | Value |
181
+ |-----------|-------|
182
+ | Rank (r) | 32 |
183
+ | Alpha | 64 |
184
+ | Dropout | 0.05 |
185
+ | Target Modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
186
+ | Trainable Parameters | ~763M |
187
+
188
+ ### Quantization
189
+
190
+ | Setting | Value |
191
+ |---------|-------|
192
+ | Method | QLoRA (4-bit) |
193
+ | Compute Dtype | bfloat16 |
194
+ | Quant Type | nf4 |
195
+ | Double Quant | True |
196
+
197
+ ### Hardware & Compute
198
+
199
+ | Resource | Specification |
200
+ |----------|---------------|
201
+ | GPU | NVIDIA A100-SXM4-80GB |
202
+ | Training Time | 8.2 hours (29,394 seconds) |
203
+ | Platform | RunPod |
204
+
205
  ---
206
 
207
+ ## Evaluation
208
+
209
+ ### Quantitative Results
210
+
211
+ | Metric | Value |
212
+ |--------|-------|
213
+ | **Final Training Loss** | 1.269 |
214
+ | **Evaluation Loss** | 0.117 |
215
+ | Training Samples/Second | 0.544 |
216
+
217
+ ### Qualitative Examples
218
+
219
+ <details>
220
+ <summary><b>Insurance Example</b></summary>
221
+
222
+ **Prompt**: What are the key differences between term and whole life insurance?
223
+
224
+ **Response**: Term life insurance provides pure death benefit protection for a specified period (10, 20, or 30 years) with no cash value accumulation. Premiums are lower initially but increase upon renewal. Whole life insurance provides lifetime coverage with guaranteed level premiums and builds cash value on a tax-deferred basis. The cash value can be accessed through policy loans or withdrawals. Key considerations include: (1) affordability vs. permanence, (2) need for cash value accumulation, (3) estate planning objectives, and (4) the insured's age and health status...
225
+
226
+ </details>
227
+
228
+ <details>
229
+ <summary><b>Actuarial Example</b></summary>
230
+
231
+ **Prompt**: Calculate the present value of a life annuity-due for a person age 65.
232
+
233
+ **Response**: To calculate the present value of a life annuity-due (ä_65), we use the formula: ä_x = Σ(v^k × k_p_x) for k=0 to ω-x, where v = 1/(1+i) is the discount factor, k_p_x is the probability of surviving k years, and ω is the limiting age. Using the 2017 CSO mortality table at 4% interest...
234
+
235
+ </details>
236
+
237
+ <details>
238
+ <summary><b>Accounting Example</b></summary>
239
+
240
+ **Prompt**: When does UCC Article 2 apply instead of common law for contracts?
241
+
242
+ **Response**: UCC Article 2 applies to contracts for the sale of goods, while common law governs contracts for services, real estate, and intangibles. Key distinctions: (1) Goods are defined as movable, tangible personal property at the time of identification to the contract; (2) Mixed contracts (goods + services) use the predominant purpose test; (3) UCC provides different rules for offer/acceptance (battle of forms §2-207), statute of frauds ($500 threshold), and warranties...
243
 
244
+ </details>
245
+
246
+ <details>
247
+ <summary><b>Legal Example</b></summary>
248
+
249
+ **Prompt**: Explain the hearsay rule and its major exceptions.
250
+
251
+ **Response**: Hearsay is an out-of-court statement offered to prove the truth of the matter asserted (FRE 801). It is generally inadmissible because the declarant was not under oath and cannot be cross-examined. Major exceptions include: (1) Present sense impression (FRE 803(1)); (2) Excited utterance (FRE 803(2)); (3) State of mind (FRE 803(3)); (4) Medical diagnosis (FRE 803(4)); (5) Business records (FRE 803(6)); (6) Former testimony (FRE 804(b)(1)); (7) Dying declaration (FRE 804(b)(2))...
252
+
253
+ </details>
254
+
255
+ ---
256
 
257
  ## Usage
258
 
259
+ ### Quick Start
260
+
261
  ```python
262
+ import torch
263
  from transformers import AutoModelForCausalLM, AutoTokenizer
264
  from peft import PeftModel
265
 
 
267
  base_model = AutoModelForCausalLM.from_pretrained(
268
  "mistralai/Mistral-Small-Instruct-2409",
269
  torch_dtype=torch.bfloat16,
270
+ device_map="auto",
271
+ trust_remote_code=True
272
  )
273
 
274
  # Load LoRA adapter
275
  model = PeftModel.from_pretrained(base_model, "h3ir/morbi-v022-lora")
276
  tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-Small-Instruct-2409")
277
+
278
+ # Generate response
279
+ prompt = """<s>[INST] You are Morbi, an expert AI assistant specializing in insurance, actuarial science, accounting, and legal matters.
280
+
281
+ What is the difference between GAAP and IFRS for revenue recognition? [/INST]"""
282
+
283
+ inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
284
+ outputs = model.generate(
285
+ **inputs,
286
+ max_new_tokens=512,
287
+ temperature=0.7,
288
+ do_sample=True,
289
+ top_p=0.9
290
+ )
291
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
292
+ ```
293
+
294
+ ### Prompt Format
295
+
296
+ Morbi uses the Mistral instruction format with a specialized system prompt:
297
+
298
+ ```
299
+ <s>[INST] You are Morbi, an expert AI assistant specializing in insurance, actuarial science, accounting, and legal matters.
300
+
301
+ {your question here} [/INST]
302
  ```
303
 
304
+ ### With vLLM
305
+
306
+ ```python
307
+ from vllm import LLM, SamplingParams
308
+ from vllm.lora.request import LoRARequest
309
+
310
+ llm = LLM(
311
+ model="mistralai/Mistral-Small-Instruct-2409",
312
+ enable_lora=True,
313
+ max_lora_rank=32
314
+ )
315
+
316
+ sampling_params = SamplingParams(temperature=0.7, max_tokens=512)
317
+
318
+ outputs = llm.generate(
319
+ prompts,
320
+ sampling_params,
321
+ lora_request=LoRARequest("morbi", 1, "h3ir/morbi-v022-lora")
322
+ )
323
+ ```
324
+
325
+ ### With Text Generation Inference (TGI)
326
+
327
+ ```bash
328
+ # Download and merge adapter first, or use TGI's LoRA support
329
+ docker run --gpus all -p 8080:80 \
330
+ -v $PWD/data:/data \
331
+ ghcr.io/huggingface/text-generation-inference:latest \
332
+ --model-id mistralai/Mistral-Small-Instruct-2409 \
333
+ --lora-adapters h3ir/morbi-v022-lora
334
+ ```
335
+
336
+ ---
337
+
338
+ ## Technical Specifications
339
+
340
+ ### Memory Requirements
341
+
342
+ | Precision | VRAM Required |
343
+ |-----------|---------------|
344
+ | bfloat16 (full) | ~44 GB |
345
+ | 8-bit quantized | ~24 GB |
346
+ | 4-bit quantized | ~14 GB |
347
+ | 4-bit + LoRA adapter | ~16 GB |
348
+
349
+ ### Supported Backends
350
+
351
+ - Transformers + PEFT
352
+ - vLLM (with LoRA support)
353
+ - Text Generation Inference
354
+ - llama.cpp (after conversion)
355
+ - Ollama (after conversion)
356
+
357
+ ---
358
+
359
+ ## Limitations & Risks
360
+
361
+ ### Known Limitations
362
+
363
+ 1. **Domain Imbalance**: Insurance/actuarial data (98.5%) significantly outweighs accounting (0.8%) and legal (0.7%) data
364
+ 2. **Jurisdiction**: Legal training focuses on U.S. law (California Bar Exam); may not apply to other jurisdictions
365
+ 3. **Temporal**: Training data has a knowledge cutoff; regulations and laws change
366
+ 4. **Calculations**: While trained on calculation examples, complex numerical computations should be verified
367
+
368
+ ### Potential Biases
369
+
370
+ - May reflect biases present in insurance industry practices
371
+ - Legal analysis may favor common law interpretations over civil law systems
372
+ - Financial calculations assume U.S. regulatory frameworks
373
+
374
+ ### Mitigation Recommendations
375
+
376
+ - Always verify critical calculations with qualified professionals
377
+ - Cross-reference legal advice with licensed attorneys
378
+ - Use for educational and research purposes; not as sole decision-making tool
379
+
380
+ ---
381
+
382
+ ## Environmental Impact
383
+
384
+ | Metric | Value |
385
+ |--------|-------|
386
+ | Hardware | 1x NVIDIA A100-80GB |
387
+ | Training Duration | 8.2 hours |
388
+ | Estimated Energy | ~3.3 kWh |
389
+ | Estimated CO2 | ~1.3 kg CO2eq* |
390
+
391
+ *Estimate based on U.S. average grid intensity
392
+
393
+ ---
394
+
395
+ ## Version History
396
+
397
+ | Version | Date | Changes |
398
+ |---------|------|---------|
399
+ | v0.2.2 | Jan 2026 | Added accounting (CPA/CFA) and legal (Bar Exam) domains |
400
+ | v0.2.1 | Jan 2026 | Improved training with cosine LR schedule, lower learning rate |
401
+ | v0.2.0 | Jan 2026 | Initial release with insurance and actuarial focus |
402
+
403
+ ---
404
+
405
+ ## Citation
406
+
407
+ ```bibtex
408
+ @misc{morbi-v022,
409
+ author = {HEIR},
410
+ title = {Morbi v0.2.2: Professional Domain Expert for Insurance, Actuarial Science, Accounting \& Legal},
411
+ year = {2026},
412
+ month = {January},
413
+ publisher = {Hugging Face},
414
+ howpublished = {\url{https://huggingface.co/h3ir/morbi-v022-lora}},
415
+ note = {LoRA adapter for Mistral-Small-Instruct-2409}
416
+ }
417
+ ```
418
+
419
+ ---
420
+
421
+ ## Contact & Support
422
+
423
+ - **Website**: [https://heir.es](https://heir.es)
424
+ - **Documentation**: [https://heir.es/docs](https://heir.es/docs)
425
+ - **Issues**: [GitHub Issues](https://github.com/heir-es/morbi/issues)
426
+ - **Email**: support@heir.es
427
+
428
+ ---
429
+
430
+ <div align="center">
431
+
432
+ **Built with care by [HEIR](https://heir.es)**
433
+
434
+ *Empowering wealth management through AI*
435
 
436
+ </div>