Spaces:
No application file
No application file
deepakkaura26
commited on
Commit
•
26db8ef
1
Parent(s):
44506b5
Delete dpm1.py
Browse files
dpm1.py
DELETED
@@ -1,61 +0,0 @@
|
|
1 |
-
# -*- coding: utf-8 -*-
|
2 |
-
"""dpm1
|
3 |
-
|
4 |
-
Automatically generated by Colaboratory.
|
5 |
-
|
6 |
-
Original file is located at
|
7 |
-
https://colab.research.google.com/drive/1PJnjffQq5PpvzMoY1aB5uggxb35r11Ut
|
8 |
-
"""
|
9 |
-
|
10 |
-
#!pip install streamlit
|
11 |
-
|
12 |
-
#!pip install transformers
|
13 |
-
|
14 |
-
import streamlit as st
|
15 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
|
16 |
-
|
17 |
-
model_name = "EleutherAI/gpt-neo-1.3B"
|
18 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
19 |
-
model = AutoModelForCausalLM.from_pretrained(model_name)
|
20 |
-
generator = pipeline('text-generation', model=model, tokenizer=tokenizer)
|
21 |
-
|
22 |
-
def generate_job_posting(position, job_type, skillset, company_name, work_experience, job_location, job_benefits, field, currency, currency_format, package, communication, notice_period, qualifications, responsibility):
|
23 |
-
context = f"{company_name} is hiring a {position} for a {job_type} position in {job_location}. The ideal candidate will have at least {work_experience} years of experience in {field}, and should be proficient in {skillset}. The job responsibility includes:\n- {responsibility}\nWe offer a {package} package in currency format {currency_format}. The successful candidate will be expected to maintain excellent communication with clients and colleagues. The notice period for this role is {notice_period}, and applicants should have the following qualifications: {qualifications}."
|
24 |
-
output = generator(context, max_length=240, do_sample=True, temperature=0.7, num_return_sequences=3)
|
25 |
-
def score_output(output_text):
|
26 |
-
sentences = output_text.split('.')
|
27 |
-
avg_sentence_length = sum(len(s.strip()) for s in sentences) / len(sentences)
|
28 |
-
return 1.0 / avg_sentence_length
|
29 |
-
sorted_outputs = sorted(output, key=lambda x: score_output(x['generated_text']), reverse=True)
|
30 |
-
best_output = sorted_outputs[0]
|
31 |
-
output_text = best_output['generated_text'].replace('- job responsibility', f"\n\n- {responsibility}")
|
32 |
-
paragraphs = output_text.split('\n\n')
|
33 |
-
output_text = '\n\n'.join('\n' + p for p in paragraphs)
|
34 |
-
return output_text
|
35 |
-
|
36 |
-
st.title("Job Posting Generator")
|
37 |
-
|
38 |
-
position = st.text_input("Enter Position for Job Posting:")
|
39 |
-
job_type = st.text_input("Enter Job Type:")
|
40 |
-
skillset = st.text_input("Enter Skillset:")
|
41 |
-
company_name = st.text_input("Enter Company Name:")
|
42 |
-
work_experience = st.text_input("Enter Required Work Experience (in years):")
|
43 |
-
job_location = st.text_input("Enter job Location:")
|
44 |
-
job_benefits = st.text_input("Enter job benefits:")
|
45 |
-
field = st.text_input("Enter job field:")
|
46 |
-
currency = st.text_input("Enter Currency:")
|
47 |
-
currency_format = st.text_input("Enter Currency Format:")
|
48 |
-
package = st.text_input("Enter Package:")
|
49 |
-
communication = st.text_input("Enter Communication:")
|
50 |
-
notice_period = st.text_input("Enter Notice Period:")
|
51 |
-
qualifications = st.text_input("Enter Qualifications:")
|
52 |
-
responsibility = st.text_area("Enter Job Responsibility:")
|
53 |
-
|
54 |
-
if st.button("Generate Job Posting"):
|
55 |
-
try:
|
56 |
-
output_text = generate_job_posting(position, job_type, skillset, company_name, work_experience, job_location, job_benefits, field, currency, currency_format, package, communication, notice_period, qualifications, responsibility)
|
57 |
-
st.success(output_text)
|
58 |
-
except ValueError as e:
|
59 |
-
st.error(f"Error: {e}")
|
60 |
-
except Exception as e:
|
61 |
-
st.error(f"An error occurred: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|