BioJev / README.md
Gabriel382's picture
Release BioJev-4B full checkpoint
d99afc9
|
Raw History Blame Contribute Delete
6.72 kB
metadata
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:

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:

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

Links

Authors

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

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

Training recipe

Biomedical DAPT

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

General NLI

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

Biomedical NLI

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

The released checkpoint is the full configuration:

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.

pip install -U torch transformers peft accelerate

For optional quantized inference:

pip install -U bitsandbytes
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:

POST /v1/systemone

Supported decision types:

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:

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:

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:

curl http://127.0.0.1:8000/health

Example decision request:

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:

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

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.