Commit
·
91ff4e5
1
Parent(s):
23e9332
Added optimal text generation params.
Browse files- test-job-app.py +7 -6
test-job-app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
3 |
import torch
|
4 |
|
5 |
# Load the SmolLM model and tokenizer
|
@@ -10,7 +11,7 @@ tokenizer = AutoTokenizer.from_pretrained(model_name)
|
|
10 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
11 |
model.to(device)
|
12 |
|
13 |
-
def
|
14 |
# System Prompt and job description
|
15 |
prompt = f"""<|im_start|>system
|
16 |
{system_prompt}<|im_end|>
|
@@ -19,7 +20,7 @@ def smol_lm_process(job_description, system_prompt):
|
|
19 |
<|im_start|>assistant
|
20 |
"""
|
21 |
inputs = tokenizer(prompt, return_tensors="pt").to(device)
|
22 |
-
output = model.generate(**inputs, max_new_tokens=512)
|
23 |
response = tokenizer.decode(output[0], skip_special_tokens=False)
|
24 |
# Extract the assistant's response
|
25 |
start_idx = response.find("<|im_start|>assistant")
|
@@ -29,12 +30,12 @@ def smol_lm_process(job_description, system_prompt):
|
|
29 |
|
30 |
def process_job_description(company_name, company_url, job_description):
|
31 |
# Step 2: Extract key qualifications, skills, and requirements
|
32 |
-
system_prompt_requirements = "Extract key qualifications, skills, and requirements from this job description. Output as bullet points. Remove benefits/salary and fluff. ONLY INCLUDE INFORMATION THAT TELLS THE USER WHAT SKILLS THE EMPLOYER SEEKS."
|
33 |
-
role_requirements =
|
34 |
|
35 |
# Step 3: Create a concise summary of the job description
|
36 |
-
system_prompt_summary = "Create a concise 150-200 word summary of this job description. Remove company bragging and
|
37 |
-
clean_job_description =
|
38 |
|
39 |
return {
|
40 |
"Company Name": company_name,
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
+
from smolagents import ToolCallingAgent
|
4 |
import torch
|
5 |
|
6 |
# Load the SmolLM model and tokenizer
|
|
|
11 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
12 |
model.to(device)
|
13 |
|
14 |
+
def smol_lm_jd_process(job_description, system_prompt):
|
15 |
# System Prompt and job description
|
16 |
prompt = f"""<|im_start|>system
|
17 |
{system_prompt}<|im_end|>
|
|
|
20 |
<|im_start|>assistant
|
21 |
"""
|
22 |
inputs = tokenizer(prompt, return_tensors="pt").to(device)
|
23 |
+
output = model.generate(**inputs, max_new_tokens=512, do_sample=True, temperature=0.6, top_k=40, top_p=0.9, repetition_penalty=1.1)
|
24 |
response = tokenizer.decode(output[0], skip_special_tokens=False)
|
25 |
# Extract the assistant's response
|
26 |
start_idx = response.find("<|im_start|>assistant")
|
|
|
30 |
|
31 |
def process_job_description(company_name, company_url, job_description):
|
32 |
# Step 2: Extract key qualifications, skills, and requirements
|
33 |
+
system_prompt_requirements = "Extract key qualifications, skills, and requirements from this job description. Output as bullet points. Remove benefits/salary, bragging about the company, and other fluff not relevant to the skills, qualifications, and job requirements. ONLY INCLUDE INFORMATION THAT TELLS THE USER WHAT SKILLS THE EMPLOYER SEEKS."
|
34 |
+
role_requirements = smol_lm_jd_process(job_description, system_prompt_requirements)
|
35 |
|
36 |
# Step 3: Create a concise summary of the job description
|
37 |
+
system_prompt_summary = "Create a concise 150-200 word summary of this job description. Remove company bragging bragging about the company, and other fluff not relevant to the position and what is desired from the candidate. FOCUS ON ASPECTS THAT POINT THE USER IN WHAT THE EMPLOYER WANTS FROM A CANDIDATE IN TERMS OF SKILLS, ACCOMPLISHMENTS, AND SUCH"
|
38 |
+
clean_job_description = smol_lm_jd_process(job_description, system_prompt_summary)
|
39 |
|
40 |
return {
|
41 |
"Company Name": company_name,
|