webcodelab commited on
Commit
b86ec7b
·
verified ·
1 Parent(s): 3ddb736

Update app/ranker.py

Browse files
Files changed (1) hide show
  1. app/ranker.py +7 -1
app/ranker.py CHANGED
@@ -1,9 +1,15 @@
1
  # utils/ranker.py
 
2
  from sentence_transformers import SentenceTransformer, util
3
  from .utils import extract_text_from_pdf
4
 
 
 
 
 
 
 
5
  model = SentenceTransformer('paraphrase-MiniLM-L6-v2')
6
- # You can load this once globally
7
 
8
  def rank_resumes_by_semantic_similarity(resume_files, job_description):
9
  resume_texts = [extract_text_from_pdf(f) for f in resume_files]
 
1
  # utils/ranker.py
2
+ import os
3
  from sentence_transformers import SentenceTransformer, util
4
  from .utils import extract_text_from_pdf
5
 
6
+ # Set safe cache directories for Hugging Face models (especially for read-only environments like Hugging Face Spaces)
7
+ os.environ["HF_HOME"] = "/tmp/hf"
8
+ os.environ["TRANSFORMERS_CACHE"] = "/tmp/hf"
9
+ os.environ["SENTENCE_TRANSFORMERS_HOME"] = "/tmp/hf"
10
+
11
+ # Load the model globally
12
  model = SentenceTransformer('paraphrase-MiniLM-L6-v2')
 
13
 
14
  def rank_resumes_by_semantic_similarity(resume_files, job_description):
15
  resume_texts = [extract_text_from_pdf(f) for f in resume_files]