Spaces:
Sleeping
Sleeping
Commit
·
8af9829
1
Parent(s):
5948801
updated app.py
Browse files
app.py
CHANGED
|
@@ -40,6 +40,15 @@ if HF_TOKEN is None:
|
|
| 40 |
raise ValueError("HF_TOKEN is not set. Check your .env file.")
|
| 41 |
login(HF_TOKEN, add_to_git_credential=True)
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
def process_files(files):
|
| 44 |
os.makedirs(folder, exist_ok=True)
|
| 45 |
|
|
@@ -83,7 +92,7 @@ def process_files(files):
|
|
| 83 |
# HF Pipeline
|
| 84 |
hf_pipeline = pipeline(
|
| 85 |
"text-generation",
|
| 86 |
-
model=
|
| 87 |
torch_dtype="auto",
|
| 88 |
device_map="auto", # Uses GPU if available
|
| 89 |
max_new_tokens=256, # Adjust output length
|
|
|
|
| 40 |
raise ValueError("HF_TOKEN is not set. Check your .env file.")
|
| 41 |
login(HF_TOKEN, add_to_git_credential=True)
|
| 42 |
|
| 43 |
+
model_name = "mistralai/Mistral-7B-Instruct-v0.1"
|
| 44 |
+
|
| 45 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 46 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 47 |
+
model_name,
|
| 48 |
+
torch_dtype=torch.float16, # Use float16 for efficiency
|
| 49 |
+
device_map="auto" # Automatically selects CPU/GPU
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
def process_files(files):
|
| 53 |
os.makedirs(folder, exist_ok=True)
|
| 54 |
|
|
|
|
| 92 |
# HF Pipeline
|
| 93 |
hf_pipeline = pipeline(
|
| 94 |
"text-generation",
|
| 95 |
+
model=model_name,
|
| 96 |
torch_dtype="auto",
|
| 97 |
device_map="auto", # Uses GPU if available
|
| 98 |
max_new_tokens=256, # Adjust output length
|