Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -28,14 +28,14 @@ st.markdown("""
|
|
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
|
32 |
#####################################
|
33 |
@st.cache_resource(show_spinner=True)
|
34 |
def load_models():
|
35 |
-
"""Load models at startup
|
36 |
with st.spinner("Loading AI models... This may take a minute on first run."):
|
37 |
models = {}
|
38 |
-
# Use bart-base
|
39 |
models['summarizer'] = pipeline(
|
40 |
"summarization",
|
41 |
model="facebook/bart-base",
|
@@ -43,13 +43,11 @@ def load_models():
|
|
43 |
truncation=True
|
44 |
)
|
45 |
|
46 |
-
# Load
|
47 |
models['evaluator'] = pipeline(
|
48 |
-
"
|
49 |
-
model="
|
50 |
-
max_length=
|
51 |
-
num_beams=2,
|
52 |
-
early_stopping=True
|
53 |
)
|
54 |
|
55 |
return models
|
@@ -105,7 +103,7 @@ def extract_text_from_file(file_obj):
|
|
105 |
return text[:15000] if text else text
|
106 |
|
107 |
#####################################
|
108 |
-
# Functions for Information Extraction
|
109 |
#####################################
|
110 |
|
111 |
# Cache the extraction functions to avoid reprocessing
|
@@ -271,11 +269,11 @@ def extract_skills_and_work(text):
|
|
271 |
return skills_formatted, work_experience
|
272 |
|
273 |
#####################################
|
274 |
-
# Function: Summarize Resume Text
|
275 |
#####################################
|
276 |
def summarize_resume_text(resume_text):
|
277 |
"""
|
278 |
-
Generates a structured summary of the resume text
|
279 |
"""
|
280 |
start_time = time.time()
|
281 |
|
@@ -312,247 +310,78 @@ def summarize_resume_text(resume_text):
|
|
312 |
return formatted_summary, execution_time
|
313 |
|
314 |
#####################################
|
315 |
-
# Function:
|
316 |
#####################################
|
317 |
-
def
|
318 |
"""
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
Returns:
|
323 |
-
- overall_score: A normalized score between 0 and 1
|
324 |
-
- category_scores: A dictionary with scores for each category
|
325 |
-
- score_breakdown: A formatted string explanation of the scoring
|
326 |
-
"""
|
327 |
-
# Define categories that Google values with specific keywords
|
328 |
-
google_categories = {
|
329 |
-
"Technical Skills": {
|
330 |
-
"keywords": ["python", "java", "c++", "go", "javascript", "sql", "nosql",
|
331 |
-
"algorithms", "data structures", "system design"],
|
332 |
-
"weight": 0.35
|
333 |
-
},
|
334 |
-
"Advanced Technologies": {
|
335 |
-
"keywords": ["artificial intelligence", "machine learning", "cloud computing",
|
336 |
-
"ai", "ml", "cloud", "data science", "big data",
|
337 |
-
"tensorflow", "pytorch", "deep learning"],
|
338 |
-
"weight": 0.25
|
339 |
-
},
|
340 |
-
"Problem Solving": {
|
341 |
-
"keywords": ["problem solving", "algorithms", "analytical", "critical thinking",
|
342 |
-
"debugging", "troubleshooting", "optimization"],
|
343 |
-
"weight": 0.20
|
344 |
-
},
|
345 |
-
"Innovation & Creativity": {
|
346 |
-
"keywords": ["innovation", "creative", "creativity", "novel", "cutting-edge",
|
347 |
-
"research", "design thinking", "innovative"],
|
348 |
-
"weight": 0.10
|
349 |
-
},
|
350 |
-
"Teamwork & Leadership": {
|
351 |
-
"keywords": ["team", "leadership", "collaborate", "collaboration", "communication",
|
352 |
-
"mentoring", "lead", "coordinate", "agile", "scrum"],
|
353 |
-
"weight": 0.10
|
354 |
-
}
|
355 |
-
}
|
356 |
-
|
357 |
-
summary_lower = candidate_summary.lower()
|
358 |
-
|
359 |
-
# Calculate scores for each category
|
360 |
-
category_scores = {}
|
361 |
-
for category, details in google_categories.items():
|
362 |
-
keywords = details["keywords"]
|
363 |
-
max_possible = len(keywords) # Maximum possible matches
|
364 |
-
|
365 |
-
# Count matches (unique keywords found)
|
366 |
-
matches = sum(1 for keyword in keywords if keyword in summary_lower)
|
367 |
-
|
368 |
-
# Calculate category score (0-1 range)
|
369 |
-
if max_possible > 0:
|
370 |
-
raw_score = matches / max_possible
|
371 |
-
# Apply a curve to reward having more matches
|
372 |
-
category_scores[category] = min(1.0, raw_score * 1.5)
|
373 |
-
else:
|
374 |
-
category_scores[category] = 0
|
375 |
-
|
376 |
-
# Calculate weighted overall score
|
377 |
-
overall_score = sum(
|
378 |
-
score * google_categories[category]["weight"]
|
379 |
-
for category, score in category_scores.items()
|
380 |
-
)
|
381 |
-
|
382 |
-
# Ensure overall score is in 0-1 range
|
383 |
-
overall_score = min(1.0, max(0.0, overall_score))
|
384 |
-
|
385 |
-
# Create score breakdown explanation
|
386 |
-
score_breakdown = "**Score Breakdown by Category:**\n\n"
|
387 |
-
|
388 |
-
for category, score in category_scores.items():
|
389 |
-
percentage = int(score * 100)
|
390 |
-
weight = int(google_categories[category]["weight"] * 100)
|
391 |
-
score_breakdown += f"β’ **{category}** ({weight}% of total): {percentage}%\n"
|
392 |
-
|
393 |
-
return overall_score, category_scores, score_breakdown
|
394 |
-
|
395 |
-
#####################################
|
396 |
-
# Function: Generate Robust Feedback - Template-Based
|
397 |
-
#####################################
|
398 |
-
def generate_template_feedback(category_scores):
|
399 |
-
"""
|
400 |
-
Generate comprehensive template-based feedback without using ML model for speed.
|
401 |
"""
|
402 |
start_time = time.time()
|
403 |
|
404 |
-
#
|
405 |
-
sorted_categories = sorted(category_scores.items(), key=lambda x: x[1], reverse=True)
|
406 |
-
top_categories = sorted_categories[:2]
|
407 |
-
bottom_categories = sorted_categories[-2:]
|
408 |
-
|
409 |
-
# More detailed template-based feedback for top category
|
410 |
-
top_feedback_templates = {
|
411 |
-
"Technical Skills": [
|
412 |
-
"demonstrates strong technical skills with proficiency in programming languages and technical tools that Google values.",
|
413 |
-
"shows excellent technical capabilities that align well with Google's engineering requirements.",
|
414 |
-
"possesses the technical expertise needed for Google's development environment."
|
415 |
-
],
|
416 |
-
"Advanced Technologies": [
|
417 |
-
"has valuable experience with cutting-edge technologies that Google prioritizes in its innovation efforts.",
|
418 |
-
"demonstrates knowledge in advanced technological areas that align with Google's future direction.",
|
419 |
-
"shows proficiency in modern technologies that Google uses in its products and services."
|
420 |
-
],
|
421 |
-
"Problem Solving": [
|
422 |
-
"exhibits strong problem-solving abilities which are fundamental to Google's engineering culture.",
|
423 |
-
"demonstrates analytical thinking and problem-solving skills that Google seeks in candidates.",
|
424 |
-
"shows the problem-solving aptitude that would be valuable in Google's collaborative environment."
|
425 |
-
],
|
426 |
-
"Innovation & Creativity": [
|
427 |
-
"shows the creative thinking and innovation mindset that Google values in its workforce.",
|
428 |
-
"demonstrates the innovative approach that would fit well with Google's creative culture.",
|
429 |
-
"exhibits creativity that could contribute to Google's product development process."
|
430 |
-
],
|
431 |
-
"Teamwork & Leadership": [
|
432 |
-
"demonstrates leadership qualities and teamwork skills that Google looks for in potential employees.",
|
433 |
-
"shows collaborative abilities that would integrate well with Google's team-based structure.",
|
434 |
-
"exhibits the interpersonal skills needed to thrive in Google's collaborative environment."
|
435 |
-
]
|
436 |
-
}
|
437 |
-
|
438 |
-
# More detailed template-based feedback for bottom categories
|
439 |
-
bottom_feedback_templates = {
|
440 |
-
"Technical Skills": [
|
441 |
-
"should strengthen their technical skills, particularly in programming languages commonly used at Google such as Python, Java, or C++.",
|
442 |
-
"would benefit from developing more depth in technical tools and programming capabilities to meet Google's standards.",
|
443 |
-
"needs to enhance their technical expertise to better align with Google's engineering requirements."
|
444 |
-
],
|
445 |
-
"Advanced Technologies": [
|
446 |
-
"would benefit from gaining more experience with AI, machine learning, or cloud technologies that Google prioritizes.",
|
447 |
-
"should develop more expertise in advanced technologies like machine learning or data science to increase their value to Google.",
|
448 |
-
"needs more exposure to the cutting-edge technologies that drive Google's innovation."
|
449 |
-
],
|
450 |
-
"Problem Solving": [
|
451 |
-
"should strengthen their problem-solving abilities, particularly with algorithms and data structures that are crucial for Google interviews.",
|
452 |
-
"would benefit from developing stronger analytical and problem-solving skills to match Google's expectations.",
|
453 |
-
"needs to improve their approach to complex problem-solving to meet Google's standards."
|
454 |
-
],
|
455 |
-
"Innovation & Creativity": [
|
456 |
-
"could develop a more innovative mindset to better align with Google's creative culture.",
|
457 |
-
"should work on demonstrating more creative thinking in their approach to match Google's innovation focus.",
|
458 |
-
"would benefit from cultivating more creativity and out-of-the-box thinking valued at Google."
|
459 |
-
],
|
460 |
-
"Teamwork & Leadership": [
|
461 |
-
"should focus on developing stronger leadership and teamwork skills to thrive in Google's collaborative environment.",
|
462 |
-
"would benefit from more experience in collaborative settings to match Google's team-oriented culture.",
|
463 |
-
"needs to strengthen their interpersonal and leadership capabilities to align with Google's expectations."
|
464 |
-
]
|
465 |
-
}
|
466 |
-
|
467 |
-
# Generate feedback with more detailed templates
|
468 |
-
import random
|
469 |
-
|
470 |
-
# Get top strength feedback
|
471 |
-
top_category = top_categories[0][0]
|
472 |
-
top_score = top_categories[0][1]
|
473 |
-
top_feedback = random.choice(top_feedback_templates.get(top_category, ["shows notable skills"]))
|
474 |
-
|
475 |
-
# Get improvement area feedback
|
476 |
-
bottom_category = bottom_categories[0][0]
|
477 |
-
bottom_score = bottom_categories[0][1]
|
478 |
-
bottom_feedback = random.choice(bottom_feedback_templates.get(bottom_category, ["could improve their skills"]))
|
479 |
-
|
480 |
-
# Construct full feedback
|
481 |
-
feedback = f"This candidate {top_feedback} "
|
482 |
-
|
483 |
-
# Add second strength if it's good
|
484 |
-
if top_categories[1][1] >= 0.6:
|
485 |
-
second_top = top_categories[1][0]
|
486 |
-
second_top_feedback = random.choice(top_feedback_templates.get(second_top, ["has good abilities"]))
|
487 |
-
feedback += f"The candidate also {second_top_feedback} "
|
488 |
-
|
489 |
-
# Add improvement feedback
|
490 |
-
feedback += f"However, the candidate {bottom_feedback} "
|
491 |
-
|
492 |
-
# Add conclusion based on overall score
|
493 |
-
overall_score = sum(score * weight for (category, score), weight in
|
494 |
-
zip(category_scores.items(), [0.35, 0.25, 0.20, 0.10, 0.10]))
|
495 |
-
|
496 |
-
if overall_score >= 0.75:
|
497 |
-
feedback += "Overall, this candidate shows strong potential for success at Google."
|
498 |
-
elif overall_score >= 0.6:
|
499 |
-
feedback += "With these improvements, the candidate could be a good fit for Google."
|
500 |
-
else:
|
501 |
-
feedback += "The candidate would need significant development to meet Google's standards."
|
502 |
-
|
503 |
-
execution_time = time.time() - start_time
|
504 |
-
|
505 |
-
return feedback, execution_time
|
506 |
-
|
507 |
-
#####################################
|
508 |
-
# Function: Generate Aspect-Based Feedback with T5 - Enhanced with Fallback
|
509 |
-
#####################################
|
510 |
-
@st.cache_data(show_spinner=False)
|
511 |
-
def generate_aspect_feedback(candidate_summary, category_scores, _evaluator=None):
|
512 |
-
"""
|
513 |
-
Use T5-small model to generate feedback with robust fallback to template-based feedback.
|
514 |
-
"""
|
515 |
-
start_time = time.time()
|
516 |
-
|
517 |
-
evaluator = _evaluator or models['evaluator']
|
518 |
-
|
519 |
-
# Sort categories by score
|
520 |
-
sorted_categories = sorted(category_scores.items(), key=lambda x: x[1], reverse=True)
|
521 |
-
top_categories = sorted_categories[:2]
|
522 |
-
bottom_categories = sorted_categories[-2:]
|
523 |
-
|
524 |
-
# Create a more explicit prompt for T5
|
525 |
prompt = f"""
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
|
|
|
|
|
|
|
|
530 |
"""
|
531 |
|
532 |
-
# Generate focused feedback with error handling
|
533 |
try:
|
534 |
-
|
535 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
536 |
|
537 |
-
# Validate the response - ensure it's not empty or too short
|
538 |
-
if len(feedback.strip()) < 20 or feedback.strip() == "This candidate" or feedback.strip() == "This candidate.":
|
539 |
-
# Fall back to template-based if T5 output is too short
|
540 |
-
return generate_template_feedback(category_scores)
|
541 |
-
|
542 |
-
# Ensure third-person tone
|
543 |
-
if not any(feedback.lower().startswith(start) for start in ["the candidate", "this candidate"]):
|
544 |
-
feedback = f"This candidate {feedback}"
|
545 |
except Exception as e:
|
546 |
-
#
|
547 |
-
|
548 |
-
|
549 |
|
550 |
execution_time = time.time() - start_time
|
551 |
|
552 |
-
return
|
553 |
|
554 |
#####################################
|
555 |
-
# Main Streamlit Interface
|
556 |
#####################################
|
557 |
st.title("Google Resume Match Analyzer")
|
558 |
st.markdown(
|
@@ -560,7 +389,7 @@ st.markdown(
|
|
560 |
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:
|
561 |
1. Extracts text from your resume.
|
562 |
2. Uses AI to generate a structured candidate summary.
|
563 |
-
3.
|
564 |
"""
|
565 |
)
|
566 |
|
@@ -571,10 +400,6 @@ with st.expander("Google's Requirements", expanded=False):
|
|
571 |
# File uploader
|
572 |
uploaded_file = st.file_uploader("Upload your resume (.docx, .doc, or .txt)", type=["docx", "doc", "txt"])
|
573 |
|
574 |
-
# Add a checkbox for template-based feedback (faster)
|
575 |
-
use_template_feedback = st.checkbox("Use faster template-based feedback (no ML)", value=False,
|
576 |
-
help="Generate feedback using pre-defined templates instead of T5 model")
|
577 |
-
|
578 |
# Process button with optimized flow
|
579 |
if uploaded_file is not None and st.button("Analyze My Google Fit"):
|
580 |
# Create a placeholder for the progress bar
|
@@ -599,18 +424,9 @@ if uploaded_file is not None and st.button("Analyze My Google Fit"):
|
|
599 |
st.markdown(summary)
|
600 |
st.info(f"Summary generated in {summarization_time:.2f} seconds")
|
601 |
|
602 |
-
# Step 3:
|
603 |
-
status_text.text("Step 3/3:
|
604 |
-
|
605 |
-
|
606 |
-
# Choose feedback generation method based on checkbox
|
607 |
-
if use_template_feedback:
|
608 |
-
feedback, feedback_time = generate_template_feedback(category_scores)
|
609 |
-
else:
|
610 |
-
feedback, feedback_time = generate_aspect_feedback(
|
611 |
-
summary, category_scores, _evaluator=models['evaluator']
|
612 |
-
)
|
613 |
-
|
614 |
progress_bar.progress(100)
|
615 |
|
616 |
# Clear status messages
|
@@ -619,50 +435,40 @@ if uploaded_file is not None and st.button("Analyze My Google Fit"):
|
|
619 |
# Display Google fit results
|
620 |
st.subheader("Google Fit Assessment")
|
621 |
|
622 |
-
# Display
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
st.warning(f"**Overall Google Match Score:** {score_percent}% β οΈ")
|
630 |
else:
|
631 |
-
st.error(f"**Overall Google Match Score:** {
|
632 |
-
|
633 |
-
# Display score breakdown
|
634 |
-
st.markdown("### Score Calculation")
|
635 |
-
st.markdown(score_breakdown)
|
636 |
|
637 |
-
# Display
|
638 |
st.markdown("### Expert Assessment")
|
639 |
-
st.markdown(
|
640 |
|
641 |
-
st.info(f"Assessment completed in {
|
642 |
|
643 |
-
# Add potential next steps based on the
|
644 |
st.subheader("Recommended Next Steps")
|
645 |
|
646 |
-
|
647 |
-
weakest_categories = sorted(category_scores.items(), key=lambda x: x[1])[:2]
|
648 |
-
|
649 |
-
if overall_score >= 0.80:
|
650 |
st.markdown("""
|
651 |
- Consider applying for positions at Google that match your experience
|
652 |
- Prepare for technical interviews by practicing algorithms and system design
|
653 |
- Review Google's interview process and STAR method for behavioral questions
|
654 |
""")
|
655 |
-
elif
|
656 |
-
|
657 |
-
|
658 |
-
- Focus on strengthening these areas: {improvement_areas}
|
659 |
- Work on projects that demonstrate your skills in Google's key technology areas
|
660 |
- Consider taking additional courses in algorithms, system design, or other Google focus areas
|
661 |
""")
|
662 |
else:
|
663 |
-
|
664 |
-
|
665 |
-
- Build experience in these critical areas: {improvement_areas}
|
666 |
- Develop projects showcasing problem-solving abilities and technical skills
|
667 |
- Consider gaining more experience before applying, or target specific Google roles that better match your profile
|
668 |
""")
|
|
|
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
|
32 |
#####################################
|
33 |
@st.cache_resource(show_spinner=True)
|
34 |
def load_models():
|
35 |
+
"""Load models at startup"""
|
36 |
with st.spinner("Loading AI models... This may take a minute on first run."):
|
37 |
models = {}
|
38 |
+
# Use bart-base for summarization
|
39 |
models['summarizer'] = pipeline(
|
40 |
"summarization",
|
41 |
model="facebook/bart-base",
|
|
|
43 |
truncation=True
|
44 |
)
|
45 |
|
46 |
+
# Load model for evaluation
|
47 |
models['evaluator'] = pipeline(
|
48 |
+
"text2text-generation",
|
49 |
+
model="google-t5/t5-small",
|
50 |
+
max_length=300
|
|
|
|
|
51 |
)
|
52 |
|
53 |
return models
|
|
|
103 |
return text[:15000] if text else text
|
104 |
|
105 |
#####################################
|
106 |
+
# Functions for Information Extraction
|
107 |
#####################################
|
108 |
|
109 |
# Cache the extraction functions to avoid reprocessing
|
|
|
269 |
return skills_formatted, work_experience
|
270 |
|
271 |
#####################################
|
272 |
+
# Function: Summarize Resume Text
|
273 |
#####################################
|
274 |
def summarize_resume_text(resume_text):
|
275 |
"""
|
276 |
+
Generates a structured summary of the resume text
|
277 |
"""
|
278 |
start_time = time.time()
|
279 |
|
|
|
310 |
return formatted_summary, execution_time
|
311 |
|
312 |
#####################################
|
313 |
+
# Function: Analyze Google Fit
|
314 |
#####################################
|
315 |
+
def analyze_google_fit(resume_summary):
|
316 |
"""
|
317 |
+
Analyze how well the candidate fits Google's requirements.
|
318 |
+
This uses the T5 model to generate a natural language assessment.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
319 |
"""
|
320 |
start_time = time.time()
|
321 |
|
322 |
+
# Carefully craft a prompt that won't be repeated in the output
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
323 |
prompt = f"""
|
324 |
+
Google hiring analysis:
|
325 |
+
Resume summary: {resume_summary}
|
326 |
+
|
327 |
+
Google requirements: {GOOGLE_DESCRIPTION}
|
328 |
+
|
329 |
+
Evaluate this candidate for Google. Consider technical skills, experience, and culture fit.
|
330 |
+
Write a paragraph starting with "This candidate" describing their fit for Google.
|
331 |
+
Include strengths, weaknesses, and a match percentage (0-100%).
|
332 |
"""
|
333 |
|
|
|
334 |
try:
|
335 |
+
# Generate the assessment
|
336 |
+
response = models['evaluator'](
|
337 |
+
prompt,
|
338 |
+
max_length=300,
|
339 |
+
do_sample=True,
|
340 |
+
temperature=0.7
|
341 |
+
)
|
342 |
+
|
343 |
+
assessment = response[0]['generated_text']
|
344 |
+
|
345 |
+
# Clean up assessment to prevent instruction leakage
|
346 |
+
assessment = assessment.replace("Google hiring analysis:", "")
|
347 |
+
assessment = assessment.replace("Resume summary:", "")
|
348 |
+
assessment = assessment.replace("Google requirements:", "")
|
349 |
+
assessment = assessment.replace("Evaluate this candidate for Google.", "")
|
350 |
+
assessment = assessment.replace("Write a paragraph", "")
|
351 |
+
assessment = assessment.replace("starting with", "")
|
352 |
+
assessment = assessment.replace("Consider technical skills, experience, and culture fit.", "")
|
353 |
+
assessment = assessment.replace("Include strengths, weaknesses, and a match percentage", "")
|
354 |
+
|
355 |
+
# Make sure it starts properly
|
356 |
+
if not assessment.strip().startswith("This candidate"):
|
357 |
+
assessment = "This candidate " + assessment.strip()
|
358 |
+
|
359 |
+
# Extract match percentage if present
|
360 |
+
match_percentage = None
|
361 |
+
percentage_pattern = r'(\d{1,3})%'
|
362 |
+
match = re.search(percentage_pattern, assessment)
|
363 |
+
if match:
|
364 |
+
match_percentage = int(match.group(1))
|
365 |
+
# Ensure it's in valid range
|
366 |
+
match_percentage = min(100, max(0, match_percentage))
|
367 |
+
|
368 |
+
# If no percentage was found in the text, default to 50%
|
369 |
+
if match_percentage is None:
|
370 |
+
match_percentage = 50
|
371 |
+
# Add a percentage to the end of assessment
|
372 |
+
assessment += f" Overall match: {match_percentage}%."
|
373 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
374 |
except Exception as e:
|
375 |
+
# Fallback if model fails
|
376 |
+
assessment = "This candidate's resume has been analyzed. Based on skills and experience, they may have some relevant qualities for Google, but a detailed assessment couldn't be generated. Please review the resume summary manually."
|
377 |
+
match_percentage = 50
|
378 |
|
379 |
execution_time = time.time() - start_time
|
380 |
|
381 |
+
return assessment, match_percentage, execution_time
|
382 |
|
383 |
#####################################
|
384 |
+
# Main Streamlit Interface
|
385 |
#####################################
|
386 |
st.title("Google Resume Match Analyzer")
|
387 |
st.markdown(
|
|
|
389 |
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:
|
390 |
1. Extracts text from your resume.
|
391 |
2. Uses AI to generate a structured candidate summary.
|
392 |
+
3. Analyzes how well your profile fits Google's requirements.
|
393 |
"""
|
394 |
)
|
395 |
|
|
|
400 |
# File uploader
|
401 |
uploaded_file = st.file_uploader("Upload your resume (.docx, .doc, or .txt)", type=["docx", "doc", "txt"])
|
402 |
|
|
|
|
|
|
|
|
|
403 |
# Process button with optimized flow
|
404 |
if uploaded_file is not None and st.button("Analyze My Google Fit"):
|
405 |
# Create a placeholder for the progress bar
|
|
|
424 |
st.markdown(summary)
|
425 |
st.info(f"Summary generated in {summarization_time:.2f} seconds")
|
426 |
|
427 |
+
# Step 3: Generate Google fit assessment
|
428 |
+
status_text.text("Step 3/3: Evaluating Google fit...")
|
429 |
+
assessment, match_percentage, assessment_time = analyze_google_fit(summary)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
430 |
progress_bar.progress(100)
|
431 |
|
432 |
# Clear status messages
|
|
|
435 |
# Display Google fit results
|
436 |
st.subheader("Google Fit Assessment")
|
437 |
|
438 |
+
# Display match percentage with appropriate color and emoji
|
439 |
+
if match_percentage >= 85:
|
440 |
+
st.success(f"**Overall Google Match Score:** {match_percentage}% π")
|
441 |
+
elif match_percentage >= 70:
|
442 |
+
st.success(f"**Overall Google Match Score:** {match_percentage}% β
")
|
443 |
+
elif match_percentage >= 50:
|
444 |
+
st.warning(f"**Overall Google Match Score:** {match_percentage}% β οΈ")
|
|
|
445 |
else:
|
446 |
+
st.error(f"**Overall Google Match Score:** {match_percentage}% π")
|
|
|
|
|
|
|
|
|
447 |
|
448 |
+
# Display assessment
|
449 |
st.markdown("### Expert Assessment")
|
450 |
+
st.markdown(assessment)
|
451 |
|
452 |
+
st.info(f"Assessment completed in {assessment_time:.2f} seconds")
|
453 |
|
454 |
+
# Add potential next steps based on the match percentage
|
455 |
st.subheader("Recommended Next Steps")
|
456 |
|
457 |
+
if match_percentage >= 80:
|
|
|
|
|
|
|
458 |
st.markdown("""
|
459 |
- Consider applying for positions at Google that match your experience
|
460 |
- Prepare for technical interviews by practicing algorithms and system design
|
461 |
- Review Google's interview process and STAR method for behavioral questions
|
462 |
""")
|
463 |
+
elif match_percentage >= 60:
|
464 |
+
st.markdown("""
|
465 |
+
- Focus on strengthening your technical skills and advanced technology knowledge
|
|
|
466 |
- Work on projects that demonstrate your skills in Google's key technology areas
|
467 |
- Consider taking additional courses in algorithms, system design, or other Google focus areas
|
468 |
""")
|
469 |
else:
|
470 |
+
st.markdown("""
|
471 |
+
- Build more relevant experience in software development or technical areas
|
|
|
472 |
- Develop projects showcasing problem-solving abilities and technical skills
|
473 |
- Consider gaining more experience before applying, or target specific Google roles that better match your profile
|
474 |
""")
|