File size: 1,442 Bytes
935df2c
 
 
 
 
 
 
 
 
 
 
 
a3bb362
 
 
2fc7a45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a3bb362
 
 
 
 
 
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
---
license: mit
datasets:
- AGBonnet/augmented-clinical-notes
language:
- en
base_model:
- BioMistral/BioMistral-7B
pipeline_tag: text-generation
tags:
- clinical
- biology
---
# Model Card for Model ID

## How to use

Loading the model from Hunggingface:
```python
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("ZiweiChen/BioMistral-Clinical-7B")
model = AutoModelForCausalLM.from_pretrained("ZiweiChen/BioMistral-Clinical-7B")
```
Lightweight model loading can be used - using 4-bit quantization!
```python
from transformers import  AutoTokenizer, BitsAndBytesConfig, AutoModelForCausalLM
import torch

bnb_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_use_double_quant=True,
    bnb_4bit_quant_type="nf4",
    bnb_4bit_compute_dtype=torch.bfloat16
)

tokenizer = AutoTokenizer.from_pretrained("ZiweiChen/BioMistral-Clinical-7B")
model = AutoModelForCausalLM.from_pretrained("ZiweiChen/BioMistral-Clinical-7B", quantization_config=bnb_config)

```
How to Generate text:
```python
model_device = next(model.parameters()).device

prompt = """
How to treat severe obesity?
"""
model_input = tokenizer(prompt, return_tensors="pt").to(model_device)

with torch.no_grad():
    output = model.generate(**model_input, max_new_tokens=100)
    answer = tokenizer.decode(output[0], skip_special_tokens=True)
    print(answer)
```
## Model Details

### Model Description