Spaces:
Sleeping
Sleeping
Update utils.py
Browse files
utils.py
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
|
|
| 1 |
import spacy
|
|
|
|
| 2 |
import fitz # PyMuPDF
|
| 3 |
import re
|
| 4 |
from transformers import pipeline
|
| 5 |
|
| 6 |
def load_models():
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
llm = pipeline("text-generation", model="openai-community/gpt2")
|
| 9 |
return nlp, llm
|
| 10 |
|
|
@@ -37,4 +44,4 @@ def generate_career_insights(parsed, llm, suggestion_type="roadmap"):
|
|
| 37 |
"counselor": f"Act like a career counselor. Give personalized advice to this candidate: Skills={parsed['skills']} Education={parsed['education']}"
|
| 38 |
}
|
| 39 |
res = llm(prompt_map[suggestion_type], max_length=512, do_sample=True, temperature=0.7)
|
| 40 |
-
return res[0]['generated_text']
|
|
|
|
| 1 |
+
# utils.py
|
| 2 |
import spacy
|
| 3 |
+
from spacy.cli import download
|
| 4 |
import fitz # PyMuPDF
|
| 5 |
import re
|
| 6 |
from transformers import pipeline
|
| 7 |
|
| 8 |
def load_models():
|
| 9 |
+
try:
|
| 10 |
+
nlp = spacy.load("en_core_web_sm")
|
| 11 |
+
except OSError:
|
| 12 |
+
download("en_core_web_sm")
|
| 13 |
+
nlp = spacy.load("en_core_web_sm")
|
| 14 |
+
|
| 15 |
llm = pipeline("text-generation", model="openai-community/gpt2")
|
| 16 |
return nlp, llm
|
| 17 |
|
|
|
|
| 44 |
"counselor": f"Act like a career counselor. Give personalized advice to this candidate: Skills={parsed['skills']} Education={parsed['education']}"
|
| 45 |
}
|
| 46 |
res = llm(prompt_map[suggestion_type], max_length=512, do_sample=True, temperature=0.7)
|
| 47 |
+
return res[0]['generated_text']
|