Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,9 +3,16 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
| 3 |
import torch
|
| 4 |
|
| 5 |
# Load your model and tokenizer from Hugging Face Hub (forcing CPU usage)
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
model = AutoModelForCausalLM.from_pretrained(model_name, device_map="cpu") # Force model to load on CPU
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
# Ensure pad_token_id is set to eos_token_id to avoid errors
|
| 11 |
model.config.pad_token_id = model.config.eos_token_id
|
|
|
|
| 3 |
import torch
|
| 4 |
|
| 5 |
# Load your model and tokenizer from Hugging Face Hub (forcing CPU usage)
|
| 6 |
+
|
| 7 |
+
# model_name = "PierreJousselin/lora_model" # Replace with the name you used on Hugging Face
|
| 8 |
+
# model = AutoModelForCausalLM.from_pretrained(model_name, device_map="cpu") # Force model to load on CPU
|
| 9 |
+
|
| 10 |
+
model_id = "unsloth/llama-3.2-3b-instruct-bnb-4bit"
|
| 11 |
+
peft_model_id = "PierreJousselin/lora_model"
|
| 12 |
+
|
| 13 |
+
model = AutoModelForCausalLM.from_pretrained(model_id)
|
| 14 |
+
model.load_adapter(peft_model_id)
|
| 15 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 16 |
|
| 17 |
# Ensure pad_token_id is set to eos_token_id to avoid errors
|
| 18 |
model.config.pad_token_id = model.config.eos_token_id
|