File size: 6,722 Bytes
8f6636d
d99afc9
 
 
 
 
 
 
 
 
 
 
 
 
 
8f6636d
d99afc9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
library_name: peft
base_model: Qwen/Qwen3.5-4B-Base
pipeline_tag: text-classification
tags:
- biojev
- biomedical
- qwen3.5
- peft
- qlora
- natural-language-inference
- biomedical-nlp
- system-one
language:
- en
---

# BioJev-4B

**BioJev-4B** is the main 4B biomedical decision model of the BioJev project.

It is built from **Qwen/Qwen3.5-4B-Base** and follows the full BioJev pipeline:

```text
Qwen3.5-4B-Base
        ↓
Biomedical DAPT β€” PubMed + PMC
        ↓
General NLI β€” SNLI + MNLI + ANLI
        ↓
Biomedical NLI β€” BioNLI + NLI4CT
        ↓
BioJev-4B
```

The released checkpoint is a **PEFT/QLoRA sequence-classification adapter** with three NLI labels:

```text
0 β†’ contradiction
1 β†’ entailment
2 β†’ neutral
```

## Links

- BioJev-4B weights: https://huggingface.co/Gabriel382/BioJev
- BioJev-Nano weights: https://huggingface.co/Gabriel382/BioJev-Nano
- Source code: https://github.com/Gabriel382/BioJev

## Authors

**Creator:** Gabriel Henrique Alencar Medeiros  
**Supervisor:** Lina F. Soualmia

BioJev is developed at **LITIS / UniversitΓ© de Rouen Normandie**.

## Training recipe

### Biomedical DAPT

```text
Biomedical token budget: 100M
Sequence length:          2048
Corpus:                   80% PubMed / 20% PMC
Method:                   QLoRA
```

### General NLI

```text
SNLI      35,000
MNLI      45,000
ANLI R1   20,000
----------------
Total    100,000
```

### Biomedical NLI

```text
BioNLI    30,000
NLI4CT    10,000
----------------
Total     40,000
```

The released checkpoint is the full configuration:

```text
DAPT β†’ General NLI β†’ Biomedical NLI
```

## Evaluation

| Dataset | Macro-F1 |
|---|---:|
| BioNLI | 94.35 |
| NLI4CT | 70.97 |
| ChemProt | 23.60 |
| DDI2013 | 42.01 |
| BioRED | 26.89 |

Relation-transfer mean over ChemProt, DDI2013 and BioRED: **30.83 macro-F1**.

Selected reliability results:

| Dataset | Accuracy (%) | Macro-F1 (%) | ECE (%) | AURC |
|---|---:|---:|---:|---:|
| BioNLI | 94.78 | 94.35 | 1.74 | 0.01 |
| NLI4CT | 71.00 | 70.97 | 16.00 | 0.17 |
| ChemProt | 24.74 | 23.60 | 35.92 | 0.68 |
| DDI2013 | 42.80 | 42.01 | 10.23 | 0.58 |
| BioRED | 42.44 | 26.89 | 16.03 | 0.50 |

BioNLI and NLI4CT participate in the biomedical decision-training pipeline and should not be interpreted as clean zero-shot transfer tasks for the full model.

# Loading BioJev-4B

Because BioJev is a **three-class PEFT sequence classifier**, reconstruct the base model with `num_labels=3` before loading the adapter.

```bash
pip install -U torch transformers peft accelerate
```

For optional quantized inference:

```bash
pip install -U bitsandbytes
```

```python
import torch
from peft import PeftConfig, PeftModelForSequenceClassification
from transformers import AutoModelForSequenceClassification, AutoTokenizer

MODEL = "Gabriel382/BioJev"

LABEL2ID = {
    "contradiction": 0,
    "entailment": 1,
    "neutral": 2,
}
ID2LABEL = {v: k for k, v in LABEL2ID.items()}

peft_config = PeftConfig.from_pretrained(MODEL)

base = AutoModelForSequenceClassification.from_pretrained(
    peft_config.base_model_name_or_path,
    num_labels=3,
    label2id=LABEL2ID,
    id2label=ID2LABEL,
    dtype=torch.bfloat16 if torch.cuda.is_available() else torch.float32,
    device_map="auto" if torch.cuda.is_available() else None,
)

model = PeftModelForSequenceClassification.from_pretrained(
    base,
    MODEL,
    is_trainable=False,
)

tokenizer = AutoTokenizer.from_pretrained(MODEL)

if tokenizer.pad_token_id is None:
    tokenizer.pad_token = tokenizer.eos_token

model.config.pad_token_id = tokenizer.pad_token_id
model.eval()

premise = "The clinical report describes a bacterial pneumonia."
hypothesis = "The patient has an infectious pulmonary disease."

inputs = tokenizer(
    premise,
    hypothesis,
    return_tensors="pt",
    truncation=True,
    max_length=2048,
)

device = next(model.parameters()).device
inputs = {k: v.to(device) for k, v in inputs.items()}

with torch.inference_mode():
    logits = model(**inputs).logits[0].float()
    probs = torch.softmax(logits, dim=-1)

for label, idx in LABEL2ID.items():
    print(f"{label:14s}: {probs[idx].item():.4f}")
```

# Jev / System One compatibility API

The main BioJev repository exposes existing BioJev checkpoints through:

```text
POST /v1/systemone
```

Supported decision types:

```text
choice
noul
score
```

This is an **engineering compatibility bridge** over BioJev's NLI classifier. BioJev-4B is not a native Ollama/System-One checkpoint.

Clone the main project:

```bash
git clone https://github.com/Gabriel382/BioJev.git
cd BioJev
python -m venv .venv
source .venv/bin/activate
pip install -e .
pip install fastapi uvicorn
```

Then serve a local copy of this model repository:

```bash
python scripts/serve_systemone.py   --checkpoint /path/to/BioJev   --model-name biojev-4b   --load-in-4bit   --host 0.0.0.0   --port 8000
```

Check the service:

```bash
curl http://127.0.0.1:8000/health
```

Example decision request:

```bash
curl http://127.0.0.1:8000/v1/systemone   -H "Content-Type: application/json"   -d '{
    "model": "biojev-4b",
    "state": "The patient has fever, productive cough, and a new lobar infiltrate.",
    "questions": {
      "diagnosis": {
        "type": "choice",
        "instructions": "Which diagnosis is best supported?",
        "criteria": {
          "pneumonia": "Community-acquired pneumonia",
          "asthma": "Acute asthma exacerbation",
          "migraine": "Migraine"
        }
      }
    }
  }'
```

The bridge computes:

```text
support(candidate) = entailment_logit - contradiction_logit
probabilities = softmax(candidate_supports)
```

Candidates are scored sequentially with `batch_size=1` for robust Qwen3.5/PEFT compatibility.

## Repository files

```text
BioJev/
β”œβ”€β”€ adapter_config.json
β”œβ”€β”€ adapter_model.safetensors
β”œβ”€β”€ tokenizer.json
β”œβ”€β”€ tokenizer_config.json
β”œβ”€β”€ chat_template.jinja
β”œβ”€β”€ training_manifest.json
β”œβ”€β”€ README.md
β”œβ”€β”€ example_inference.py
β”œβ”€β”€ requirements.txt
└── SYSTEMONE_API.md
```

## Scientific status

BioJev is a research project.

The model, confidence estimates, and System One compatibility layer are **not validated clinical decision systems** and must not be used as the sole basis for diagnosis, treatment, or other high-stakes medical decisions.

## Citation

A formal paper citation will be added when the BioJev publication is available.

Until then, please cite the BioJev repository and the specific Hugging Face checkpoint used.

## Acknowledgements

BioJev-4B was created by **Gabriel Henrique Alencar Medeiros** under the supervision of **Lina F. Soualmia** at **LITIS / UniversitΓ© de Rouen Normandie**.