CR7CAD commited on
Commit
ca31f44
Β·
verified Β·
1 Parent(s): 11cb389

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +75 -54
app.py CHANGED
@@ -12,7 +12,7 @@ from transformers import pipeline, AutoTokenizer, AutoModelForSeq2SeqLM
12
 
13
  # Set page title and hide sidebar
14
  st.set_page_config(
15
- page_title="Resume Analyzer and Company Suitability Checker",
16
  initial_sidebar_state="collapsed"
17
  )
18
 
@@ -24,6 +24,9 @@ st.markdown("""
24
  </style>
25
  """, unsafe_allow_html=True)
26
 
 
 
 
27
  #####################################
28
  # Preload Models - Optimized
29
  #####################################
@@ -177,14 +180,15 @@ def extract_skills_and_work(text):
177
  """Extract both skills and work experience at once to save processing time"""
178
  # Common skill categories - reduced keyword list for speed
179
  skill_categories = {
180
- "Programming": ["Python", "Java", "JavaScript", "HTML", "CSS", "SQL", "C++", "C#"],
181
- "Data Science": ["Machine Learning", "Data Analysis", "Statistics", "TensorFlow", "PyTorch"],
182
- "Database": ["SQL", "MySQL", "MongoDB", "Database"],
183
- "Web Development": ["React", "Angular", "Node.js", "Frontend", "Backend"],
184
- "Software Development": ["Agile", "Scrum", "Git", "DevOps", "Docker"],
185
- "Cloud": ["AWS", "Azure", "Google Cloud", "Cloud"],
186
- "Business": ["Project Management", "Business Analysis", "Leadership"],
187
- "Tools": ["Excel", "PowerPoint", "Tableau", "Power BI", "JIRA"]
 
188
  }
189
 
190
  # Work experience extraction
@@ -301,12 +305,12 @@ def summarize_resume_text(resume_text):
301
  return formatted_summary, execution_time
302
 
303
  #####################################
304
- # Function: Evaluate with TinyLlama
305
  #####################################
306
  @st.cache_data(show_spinner=False)
307
- def evaluate_with_tiny_llama(candidate_summary, company_info, _evaluator=None):
308
  """
309
- Use TinyLlama to evaluate the match between a candidate's resume and company requirements.
310
  """
311
  start_time = time.time()
312
 
@@ -314,22 +318,21 @@ def evaluate_with_tiny_llama(candidate_summary, company_info, _evaluator=None):
314
 
315
  # Format the chat prompt for TinyLlama's chat format
316
  prompt = f"""<|im_start|>system
317
- You are an expert HR recruiter. Your task is to evaluate how well a candidate's profile matches with a company's requirements. Be concise but thorough in your evaluation.
318
  <|im_end|>
319
 
320
  <|im_start|>user
321
- I need to evaluate a job candidate against company requirements. Please:
322
- 1. Analyze the match between the candidate and the position
323
- 2. Give a suitability score from 0-100
324
- 3. Provide 2-3 sentences explaining your evaluation
325
- 4. List the top 3 strengths of the candidate for this role
326
- 5. List 1-2 potential gaps if any
327
 
328
  Candidate Profile:
329
  {candidate_summary}
330
 
331
- Company Requirements:
332
- {company_info}
333
  <|im_end|>
334
 
335
  <|im_start|>assistant
@@ -361,8 +364,8 @@ Company Requirements:
361
  normalized_score = 0.5 # Default if no group was extracted
362
  else:
363
  # If no explicit score, try to infer from sentiments
364
- positive_words = ['excellent', 'perfect', 'outstanding', 'ideal', 'great']
365
- negative_words = ['poor', 'inadequate', 'insufficient', 'lacks', 'mismatch']
366
 
367
  positive_count = sum(assistant_response.lower().count(word) for word in positive_words)
368
  negative_count = sum(assistant_response.lower().count(word) for word in negative_words)
@@ -385,28 +388,25 @@ Company Requirements:
385
  #####################################
386
  # Main Streamlit Interface - with Progress Reporting
387
  #####################################
388
- st.title("Resume Analyzer and Company Suitability Checker")
389
  st.markdown(
390
  """
391
- Upload your resume file in **.docx**, **.doc**, or **.txt** format. The app performs the following tasks:
392
- 1. Extracts text from the resume.
393
- 2. Uses AI to generate a structured candidate summary with name, age, expected job industry, previous work experience, and skills.
394
- 3. Uses TinyLlama AI to evaluate the candidate's suitability for the company and provide detailed feedback.
395
  """
396
  )
397
 
 
 
 
 
398
  # File uploader
399
  uploaded_file = st.file_uploader("Upload your resume (.docx, .doc, or .txt)", type=["docx", "doc", "txt"])
400
 
401
- # Company description text area
402
- company_prompt = st.text_area(
403
- "Enter the company description or job requirements:",
404
- height=150,
405
- help="Enter a detailed description of the company culture, role requirements, and desired skills.",
406
- )
407
-
408
  # Process button with optimized flow
409
- if uploaded_file is not None and company_prompt and st.button("Analyze Resume"):
410
  # Create a placeholder for the progress bar
411
  progress_bar = st.progress(0)
412
  status_text = st.empty()
@@ -425,36 +425,57 @@ if uploaded_file is not None and company_prompt and st.button("Analyze Resume"):
425
  progress_bar.progress(75)
426
 
427
  # Display summary
428
- st.subheader("Candidate Summary")
429
  st.markdown(summary)
430
  st.info(f"Summary generated in {summarization_time:.2f} seconds")
431
 
432
- # Step 3: Evaluate with TinyLlama
433
- status_text.text("Step 3/3: Evaluating candidate with TinyLlama...")
434
- suitability_score, evaluation, evaluation_time = evaluate_with_tiny_llama(
435
- summary, company_prompt, _evaluator=models['evaluator']
436
  )
437
  progress_bar.progress(100)
438
 
439
  # Clear status messages
440
  status_text.empty()
441
 
442
- # Display suitability results
443
- st.subheader("Suitability Assessment")
444
 
445
- # Display score with appropriate color
446
- score_percent = int(suitability_score * 100)
447
- if suitability_score >= 0.85:
448
- st.success(f"**Matching Score:** {score_percent}%")
449
- elif suitability_score >= 0.70:
450
- st.success(f"**Matching Score:** {score_percent}%")
451
- elif suitability_score >= 0.50:
452
- st.warning(f"**Matching Score:** {score_percent}%")
453
  else:
454
- st.error(f"**Matching Score:** {score_percent}%")
455
 
456
  # Display the full evaluation
457
- st.markdown("### Detailed Evaluation")
458
  st.markdown(evaluation)
459
 
460
- st.info(f"Evaluation completed in {evaluation_time:.2f} seconds using TinyLlama")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  # Set page title and hide sidebar
14
  st.set_page_config(
15
+ page_title="Resume-Google Job Match Analyzer",
16
  initial_sidebar_state="collapsed"
17
  )
18
 
 
24
  </style>
25
  """, unsafe_allow_html=True)
26
 
27
+ # Pre-defined company description for Google
28
+ GOOGLE_DESCRIPTION = """Google LLC, a global leader in technology and innovation, specializes in internet services, cloud computing, artificial intelligence, and software development. As part of Alphabet Inc., Google seeks candidates with strong problem-solving skills, adaptability, and collaboration abilities. Technical roles require proficiency in programming languages such as Python, Java, C++, Go, or JavaScript, with expertise in data structures, algorithms, and system design. Additionally, skills in AI, cybersecurity, UX/UI design, and digital marketing are highly valued. Google fosters a culture of innovation, expecting candidates to demonstrate creativity, analytical thinking, and a passion for cutting-edge technology."""
29
+
30
  #####################################
31
  # Preload Models - Optimized
32
  #####################################
 
180
  """Extract both skills and work experience at once to save processing time"""
181
  # Common skill categories - reduced keyword list for speed
182
  skill_categories = {
183
+ "Programming": ["Python", "Java", "JavaScript", "HTML", "CSS", "SQL", "C++", "C#", "Go"],
184
+ "Data Science": ["Machine Learning", "Data Analysis", "Statistics", "TensorFlow", "PyTorch", "AI", "Algorithms"],
185
+ "Database": ["SQL", "MySQL", "MongoDB", "Database", "NoSQL", "PostgreSQL"],
186
+ "Web Development": ["React", "Angular", "Node.js", "Frontend", "Backend", "Full-Stack"],
187
+ "Software Development": ["Agile", "Scrum", "Git", "DevOps", "Docker", "System Design"],
188
+ "Cloud": ["AWS", "Azure", "Google Cloud", "Cloud Computing"],
189
+ "Security": ["Cybersecurity", "Network Security", "Encryption", "Security"],
190
+ "Business": ["Project Management", "Business Analysis", "Leadership", "Teamwork"],
191
+ "Design": ["UX/UI", "User Experience", "Design Thinking", "Adobe"]
192
  }
193
 
194
  # Work experience extraction
 
305
  return formatted_summary, execution_time
306
 
307
  #####################################
308
+ # Function: Evaluate Google Fit with TinyLlama
309
  #####################################
310
  @st.cache_data(show_spinner=False)
311
+ def evaluate_google_fit(candidate_summary, _evaluator=None):
312
  """
313
+ Use TinyLlama to evaluate how well the candidate matches with Google's requirements.
314
  """
315
  start_time = time.time()
316
 
 
318
 
319
  # Format the chat prompt for TinyLlama's chat format
320
  prompt = f"""<|im_start|>system
321
+ You are an expert technical recruiter at Google. Your task is to evaluate how well a candidate's profile matches with Google's hiring requirements. Be focused and specific in your evaluation.
322
  <|im_end|>
323
 
324
  <|im_start|>user
325
+ I need to evaluate if this candidate is a good fit for Google. Please:
326
+ 1. Score the candidate's fit for Google from 0-100
327
+ 2. Write a brief evaluation (2-3 sentences) explaining why they would or wouldn't be a good fit
328
+ 3. Mention 1-2 specific strengths relevant to Google
329
+ 4. Mention 1 specific area where they might need improvement to better fit Google's requirements
 
330
 
331
  Candidate Profile:
332
  {candidate_summary}
333
 
334
+ Google's Requirements:
335
+ {GOOGLE_DESCRIPTION}
336
  <|im_end|>
337
 
338
  <|im_start|>assistant
 
364
  normalized_score = 0.5 # Default if no group was extracted
365
  else:
366
  # If no explicit score, try to infer from sentiments
367
+ positive_words = ['excellent', 'perfect', 'outstanding', 'ideal', 'great', 'strong']
368
+ negative_words = ['poor', 'inadequate', 'insufficient', 'lacks', 'mismatch', 'weak']
369
 
370
  positive_count = sum(assistant_response.lower().count(word) for word in positive_words)
371
  negative_count = sum(assistant_response.lower().count(word) for word in negative_words)
 
388
  #####################################
389
  # Main Streamlit Interface - with Progress Reporting
390
  #####################################
391
+ st.title("Google Resume Match Analyzer")
392
  st.markdown(
393
  """
394
+ Upload your resume file in **.docx**, **.doc**, or **.txt** format to see how well you match with Google's hiring requirements. The app performs the following tasks:
395
+ 1. Extracts text from your resume.
396
+ 2. Uses AI to generate a structured candidate summary.
397
+ 3. Evaluates your fit for Google, providing a match score and specific feedback.
398
  """
399
  )
400
 
401
+ # Display Google's requirements
402
+ with st.expander("Google's Requirements", expanded=False):
403
+ st.write(GOOGLE_DESCRIPTION)
404
+
405
  # File uploader
406
  uploaded_file = st.file_uploader("Upload your resume (.docx, .doc, or .txt)", type=["docx", "doc", "txt"])
407
 
 
 
 
 
 
 
 
408
  # Process button with optimized flow
409
+ if uploaded_file is not None and st.button("Analyze My Google Fit"):
410
  # Create a placeholder for the progress bar
411
  progress_bar = st.progress(0)
412
  status_text = st.empty()
 
425
  progress_bar.progress(75)
426
 
427
  # Display summary
428
+ st.subheader("Your Resume Summary")
429
  st.markdown(summary)
430
  st.info(f"Summary generated in {summarization_time:.2f} seconds")
431
 
432
+ # Step 3: Evaluate Google fit
433
+ status_text.text("Step 3/3: Evaluating your fit for Google...")
434
+ fit_score, evaluation, evaluation_time = evaluate_google_fit(
435
+ summary, _evaluator=models['evaluator']
436
  )
437
  progress_bar.progress(100)
438
 
439
  # Clear status messages
440
  status_text.empty()
441
 
442
+ # Display Google fit results
443
+ st.subheader("Google Fit Assessment")
444
 
445
+ # Display score with appropriate color and emoji
446
+ score_percent = int(fit_score * 100)
447
+ if fit_score >= 0.85:
448
+ st.success(f"**Google Match Score:** {score_percent}% 🌟")
449
+ elif fit_score >= 0.70:
450
+ st.success(f"**Google Match Score:** {score_percent}% βœ…")
451
+ elif fit_score >= 0.50:
452
+ st.warning(f"**Google Match Score:** {score_percent}% ⚠️")
453
  else:
454
+ st.error(f"**Google Match Score:** {score_percent}% πŸ”")
455
 
456
  # Display the full evaluation
457
+ st.markdown("### Feedback from Google AI Recruiter")
458
  st.markdown(evaluation)
459
 
460
+ st.info(f"Evaluation completed in {evaluation_time:.2f} seconds")
461
+
462
+ # Add potential next steps based on the score
463
+ st.subheader("Recommended Next Steps")
464
+ if fit_score >= 0.80:
465
+ st.markdown("""
466
+ - Consider applying for positions at Google that match your experience
467
+ - Prepare for technical interviews by practicing algorithms and system design
468
+ - Review Google's interview process and STAR method for behavioral questions
469
+ """)
470
+ elif fit_score >= 0.60:
471
+ st.markdown("""
472
+ - Focus on strengthening the improvement areas mentioned in the evaluation
473
+ - Work on projects that demonstrate your skills in Google's key technology areas
474
+ - Consider taking additional courses in areas where Google has shown interest
475
+ """)
476
+ else:
477
+ st.markdown("""
478
+ - Build experience in areas matching Google's requirements
479
+ - Develop projects showcasing problem-solving abilities and technical skills
480
+ - Consider gaining more experience before applying, or target specific Google roles that better match your profile
481
+ """)