File size: 1,728 Bytes
a43767a
 
 
 
 
 
 
516b7e0
a43767a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
916a750
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
import gradio as gr
import pandas as pd
import numpy as np
from sentence_transformers import SentenceTransformer
from sklearn.metrics.pairwise import cosine_similarity

# טען את הדאטה והמודל
df = pd.read_parquet("data/train-00000-of-00001.parquet")
model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")

# הפונקציה שמריצה את ההתאמה
def recommend_jobs(user_input):
    if not user_input.strip():
        return "Please enter something!", "", "", ""

    user_embedding = model.encode([user_input])
    descriptions = df["career_goal"].tolist()
    embeddings = model.encode(descriptions)
    scores = cosine_similarity(user_embedding, embeddings)[0]

    top_indices = np.argsort(scores)[-3:][::-1]
    results = []
    for i in top_indices:
        name = df.iloc[i]["name"]
        occupation = df.iloc[i]["occupation"]
        match_score = round(scores[i]*100, 2)
        results.append(f"{name} — {occupation} (match: {match_score}%)")

    # חיזוי "מקצוע גנרי" חדש (סתם דוגמה פשוטה)
    generated = "Career suggestion: " + df.iloc[top_indices[0]]["occupation"]
    return results[0], results[1], results[2], generated

# בניית ממשק גרפייו
demo = gr.Interface(
    fn=recommend_jobs,
    inputs=gr.Textbox(lines=3, placeholder="Describe your goals, dreams, passions..."),
    outputs=[
        gr.Textbox(label="Top match"),
        gr.Textbox(label="Second match"),
        gr.Textbox(label="Third match"),
        gr.Textbox(label="Generated suggestion")
    ],
    title="Career Matcher AI",
    description="Write about your career goals and get matched with similar people and occupations!"
)

demo.launch(share=True)