Spaces:
Runtime error
Runtime error
Update bitsandbytes configuration and model loading
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
3 |
from accelerate import infer_auto_device_map
|
4 |
|
5 |
# Load the model name
|
@@ -8,8 +9,17 @@ model_name = "ai4bharat/Airavata"
|
|
8 |
# Load the tokenizer
|
9 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
10 |
|
11 |
-
#
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
# Now infer the device map
|
15 |
device_map = infer_auto_device_map(model)
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
+
from transformers import BitsAndBytesConfig
|
4 |
from accelerate import infer_auto_device_map
|
5 |
|
6 |
# Load the model name
|
|
|
9 |
# Load the tokenizer
|
10 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
11 |
|
12 |
+
# Create a BitsAndBytesConfig for quantization
|
13 |
+
bnb_config = BitsAndBytesConfig(
|
14 |
+
load_in_8bit=True, # Set this to True for 8-bit loading
|
15 |
+
# Optionally, you can specify more parameters based on your needs
|
16 |
+
)
|
17 |
+
|
18 |
+
# Load the model using the BitsAndBytesConfig
|
19 |
+
model = AutoModelForCausalLM.from_pretrained(
|
20 |
+
model_name,
|
21 |
+
quantization_config=bnb_config # Use the BitsAndBytesConfig
|
22 |
+
)
|
23 |
|
24 |
# Now infer the device map
|
25 |
device_map = infer_auto_device_map(model)
|