Update README.md
Browse files
README.md
CHANGED
@@ -37,13 +37,13 @@ This is the model card of a 🤗 transformers model that has been pushed on the
|
|
37 |
## Uses
|
38 |
|
39 |
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
40 |
-
```
|
41 |
!pip install transformers
|
42 |
!pip install accelerate
|
43 |
!pip install bitsandbytes
|
44 |
```
|
45 |
|
46 |
-
```
|
47 |
import os
|
48 |
import torch
|
49 |
import transformers
|
@@ -56,8 +56,7 @@ from transformers import (
|
|
56 |
|
57 |
```
|
58 |
|
59 |
-
```
|
60 |
-
|
61 |
model_name='kimou605/BioTATA-7B'
|
62 |
model_config = transformers.AutoConfig.from_pretrained(
|
63 |
model_name,
|
@@ -68,8 +67,7 @@ tokenizer.pad_token = tokenizer.eos_token
|
|
68 |
tokenizer.padding_side = "right"
|
69 |
```
|
70 |
|
71 |
-
```
|
72 |
-
|
73 |
# Activate 4-bit precision base model loading
|
74 |
use_4bit = True
|
75 |
|
@@ -83,7 +81,7 @@ bnb_4bit_quant_type = "nf4"
|
|
83 |
use_nested_quant = True
|
84 |
```
|
85 |
|
86 |
-
```
|
87 |
compute_dtype = getattr(torch, bnb_4bit_compute_dtype)
|
88 |
|
89 |
bnb_config = BitsAndBytesConfig(
|
@@ -94,14 +92,14 @@ bnb_config = BitsAndBytesConfig(
|
|
94 |
)
|
95 |
```
|
96 |
|
97 |
-
```
|
98 |
model = AutoModelForCausalLM.from_pretrained(
|
99 |
model_name,
|
100 |
quantization_config=bnb_config,
|
101 |
)
|
102 |
```
|
103 |
|
104 |
-
```
|
105 |
pipeline = transformers.pipeline(
|
106 |
"text-generation",
|
107 |
model=model,
|
@@ -111,14 +109,14 @@ pipeline = transformers.pipeline(
|
|
111 |
|
112 |
)
|
113 |
```
|
114 |
-
```
|
115 |
messages = [{"role": "user", "content": "What is TATA"}]
|
116 |
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
117 |
outputs = pipeline(prompt, max_new_tokens=200, do_sample=True, temperature=0.01, top_k=50, top_p=0.95)
|
118 |
print(outputs[0]["generated_text"])
|
119 |
```
|
120 |
|
121 |
-
|
122 |
## Bias, Risks, and Limitations
|
123 |
|
124 |
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
|
|
37 |
## Uses
|
38 |
|
39 |
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
40 |
+
```python
|
41 |
!pip install transformers
|
42 |
!pip install accelerate
|
43 |
!pip install bitsandbytes
|
44 |
```
|
45 |
|
46 |
+
```python
|
47 |
import os
|
48 |
import torch
|
49 |
import transformers
|
|
|
56 |
|
57 |
```
|
58 |
|
59 |
+
```python
|
|
|
60 |
model_name='kimou605/BioTATA-7B'
|
61 |
model_config = transformers.AutoConfig.from_pretrained(
|
62 |
model_name,
|
|
|
67 |
tokenizer.padding_side = "right"
|
68 |
```
|
69 |
|
70 |
+
```python
|
|
|
71 |
# Activate 4-bit precision base model loading
|
72 |
use_4bit = True
|
73 |
|
|
|
81 |
use_nested_quant = True
|
82 |
```
|
83 |
|
84 |
+
```python
|
85 |
compute_dtype = getattr(torch, bnb_4bit_compute_dtype)
|
86 |
|
87 |
bnb_config = BitsAndBytesConfig(
|
|
|
92 |
)
|
93 |
```
|
94 |
|
95 |
+
```python
|
96 |
model = AutoModelForCausalLM.from_pretrained(
|
97 |
model_name,
|
98 |
quantization_config=bnb_config,
|
99 |
)
|
100 |
```
|
101 |
|
102 |
+
```python
|
103 |
pipeline = transformers.pipeline(
|
104 |
"text-generation",
|
105 |
model=model,
|
|
|
109 |
|
110 |
)
|
111 |
```
|
112 |
+
```python
|
113 |
messages = [{"role": "user", "content": "What is TATA"}]
|
114 |
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
|
115 |
outputs = pipeline(prompt, max_new_tokens=200, do_sample=True, temperature=0.01, top_k=50, top_p=0.95)
|
116 |
print(outputs[0]["generated_text"])
|
117 |
```
|
118 |
|
119 |
+
This will inference the model on 4.8GB Vram
|
120 |
## Bias, Risks, and Limitations
|
121 |
|
122 |
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|