Spaces:
Sleeping
Sleeping
# Load the RAG model | |
rag_model = RagTokenForGeneration.from_pretrained("rag_model") | |
job_description_text = """ | |
We are looking for a Senior Data Scientist with 7+ years of experience in machine learning, deep learning, and advanced statistical modeling. The candidate should have a strong background in Python, TensorFlow, and PyTorch. Experience with cloud platforms like AWS or GCP is mandatory. Responsibilities include leading data science teams, designing predictive models, and optimizing business strategies through data insights. A PhD in Computer Science, Statistics, or a related field is highly preferred. | |
""" | |
resume_text = """ | |
Hardworking construction worker with 2 years of experience in residential building projects. Skilled in operating heavy machinery, reading blueprints, and ensuring site safety. Proficient in the use of tools like drills, saws, and hammers. Strong knowledge of safety regulations and experience collaborating with contractors and architects. Dedicated to delivering quality results and meeting project deadlines. | |
""" | |
query = resume_text + " " + job_description_text + | |
f"Provide a score between 0 and 100% for the resume against the job description and explain your reasoning. Summarize the classification whether the candidate is a perfect fit, a good fit, a potential fit, or no fit" | |
tokenizer = RagTokenizer.from_pretrained("facebook/rag-sequence-base", trust_remote_code=True) | |
def test_new_data(query, model, tokenizer): | |
inputs = tokenizer(query, return_tensors="pt", padding=True, truncation=True) | |
with torch.no_grad(): | |
outputs = model( | |
input_ids=inputs["input_ids"], | |
attention_mask=inputs["attention_mask"] | |
) | |
logits = outputs.logits | |
preds = torch.argmax(logits, axis=1) | |
return preds.item() | |
predicted_label = test_new_data(query, model, tokenizer) | |
print(f"Predicted Label: {predicted_label}") | |
response = model.generate(inputs_ids=inputs["input_ids"], attention_mask=inputs["attention_mask"]) | |
print(f"Jof Fitness: {response}") | |