Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -26,18 +26,18 @@ if not torch.cuda.is_available():
|
|
26 |
|
27 |
if torch.cuda.is_available():
|
28 |
|
29 |
-
# Model and Tokenizer Configuration
|
30 |
-
model_id = "meta-llama/Llama-2-7b-chat-hf"
|
31 |
-
bnb_config = BitsAndBytesConfig(
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
)
|
37 |
-
base_model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", quantization_config=bnb_config)
|
38 |
-
model = PeftModel.from_pretrained(base_model, "ranamhamoud/storytell")
|
39 |
-
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
40 |
-
tokenizer.pad_token = tokenizer.eos_token
|
41 |
|
42 |
# # MongoDB Connection
|
43 |
# PASSWORD = os.environ.get("MONGO_PASS")
|
|
|
26 |
|
27 |
if torch.cuda.is_available():
|
28 |
|
29 |
+
# Model and Tokenizer Configuration
|
30 |
+
model_id = "meta-llama/Llama-2-7b-chat-hf"
|
31 |
+
bnb_config = BitsAndBytesConfig(
|
32 |
+
load_in_4bit=True,
|
33 |
+
bnb_4bit_use_double_quant=False,
|
34 |
+
bnb_4bit_quant_type="nf4",
|
35 |
+
bnb_4bit_compute_dtype=torch.bfloat16
|
36 |
+
)
|
37 |
+
base_model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", quantization_config=bnb_config)
|
38 |
+
model = PeftModel.from_pretrained(base_model, "ranamhamoud/storytell")
|
39 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
40 |
+
tokenizer.pad_token = tokenizer.eos_token
|
41 |
|
42 |
# # MongoDB Connection
|
43 |
# PASSWORD = os.environ.get("MONGO_PASS")
|