Spaces:
Runtime error
Runtime error
Caitlin Blackmore
commited on
Commit
·
644c461
1
Parent(s):
591ae97
fix find-my-match paths
Browse files- main.py +24 -21
- requirements.txt +2 -1
- templates/find_my_match.html +3 -3
- templates/job_neighborhoods.html +0 -0
main.py
CHANGED
|
@@ -14,6 +14,7 @@ import numpy as np
|
|
| 14 |
from numpy.linalg import norm
|
| 15 |
from nltk.tokenize import SpaceTokenizer
|
| 16 |
import nltk
|
|
|
|
| 17 |
from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification
|
| 18 |
from dotenv import load_dotenv
|
| 19 |
load_dotenv()
|
|
@@ -74,19 +75,22 @@ def render_job_info(request: Request, jobtitle: str = Form(enum=[x for x in onet
|
|
| 74 |
|
| 75 |
### job neighborhoods ###
|
| 76 |
@app.get("/explore-job-neighborhoods/", response_class=HTMLResponse)
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
title =
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
-
|
| 90 |
|
| 91 |
### find my match ###
|
| 92 |
# get
|
|
@@ -122,6 +126,7 @@ def get_resume(request: Request, resume: UploadFile = File(...)):
|
|
| 122 |
def cosine(A, B):
|
| 123 |
return np.dot(A,B)/(norm(A)*norm(B))
|
| 124 |
|
|
|
|
| 125 |
embeds = coSkillEmbed(resume)
|
| 126 |
simResults = []
|
| 127 |
|
|
@@ -138,7 +143,7 @@ def get_resume(request: Request, resume: UploadFile = File(...)):
|
|
| 138 |
simResults.reset_index(drop=True, inplace=True)
|
| 139 |
for x in range(len(simResults)):
|
| 140 |
simResults.iloc[x,1] = "{:0.2f}".format(simResults.iloc[x,1])
|
| 141 |
-
|
| 142 |
# EXTRACT SKILLS FROM RESUME
|
| 143 |
def skillNER(resume):
|
| 144 |
resume = clean_my_text(resume)
|
|
@@ -150,17 +155,15 @@ def get_resume(request: Request, resume: UploadFile = File(...)):
|
|
| 150 |
resume = [word for word in SpaceTokenizer().tokenize(resume) if word not in stops]
|
| 151 |
resume = [word for word in resume if ")" not in word]
|
| 152 |
resume = [word for word in resume if "(" not in word]
|
| 153 |
-
|
| 154 |
labels = []
|
| 155 |
for i in range(len(resume)):
|
| 156 |
classification = classifier(resume[i])[0]['label']
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
labels_dict = dict(zip(resume, labels))
|
| 162 |
return labels_dict
|
| 163 |
-
|
| 164 |
-
skills=skillNER(resume)
|
| 165 |
-
|
| 166 |
return templates.TemplateResponse('find_my_match.html', context={'request': request, 'resume': resume, 'skills': skills, 'simResults': simResults})
|
|
|
|
| 14 |
from numpy.linalg import norm
|
| 15 |
from nltk.tokenize import SpaceTokenizer
|
| 16 |
import nltk
|
| 17 |
+
import plotly.express as px
|
| 18 |
from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification
|
| 19 |
from dotenv import load_dotenv
|
| 20 |
load_dotenv()
|
|
|
|
| 75 |
|
| 76 |
### job neighborhoods ###
|
| 77 |
@app.get("/explore-job-neighborhoods/", response_class=HTMLResponse)
|
| 78 |
+
def render_job_neighborhoods(request: Request):
|
| 79 |
+
if 'job_neighborhoods.html' in os.listdir('templates'):
|
| 80 |
+
return templates.TemplateResponse('job_neighborhoods.html', context={'request': request})
|
| 81 |
+
else:
|
| 82 |
+
def format_title(logo, title, subtitle, title_font_size = 28, subtitle_font_size=14):
|
| 83 |
+
logo = f'<a href="/" target="_self">{logo}</a>'
|
| 84 |
+
subtitle = f'<span style="font-size: {subtitle_font_size}px;">{subtitle}</span>'
|
| 85 |
+
title = f'<span style="font-size: {title_font_size}px;">{title}</span>'
|
| 86 |
+
return f'{logo}{title}<br>{subtitle}'
|
| 87 |
+
|
| 88 |
+
fig = px.scatter(coheredat, x = 'longitude', y = 'latitude', color = 'Category', hover_data = ['Category', 'Title'],
|
| 89 |
+
title=format_title("Pathfinder", " Job Neighborhoods: Explore the Map!", "(Generated using Co-here AI's LLM & ONET's Task Statements)"))
|
| 90 |
+
fig['layout'].update(height=1000, width=1500, font=dict(family='Courier New, monospace', color='black'))
|
| 91 |
+
fig.write_html('templates/job_neighborhoods.html')
|
| 92 |
|
| 93 |
+
return templates.TemplateResponse('job_neighborhoods.html', context={'request': request})
|
| 94 |
|
| 95 |
### find my match ###
|
| 96 |
# get
|
|
|
|
| 126 |
def cosine(A, B):
|
| 127 |
return np.dot(A,B)/(norm(A)*norm(B))
|
| 128 |
|
| 129 |
+
# GET RESUME EMBEDDINGS AND JOB SIMILARITY SCORES
|
| 130 |
embeds = coSkillEmbed(resume)
|
| 131 |
simResults = []
|
| 132 |
|
|
|
|
| 143 |
simResults.reset_index(drop=True, inplace=True)
|
| 144 |
for x in range(len(simResults)):
|
| 145 |
simResults.iloc[x,1] = "{:0.2f}".format(simResults.iloc[x,1])
|
| 146 |
+
|
| 147 |
# EXTRACT SKILLS FROM RESUME
|
| 148 |
def skillNER(resume):
|
| 149 |
resume = clean_my_text(resume)
|
|
|
|
| 155 |
resume = [word for word in SpaceTokenizer().tokenize(resume) if word not in stops]
|
| 156 |
resume = [word for word in resume if ")" not in word]
|
| 157 |
resume = [word for word in resume if "(" not in word]
|
| 158 |
+
|
| 159 |
labels = []
|
| 160 |
for i in range(len(resume)):
|
| 161 |
classification = classifier(resume[i])[0]['label']
|
| 162 |
+
if classification == 'LABEL_1':
|
| 163 |
+
labels.append("Skill")
|
| 164 |
+
else:
|
| 165 |
+
labels.append("Not Skill")
|
| 166 |
labels_dict = dict(zip(resume, labels))
|
| 167 |
return labels_dict
|
| 168 |
+
skills = skillNER(resume)
|
|
|
|
|
|
|
| 169 |
return templates.TemplateResponse('find_my_match.html', context={'request': request, 'resume': resume, 'skills': skills, 'simResults': simResults})
|
requirements.txt
CHANGED
|
@@ -15,4 +15,5 @@ cohere==3.1.5
|
|
| 15 |
python-dotenv==0.21.1
|
| 16 |
transformers==4.25.1
|
| 17 |
torch==1.13.1
|
| 18 |
-
accelerate==0.16.0
|
|
|
|
|
|
| 15 |
python-dotenv==0.21.1
|
| 16 |
transformers==4.25.1
|
| 17 |
torch==1.13.1
|
| 18 |
+
accelerate==0.16.0
|
| 19 |
+
plotly-express==0.4.1
|
templates/find_my_match.html
CHANGED
|
@@ -5,12 +5,12 @@
|
|
| 5 |
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 7 |
<title>Dashboard</title>
|
| 8 |
-
<link rel="stylesheet" href="
|
| 9 |
</head>
|
| 10 |
<body>
|
| 11 |
<header class="navbar">
|
| 12 |
<div class="navbar__brand">
|
| 13 |
-
<img src="
|
| 14 |
<a href="/" class="navbar__logo">Pathfinder</a>
|
| 15 |
</div>
|
| 16 |
<ul class="navbar__navigation">
|
|
@@ -21,7 +21,7 @@
|
|
| 21 |
<main class="main">
|
| 22 |
<h1 class="pagetitle">Find my Perfect Match!</h1>
|
| 23 |
<h2 class="pagesubtitle">We'll help you find the perfect job for you! Upload your resume, CV, or cover letter to get started!</h2>
|
| 24 |
-
<form action
|
| 25 |
<input type="file" name="resume" id="resume" class="upload__file">
|
| 26 |
<button type="submit" class="form__submit">Submit</button>
|
| 27 |
<p class="alert">Note: We will not store or use your personal information for anything other than the stated purpose.</p>
|
|
|
|
| 5 |
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
| 6 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 7 |
<title>Dashboard</title>
|
| 8 |
+
<link rel="stylesheet" href="/static/styles.css">
|
| 9 |
</head>
|
| 10 |
<body>
|
| 11 |
<header class="navbar">
|
| 12 |
<div class="navbar__brand">
|
| 13 |
+
<img src="/static/PF.png" class="navbar__logo" alt="Pathfinder logo" />
|
| 14 |
<a href="/" class="navbar__logo">Pathfinder</a>
|
| 15 |
</div>
|
| 16 |
<ul class="navbar__navigation">
|
|
|
|
| 21 |
<main class="main">
|
| 22 |
<h1 class="pagetitle">Find my Perfect Match!</h1>
|
| 23 |
<h2 class="pagesubtitle">We'll help you find the perfect job for you! Upload your resume, CV, or cover letter to get started!</h2>
|
| 24 |
+
<form action="" class="upload" method="POST" enctype="multipart/form-data">
|
| 25 |
<input type="file" name="resume" id="resume" class="upload__file">
|
| 26 |
<button type="submit" class="form__submit">Submit</button>
|
| 27 |
<p class="alert">Note: We will not store or use your personal information for anything other than the stated purpose.</p>
|
templates/job_neighborhoods.html
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|