File size: 2,071 Bytes
ba2c4c2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.16.4
#   kernelspec:
#     display_name: Python 3 (ipykernel)
#     language: python
#     name: python3
# ---

# +
import streamlit as st
import pandas as pd
import numpy as np
import faiss
from sentence_transformers import SentenceTransformer
from huggingface_hub import hf_hub_download
import warnings
warnings.filterwarnings('ignore')

@st.cache_resource
def load_artifacts():
    repo_id = "PankhuriSharma9795/SHL_Model_Assets"

    # Load SBERT model
    model_dir = hf_hub_download(repo_id="PankhuriSharma9795/SHL_model_Asset", filename="config.json", repo_type="model")
    model = SentenceTransformer(model_dir.replace("config.json", ""))

    # Load FAISS index
    faiss_path = hf_hub_download(repo_id="PankhuriSharma9795/SHL_model_Asset", filename="faiss_index.index", repo_type="model")
    index = faiss.read_index(faiss_path)

    # Load CSV
    csv_path = hf_hub_download(repo_id="PankhuriSharma9795/SHL_model_Asset", filename="assessment_data.csv", repo_type="model")
    df = pd.read_csv(csv_path)

    return model, index, df

def recommend_assessments(profile_text, model, index, df, top_n=10):
    profile_embedding = model.encode([profile_text]).astype('float32')
    _, indices = index.search(profile_embedding, top_n)
    return df.iloc[indices[0]]

# Streamlit UI
st.title("🔍 SHL Assessment Recommender")

profile = st.text_area("✍️ Enter your job role or career aspiration:", 
                       "Looking for a leadership role in financial planning and client management")

if st.button("Get Recommendations"):
    model, index, df = load_artifacts()
    results = recommend_assessments(profile, model, index, df, top_n=10)
    st.subheader("🧠 Top 10 Matching Assessments")
    st.dataframe(results[['Assesment Name', 'cleaned_text', 'Duration', 
                          'Remote Testing Support', 'URL', 'Adaptive/IRT', 'Job Type']].reset_index(drop=True))
# -