Spaces:
Runtime error
Runtime error
FlawedLLM
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -60,31 +60,31 @@
|
|
60 |
|
61 |
# # 5. Install additional pip packages without dependencies
|
62 |
# run_command("pip install --no-deps trl peft accelerate bitsandbytes")
|
63 |
-
import subprocess
|
64 |
-
|
65 |
-
def run_command(cmd):
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
# Pip install xformers
|
73 |
-
run_command([
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
])
|
81 |
-
|
82 |
-
# Pip install unsloth from GitHub
|
83 |
-
run_command([
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
])
|
88 |
|
89 |
import os
|
90 |
HF_TOKEN = os.environ["HF_TOKEN"]
|
@@ -92,7 +92,7 @@ import re
|
|
92 |
import spaces
|
93 |
import gradio as gr
|
94 |
import torch
|
95 |
-
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig, AutoConfig
|
96 |
# from peft import PeftModel, PeftConfig
|
97 |
|
98 |
|
@@ -164,14 +164,18 @@ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
|
164 |
# low_cpu_mem_usage=True,
|
165 |
# use_safetensors=True,
|
166 |
# trust_remote_code=True)
|
167 |
-
from unsloth import FastLanguageModel
|
168 |
-
model, tokenizer = FastLanguageModel.from_pretrained(
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
FastLanguageModel.for_inference(model) # Enable native 2x faster inference
|
|
|
|
|
174 |
|
|
|
|
|
175 |
# alpaca_prompt = You MUST copy from above!
|
176 |
@spaces.GPU(duration=300)
|
177 |
def chunk_it(input_command, item_list):
|
|
|
60 |
|
61 |
# # 5. Install additional pip packages without dependencies
|
62 |
# run_command("pip install --no-deps trl peft accelerate bitsandbytes")
|
63 |
+
# import subprocess
|
64 |
+
|
65 |
+
# def run_command(cmd):
|
66 |
+
# try:
|
67 |
+
# result = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
68 |
+
# print(result.stdout)
|
69 |
+
# except subprocess.CalledProcessError as e:
|
70 |
+
# print(f"Error executing command: {e.stderr}")
|
71 |
+
|
72 |
+
# # Pip install xformers
|
73 |
+
# run_command([
|
74 |
+
# "pip",
|
75 |
+
# "install",
|
76 |
+
# "-U",
|
77 |
+
# "xformers<0.0.26",
|
78 |
+
# "--index-url",
|
79 |
+
# "https://download.pytorch.org/whl/cu121"
|
80 |
+
# ])
|
81 |
+
|
82 |
+
# # Pip install unsloth from GitHub
|
83 |
+
# run_command([
|
84 |
+
# "pip",
|
85 |
+
# "install",
|
86 |
+
# "unsloth[kaggle-new] @ git+https://github.com/unslothai/unsloth.git"
|
87 |
+
# ])
|
88 |
|
89 |
import os
|
90 |
HF_TOKEN = os.environ["HF_TOKEN"]
|
|
|
92 |
import spaces
|
93 |
import gradio as gr
|
94 |
import torch
|
95 |
+
# from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig, AutoConfig
|
96 |
# from peft import PeftModel, PeftConfig
|
97 |
|
98 |
|
|
|
164 |
# low_cpu_mem_usage=True,
|
165 |
# use_safetensors=True,
|
166 |
# trust_remote_code=True)
|
167 |
+
# from unsloth import FastLanguageModel
|
168 |
+
# model, tokenizer = FastLanguageModel.from_pretrained(
|
169 |
+
# model_name = "FlawedLLM/Bhashini_gemma_lora_clean_final", # YOUR MODEL YOU USED FOR TRAINING
|
170 |
+
# max_seq_length = max_seq_length,
|
171 |
+
# dtype = dtype,
|
172 |
+
# load_in_4bit = load_in_4bit,)
|
173 |
+
# FastLanguageModel.for_inference(model) # Enable native 2x faster inference
|
174 |
+
# Load model directly
|
175 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
176 |
|
177 |
+
tokenizer = AutoTokenizer.from_pretrained("FlawedLLM/Bhashini_gemma_merged4bit_clean_final")
|
178 |
+
model = AutoModelForCausalLM.from_pretrained("FlawedLLM/Bhashini_gemma_merged4bit_clean_final")
|
179 |
# alpaca_prompt = You MUST copy from above!
|
180 |
@spaces.GPU(duration=300)
|
181 |
def chunk_it(input_command, item_list):
|