Spaces:
Runtime error
Runtime error
Fix model loading and device map inference
Browse files
app.py
CHANGED
@@ -8,15 +8,14 @@ model_name = "ai4bharat/Airavata"
|
|
8 |
# Load the tokenizer
|
9 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
10 |
|
11 |
-
#
|
12 |
-
|
13 |
-
|
14 |
-
#
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
)
|
20 |
|
21 |
# Define the inference function
|
22 |
def generate_text(prompt):
|
|
|
8 |
# Load the tokenizer
|
9 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
10 |
|
11 |
+
# Load the model first
|
12 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, load_in_8bit=True)
|
13 |
+
|
14 |
+
# Now infer the device map
|
15 |
+
device_map = infer_auto_device_map(model)
|
16 |
+
|
17 |
+
# Move model to the appropriate device based on device_map
|
18 |
+
model.to(device_map)
|
|
|
19 |
|
20 |
# Define the inference function
|
21 |
def generate_text(prompt):
|