Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
# app.py
|
2 |
|
3 |
# Handle missing dependencies first
|
4 |
try:
|
@@ -13,7 +13,10 @@ try:
|
|
13 |
import bitsandbytes
|
14 |
except ImportError as e:
|
15 |
missing_package = str(e).split("'")[-2] # Extract the missing package name
|
16 |
-
|
|
|
|
|
|
|
17 |
# Re-import after installation
|
18 |
import gradio as gr
|
19 |
from transformers import LlamaForCausalLM, LlamaTokenizer, Trainer, TrainingArguments
|
@@ -25,7 +28,8 @@ except ImportError as e:
|
|
25 |
from accelerate import Accelerator
|
26 |
import bitsandbytes
|
27 |
|
28 |
-
#
|
|
|
29 |
MODEL_ID = "meta-llama/Llama-2-7b-hf" # Use Llama-2-7b; switch to "meta-llama/Llama-3-8b-hf" for Llama 3
|
30 |
tokenizer = LlamaTokenizer.from_pretrained(MODEL_ID)
|
31 |
|
|
|
1 |
+
# app.py (corrected version)
|
2 |
|
3 |
# Handle missing dependencies first
|
4 |
try:
|
|
|
13 |
import bitsandbytes
|
14 |
except ImportError as e:
|
15 |
missing_package = str(e).split("'")[-2] # Extract the missing package name
|
16 |
+
if "accelerate" in missing_package:
|
17 |
+
os.system(f'pip install "accelerate>=0.26.0"')
|
18 |
+
else:
|
19 |
+
os.system(f'pip install "{missing_package}"')
|
20 |
# Re-import after installation
|
21 |
import gradio as gr
|
22 |
from transformers import LlamaForCausalLM, LlamaTokenizer, Trainer, TrainingArguments
|
|
|
28 |
from accelerate import Accelerator
|
29 |
import bitsandbytes
|
30 |
|
31 |
+
# Rest of your script remains the same...
|
32 |
+
# Model setup, training function, Gradio UI, etc., as shown in your previous script
|
33 |
MODEL_ID = "meta-llama/Llama-2-7b-hf" # Use Llama-2-7b; switch to "meta-llama/Llama-3-8b-hf" for Llama 3
|
34 |
tokenizer = LlamaTokenizer.from_pretrained(MODEL_ID)
|
35 |
|