Add vacancy search weights
This commit is contained in:
parent
42395de6d3
commit
618a102c98
@ -5,14 +5,29 @@ from qdrant_client import QdrantClient
|
||||
from qdrant_client.models import Filter
|
||||
from vacancies.main.models import VacancyFeatures
|
||||
|
||||
client = QdrantClient(path="./embeddings")
|
||||
#client = QdrantClient(url="http://localhost:6333")
|
||||
# client = QdrantClient(path="./embeddings")
|
||||
client = QdrantClient(url="http://localhost:6333")
|
||||
|
||||
FEATURE_NAMES = [
|
||||
"employment_type", "work_format", "experience", "position_level", "industry", "tech_stack",
|
||||
"location", "salary_range", "languages", "education", "schedule", "additional_requirements"
|
||||
]
|
||||
|
||||
weights = {
|
||||
"employment_type": 2,
|
||||
"work_format": 2,
|
||||
"experience": 4,
|
||||
"position_level": 4,
|
||||
"industry": 4,
|
||||
"tech_stack": 5,
|
||||
"location": 2,
|
||||
"salary_range": 2,
|
||||
"languages": 2,
|
||||
"education": 1,
|
||||
"schedule": 1,
|
||||
"additional_requirements": 1,
|
||||
}
|
||||
|
||||
vectors_config = {
|
||||
name: models.VectorParams(size=3072, distance=models.Distance.COSINE) for name in FEATURE_NAMES
|
||||
}
|
||||
@ -90,7 +105,7 @@ def search_similarities(query_filter: Filter, cv_id: int) -> list[dict]:
|
||||
|
||||
scored = []
|
||||
for vid, feature_sims in max_similarities.items():
|
||||
total = sum(feature_sims.values())
|
||||
total = sum(feature_sims[feature] * weights.get(feature, 1) for feature in feature_sims)
|
||||
scored.append({"id": vid, "score": total})
|
||||
|
||||
scored.sort(key=lambda x: x["score"], reverse=True)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user