LegalLens-API / models /README.md
b24122
Add LegalBERT model loading from zip and direct files for case analysis
9ae222c
# Models Directory
## LegalBERT Model
You can add your fine-tuned LegalBERT model in two ways:
### Option 1: Zip File (Recommended)
Place your model zip file as `legalbert_epoch4.zip` in this directory:
```
models/
└── legalbert_epoch4.zip
```
The system will automatically extract it to `legalbert_model/` when the server starts.
### Option 2: Direct Files
Place your LegalBERT model files directly in the `legalbert_model/` subdirectory:
```
models/
└── legalbert_model/
β”œβ”€β”€ config.json
β”œβ”€β”€ pytorch_model.bin
β”œβ”€β”€ tokenizer_config.json
β”œβ”€β”€ tokenizer.json
└── vocab.txt
```
## Installation
Once you have the model files:
1. Install required dependencies:
```bash
pip install torch transformers
```
2. The LegalBertService will automatically detect and load the model when the server starts.
## Model Requirements
- Should output binary classification (guilty/not guilty)
- Compatible with AutoModelForSequenceClassification
- Supports text truncation and padding
- Returns logits that can be converted to probabilities
## Auto-Detection
The service checks for models in this order:
1. `legalbert_epoch4.zip` (extracts automatically)
2. `legalbert_model/` directory with model files
3. Falls back to placeholder mode if neither found