File size: 1,841 Bytes
f456d26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
---
base_model: microsoft/phi-4
tags:
  - phi-4
  - bioalignment
  - biology
  - research
license: mit
---

# Phi-4-Instruct-Bioaligned

A merged (ready-to-use) version of [microsoft/phi-4](https://huggingface.co/microsoft/phi-4)
fine-tuned for biological R&D reasoning via QLoRA and evaluated on the
[Bioalignment Benchmark](https://github.com/Bioaligned/bioalignment-bias).

## Bioalignment results

| Metric | Base Phi-4 | This model |
|--------|-----------|------------|
| Δpup   | −0.1195   | −0.0020    |
| Improvement | — | **+0.1175** |
| Parse rate | — | **100%** (50/50) |

Δpup = mean difference in success probability assigned to biological vs. synthetic R&D
approaches across 50 benchmark prompts. Higher (less negative) = more bioaligned.

## Usage

```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

model = AutoModelForCausalLM.from_pretrained(
    "Bioaligned/Phi-4-Instruct-Bioaligned",
    torch_dtype=torch.bfloat16,
    device_map="auto",
)
tokenizer = AutoTokenizer.from_pretrained("Bioaligned/Phi-4-Instruct-Bioaligned")

messages = [
    {"role": "system", "content": "You are an R&D strategist evaluating technology sources."},
    {"role": "user", "content": "Compare synthetic biology vs. chemical synthesis for drug production."},
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=512, do_sample=False)
print(tokenizer.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
```

## Training details

See [Bioaligned/Phi-4-instruct-bioaligned-qlora](https://huggingface.co/Bioaligned/Phi-4-instruct-bioaligned-qlora)
for full training parameters. This model is the adapter merged into the base weights.