Spaces:
Sleeping
Sleeping
token
Browse files
app.py
CHANGED
|
@@ -22,7 +22,7 @@ base_model = AutoModelForCausalLM.from_pretrained(
|
|
| 22 |
trust_remote_code=True,
|
| 23 |
token=huggingface_token, # Use the token parameter
|
| 24 |
cache_dir=cache_dir # Specify cache directory
|
| 25 |
-
)
|
| 26 |
|
| 27 |
# Load the tokenizer
|
| 28 |
tokenizer = AutoTokenizer.from_pretrained(
|
|
@@ -34,7 +34,7 @@ tokenizer = AutoTokenizer.from_pretrained(
|
|
| 34 |
)
|
| 35 |
|
| 36 |
# Load the fine-tuned model
|
| 37 |
-
ft_model = PeftModel.from_pretrained(base_model, "checkpoint-2800", cache_dir=cache_dir)
|
| 38 |
|
| 39 |
def formatting_func(job_description):
|
| 40 |
text = f"### The job description: {job_description}\n ### The skills: "
|
|
@@ -47,6 +47,8 @@ def generate_skills(job_description):
|
|
| 47 |
|
| 48 |
ft_model.eval()
|
| 49 |
with torch.no_grad():
|
|
|
|
|
|
|
| 50 |
output_tokens = ft_model.generate(**model_input, max_new_tokens=200)[0]
|
| 51 |
generated_text = tokenizer.decode(output_tokens, skip_special_tokens=True)
|
| 52 |
|
|
|
|
| 22 |
trust_remote_code=True,
|
| 23 |
token=huggingface_token, # Use the token parameter
|
| 24 |
cache_dir=cache_dir # Specify cache directory
|
| 25 |
+
)
|
| 26 |
|
| 27 |
# Load the tokenizer
|
| 28 |
tokenizer = AutoTokenizer.from_pretrained(
|
|
|
|
| 34 |
)
|
| 35 |
|
| 36 |
# Load the fine-tuned model
|
| 37 |
+
ft_model = PeftModel.from_pretrained(base_model, "checkpoint-2800", cache_dir=cache_dir)
|
| 38 |
|
| 39 |
def formatting_func(job_description):
|
| 40 |
text = f"### The job description: {job_description}\n ### The skills: "
|
|
|
|
| 47 |
|
| 48 |
ft_model.eval()
|
| 49 |
with torch.no_grad():
|
| 50 |
+
# Move model to GPU if not already there
|
| 51 |
+
ft_model.to("cuda")
|
| 52 |
output_tokens = ft_model.generate(**model_input, max_new_tokens=200)[0]
|
| 53 |
generated_text = tokenizer.decode(output_tokens, skip_special_tokens=True)
|
| 54 |
|