Spaces:
Build error
Build error
token
Browse files
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import os
|
| 2 |
import torch
|
| 3 |
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
| 4 |
import gradio as gr
|
|
@@ -31,7 +31,7 @@ base_model = AutoModelForCausalLM.from_pretrained(
|
|
| 31 |
trust_remote_code=True,
|
| 32 |
token=huggingface_token, # Use the token parameter
|
| 33 |
cache_dir=cache_dir # Specify cache directory
|
| 34 |
-
)
|
| 35 |
|
| 36 |
# Load the tokenizer
|
| 37 |
tokenizer = AutoTokenizer.from_pretrained(
|
|
@@ -43,7 +43,7 @@ tokenizer = AutoTokenizer.from_pretrained(
|
|
| 43 |
)
|
| 44 |
|
| 45 |
# Load the fine-tuned model
|
| 46 |
-
ft_model = PeftModel.from_pretrained(base_model, "checkpoint-2800", cache_dir=cache_dir)
|
| 47 |
|
| 48 |
def formatting_func(job_description):
|
| 49 |
text = f"### The job description: {job_description}\n ### The skills: "
|
|
@@ -52,7 +52,7 @@ def formatting_func(job_description):
|
|
| 52 |
@spaces.GPU # Decorate the function to ensure it uses GPU
|
| 53 |
def generate_skills(job_description):
|
| 54 |
formatted_text = formatting_func(job_description)
|
| 55 |
-
model_input = tokenizer(formatted_text, return_tensors="pt").to("cuda") #
|
| 56 |
|
| 57 |
ft_model.eval()
|
| 58 |
with torch.no_grad():
|
|
|
|
| 1 |
+
import os
|
| 2 |
import torch
|
| 3 |
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
|
| 4 |
import gradio as gr
|
|
|
|
| 31 |
trust_remote_code=True,
|
| 32 |
token=huggingface_token, # Use the token parameter
|
| 33 |
cache_dir=cache_dir # Specify cache directory
|
| 34 |
+
)
|
| 35 |
|
| 36 |
# Load the tokenizer
|
| 37 |
tokenizer = AutoTokenizer.from_pretrained(
|
|
|
|
| 43 |
)
|
| 44 |
|
| 45 |
# Load the fine-tuned model
|
| 46 |
+
ft_model = PeftModel.from_pretrained(base_model, "checkpoint-2800", cache_dir=cache_dir)
|
| 47 |
|
| 48 |
def formatting_func(job_description):
|
| 49 |
text = f"### The job description: {job_description}\n ### The skills: "
|
|
|
|
| 52 |
@spaces.GPU # Decorate the function to ensure it uses GPU
|
| 53 |
def generate_skills(job_description):
|
| 54 |
formatted_text = formatting_func(job_description)
|
| 55 |
+
model_input = tokenizer(formatted_text, return_tensors="pt").to("cuda") # Ensure input is on CUDA
|
| 56 |
|
| 57 |
ft_model.eval()
|
| 58 |
with torch.no_grad():
|