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)