Spaces:
Build error
Build error
token
Browse files
app.py
CHANGED
|
@@ -13,28 +13,23 @@ huggingface_token = os.getenv('HUGGINGFACE_TOKEN')
|
|
| 13 |
if not huggingface_token:
|
| 14 |
raise Exception("Hugging Face token not found. Please set it as an environment variable 'HUGGINGFACE_TOKEN'.")
|
| 15 |
|
| 16 |
-
# Define cache directory
|
| 17 |
-
cache_dir = "./cache"
|
| 18 |
-
|
| 19 |
# Load the base model without quantization configuration
|
| 20 |
base_model = AutoModelForCausalLM.from_pretrained(
|
| 21 |
base_model_id,
|
| 22 |
trust_remote_code=True,
|
| 23 |
-
token=huggingface_token
|
| 24 |
-
|
| 25 |
-
)
|
| 26 |
|
| 27 |
# Load the tokenizer
|
| 28 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 29 |
base_model_id,
|
| 30 |
add_bos_token=True,
|
| 31 |
trust_remote_code=True,
|
| 32 |
-
token=huggingface_token
|
| 33 |
-
cache_dir=cache_dir # Specify cache directory
|
| 34 |
)
|
| 35 |
|
| 36 |
-
# Load the fine-tuned model
|
| 37 |
-
ft_model = PeftModel.from_pretrained(base_model, "checkpoint-2800"
|
| 38 |
|
| 39 |
def formatting_func(job_description):
|
| 40 |
text = f"### The job description: {job_description}\n ### The skills: "
|
|
@@ -66,4 +61,4 @@ inputs = gr.Textbox(lines=10, label="Job description:", placeholder="Enter or pa
|
|
| 66 |
outputs = gr.Textbox(label="Required skills:", placeholder="The required skills will be displayed here...")
|
| 67 |
|
| 68 |
gr.Interface(fn=generate_skills, inputs=inputs, outputs=outputs, title="Job Skills Analysis",
|
| 69 |
-
description="Paste the job description in the text box below and the model will show the required skills for candidates.").launch()
|
|
|
|
| 13 |
if not huggingface_token:
|
| 14 |
raise Exception("Hugging Face token not found. Please set it as an environment variable 'HUGGINGFACE_TOKEN'.")
|
| 15 |
|
|
|
|
|
|
|
|
|
|
| 16 |
# Load the base model without quantization configuration
|
| 17 |
base_model = AutoModelForCausalLM.from_pretrained(
|
| 18 |
base_model_id,
|
| 19 |
trust_remote_code=True,
|
| 20 |
+
token=huggingface_token # Use the token parameter
|
| 21 |
+
).to("cuda") # Move model to CUDA
|
|
|
|
| 22 |
|
| 23 |
# Load the tokenizer
|
| 24 |
tokenizer = AutoTokenizer.from_pretrained(
|
| 25 |
base_model_id,
|
| 26 |
add_bos_token=True,
|
| 27 |
trust_remote_code=True,
|
| 28 |
+
token=huggingface_token
|
|
|
|
| 29 |
)
|
| 30 |
|
| 31 |
+
# Load the fine-tuned model and move to CUDA
|
| 32 |
+
ft_model = PeftModel.from_pretrained(base_model, "checkpoint-2800").to("cuda") # Move model to CUDA
|
| 33 |
|
| 34 |
def formatting_func(job_description):
|
| 35 |
text = f"### The job description: {job_description}\n ### The skills: "
|
|
|
|
| 61 |
outputs = gr.Textbox(label="Required skills:", placeholder="The required skills will be displayed here...")
|
| 62 |
|
| 63 |
gr.Interface(fn=generate_skills, inputs=inputs, outputs=outputs, title="Job Skills Analysis",
|
| 64 |
+
description="Paste the job description in the text box below and the model will show the required skills for candidates.").launch()
|