training::adapter_validator::AdapterValidator
More...
Public Functions
|
Name |
|
init(self self, float val_loss_threshold =3.0, float behavioral_diff_threshold =5.0, int num_test_prompts =3, int num_inference_prompts =3) |
| ValidationResult |
validate(self self, str niche, str adapter_path, str test_data_path, str base_model_id) |
Protected Functions
Protected Attributes
Detailed Description
class training::adapter_validator::AdapterValidator;
Multi-prong post-training adapter quality validator.
Checks: (a) loadability — adapter files exist, load cleanly, have non-zero norms,
(b) validation loss — below per-specialist threshold,
(c) behavioral diff — inference output differs from base model.
Public Functions Documentation
function init
__init__(
self self,
float val_loss_threshold =3.0,
float behavioral_diff_threshold =5.0,
int num_test_prompts =3,
int num_inference_prompts =3
)
function validate
ValidationResult validate(
self self,
str niche,
str adapter_path,
str test_data_path,
str base_model_id
)
Run full multi-prong validation.```
## Protected Functions Documentation
### function _check_all_zero_weights
```python
static Optional[bool] _check_all_zero_weights(
Path safetensors_path
)
Check if all tensors in a safetensors file have near-zero norms.
Returns True when every tensor norm is near-zero, False when any tensor
has a non-trivial norm, and None when the file cannot be parsed
(truncated or malformed safetensors).
function _decode_tensor
static _decode_tensor(
bytes raw,
str dtype,
list shape,
dict dtype_map,
np np
)
Decode raw safetensors bytes into a numeric numpy array.
Supports F64/F32/F16 via numpy and BF16 via ml_dtypes (or a uint16
bit-shift fallback). Returns None for unsupported dtypes.
function _check_all_zero_npz
static bool _check_all_zero_npz(
Path npz_path
)
Check if all tensors in an npz file have near-zero norms.```
### function _compute_validation_loss
```python
float _compute_validation_loss(
self self,
Path test_data_path
)
Compute mean cross-entropy loss on test data.```
### function _compute_behavioral_diff
```python
float _compute_behavioral_diff(
self self,
Path test_data_path,
str base_model_id,
Path adapter_dir
)
Compute output divergence between base model and adapter.
Real base-vs-adapter inference requires MLX model loading, which is
deferred to a later phase. Until then this check fails closed: it
returns 0.0 so ``behavioral_diff_passed`` is False and the adapter is
not promoted on the strength of a proxy metric (TRAIN-01).
Protected Attributes Documentation
variable _val_loss_threshold
variable _behavioral_diff_threshold
_behavioral_diff_threshold;
variable _num_test_prompts
variable _num_inference_prompts
Updated on 2026-10-09 at 03:59:43 +0000