root
commited on
Commit
·
c0d9b94
1
Parent(s):
86dad54
ss
Browse files- app.py +5 -28
- explanation_generator.py +0 -19
- requirements.txt +1 -1
app.py
CHANGED
@@ -9,35 +9,15 @@ import os
|
|
9 |
import tempfile
|
10 |
import base64
|
11 |
from rank_bm25 import BM25Okapi
|
|
|
|
|
|
|
|
|
12 |
import re
|
13 |
import io
|
14 |
import PyPDF2
|
15 |
from docx import Document
|
16 |
import csv
|
17 |
-
|
18 |
-
# Fix for Replicate issue - must be before model imports
|
19 |
-
import torch
|
20 |
-
try:
|
21 |
-
from einops.layers.torch import Replicate
|
22 |
-
except ImportError:
|
23 |
-
# Define our own Replicate class if not available
|
24 |
-
class Replicate(torch.nn.Module):
|
25 |
-
def __init__(self, *args, **kwargs):
|
26 |
-
super().__init__()
|
27 |
-
def forward(self, x):
|
28 |
-
return x
|
29 |
-
|
30 |
-
# Make sure Replicate is available in the right module
|
31 |
-
import sys
|
32 |
-
import einops.layers.torch
|
33 |
-
einops.layers.torch.Replicate = Replicate
|
34 |
-
sys.modules['einops.layers.torch'].Replicate = Replicate
|
35 |
-
|
36 |
-
# Now import models
|
37 |
-
from transformers import AutoModel, AutoTokenizer
|
38 |
-
from sentence_transformers import SentenceTransformer
|
39 |
-
from nltk.tokenize import word_tokenize, sent_tokenize
|
40 |
-
from tqdm import tqdm
|
41 |
from explanation_generator import ExplanationGenerator
|
42 |
|
43 |
# Download NLTK resources
|
@@ -386,11 +366,8 @@ class ResumeScreener:
|
|
386 |
bm25_scores = self.calculate_bm25_scores(resume_texts, job_description)
|
387 |
|
388 |
# Normalize BM25 scores
|
389 |
-
if
|
390 |
bm25_scores = [score / max(bm25_scores) for score in bm25_scores]
|
391 |
-
else:
|
392 |
-
# If BM25 scores are empty or all zero, use neutral values
|
393 |
-
bm25_scores = [0.5] * len(resume_texts)
|
394 |
|
395 |
# Calculate hybrid scores
|
396 |
keyword_weight = 1.0 - semantic_weight
|
|
|
9 |
import tempfile
|
10 |
import base64
|
11 |
from rank_bm25 import BM25Okapi
|
12 |
+
from transformers import AutoModel, AutoTokenizer
|
13 |
+
from sentence_transformers import SentenceTransformer
|
14 |
+
from nltk.tokenize import word_tokenize, sent_tokenize
|
15 |
+
from tqdm import tqdm
|
16 |
import re
|
17 |
import io
|
18 |
import PyPDF2
|
19 |
from docx import Document
|
20 |
import csv
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
from explanation_generator import ExplanationGenerator
|
22 |
|
23 |
# Download NLTK resources
|
|
|
366 |
bm25_scores = self.calculate_bm25_scores(resume_texts, job_description)
|
367 |
|
368 |
# Normalize BM25 scores
|
369 |
+
if max(bm25_scores) > 0:
|
370 |
bm25_scores = [score / max(bm25_scores) for score in bm25_scores]
|
|
|
|
|
|
|
371 |
|
372 |
# Calculate hybrid scores
|
373 |
keyword_weight = 1.0 - semantic_weight
|
explanation_generator.py
CHANGED
@@ -6,28 +6,9 @@ using the QwQ-32B model from Hugging Face.
|
|
6 |
"""
|
7 |
|
8 |
import torch
|
9 |
-
# Fix for Replicate issue - must be before model imports
|
10 |
-
try:
|
11 |
-
from einops.layers.torch import Replicate
|
12 |
-
except ImportError:
|
13 |
-
# Define our own Replicate class if not available
|
14 |
-
class Replicate(torch.nn.Module):
|
15 |
-
def __init__(self, *args, **kwargs):
|
16 |
-
super().__init__()
|
17 |
-
def forward(self, x):
|
18 |
-
return x
|
19 |
-
|
20 |
-
# Make sure Replicate is available in the right module
|
21 |
-
import sys
|
22 |
-
import einops.layers.torch
|
23 |
-
einops.layers.torch.Replicate = Replicate
|
24 |
-
sys.modules['einops.layers.torch'].Replicate = Replicate
|
25 |
-
|
26 |
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
|
27 |
import os
|
28 |
import re
|
29 |
-
from einops.layers.torch import Rearrange, Reduce
|
30 |
-
from einops import rearrange, reduce, repeat
|
31 |
|
32 |
# Load QwQ model at initialization time
|
33 |
print("Loading Qwen/QwQ-32B model with 4-bit quantization...")
|
|
|
6 |
"""
|
7 |
|
8 |
import torch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
|
10 |
import os
|
11 |
import re
|
|
|
|
|
12 |
|
13 |
# Load QwQ model at initialization time
|
14 |
print("Loading Qwen/QwQ-32B model with 4-bit quantization...")
|
requirements.txt
CHANGED
@@ -15,6 +15,6 @@ pandas==2.1.3
|
|
15 |
numpy==1.24.3
|
16 |
tqdm==4.66.1
|
17 |
huggingface-hub>=0.30.0,<1.0
|
18 |
-
einops
|
19 |
bitsandbytes>=0.41.0
|
20 |
accelerate>=0.23.0
|
|
|
15 |
numpy==1.24.3
|
16 |
tqdm==4.66.1
|
17 |
huggingface-hub>=0.30.0,<1.0
|
18 |
+
einops==0.5.0
|
19 |
bitsandbytes>=0.41.0
|
20 |
accelerate>=0.23.0
|