Danial7 commited on
Commit
658a9ba
·
verified ·
1 Parent(s): d707b82

Update utils/suggestions.py

Browse files
Files changed (1) hide show
  1. utils/suggestions.py +24 -53
utils/suggestions.py CHANGED
@@ -1,60 +1,31 @@
1
- from transformers import AutoModelForCausalLM, AutoTokenizer
2
- import torch
3
 
4
- # Load ungated Phi-2 model
5
- model_name = "microsoft/phi-2"
6
- tokenizer = AutoTokenizer.from_pretrained(model_name)
7
- model = AutoModelForCausalLM.from_pretrained(
8
- model_name,
9
- torch_dtype=torch.float32
10
- )
11
- model.eval()
12
 
13
- def call_llm(prompt):
14
- inputs = tokenizer(prompt, return_tensors="pt", truncation=True)
15
- with torch.no_grad():
16
- outputs = model.generate(
17
- inputs["input_ids"],
18
- max_new_tokens=250,
19
- do_sample=True,
20
- temperature=0.7,
21
- top_k=50
22
- )
23
- return tokenizer.decode(outputs[0], skip_special_tokens=True)
24
 
25
- def get_certification_suggestions(cv_text):
26
- prompt = f"""You are a helpful career assistant. Analyze the following CV content and suggest relevant certifications to improve the candidate's chances of getting international jobs.
 
 
 
 
27
 
28
- CV:
29
- {cv_text}
 
30
 
31
- List the top 5 certifications with short descriptions.
32
- """
33
- response = call_llm(prompt)
34
- return response.strip()
35
 
36
- def get_higher_education_suggestions(cv_text):
37
- prompt = f"""You are a career coach. Based on the following CV, suggest 3 higher education degrees or programs that would significantly improve the candidate's job prospects internationally. Include degree names and reasons.
 
38
 
39
- CV:
40
- {cv_text}
41
- """
42
- response = call_llm(prompt)
43
- return response.strip()
44
-
45
- def get_visa_recommendations(cv_text):
46
- prompt = f"""You are a global career visa advisor. Based on the following CV text, suggest 3 countries where the candidate has a high chance of qualifying for a work visa. Mention the type of visa, eligibility reasons, and links if possible.
47
-
48
- CV:
49
- {cv_text}
50
- """
51
- response = call_llm(prompt)
52
- return response.strip()
53
-
54
- def get_career_advice(cv_text):
55
- prompt = f"""You are a professional career counselor. Analyze the following CV text and give personalized career advice. Mention areas of improvement, potential career paths, and tips for international job hunting.
56
-
57
- CV:
58
- {cv_text}
59
- """
60
- return call_llm(prompt).strip()
 
1
+ import pandas as pd
2
+ import os
3
 
4
+ BASE_DIR = os.path.join(os.path.dirname(__file__), "..", "csvs")
 
 
 
 
 
 
 
5
 
6
+ def load_csv(filename):
7
+ path = os.path.join(BASE_DIR, filename)
8
+ return pd.read_csv(path)
 
 
 
 
 
 
 
 
9
 
10
+ def match_field(field, df):
11
+ field = field.strip().lower()
12
+ match = df[df['field'].str.lower().str.contains(field)]
13
+ if not match.empty:
14
+ return match['suggestion'].tolist()
15
+ return ["No specific suggestions found for this field."]
16
 
17
+ def get_certification_suggestions(field):
18
+ df = load_csv("certifications.csv")
19
+ return match_field(field, df)
20
 
21
+ def get_higher_education_suggestions(field):
22
+ df = load_csv("education.csv")
23
+ return match_field(field, df)
 
24
 
25
+ def get_visa_recommendations(field):
26
+ df = load_csv("visa.csv")
27
+ return match_field(field, df)
28
 
29
+ def get_career_advice(field):
30
+ df = load_csv("career_advice.csv")
31
+ return match_field(field, df)