Commit
•
590f94a
1
Parent(s):
e28330b
Upload folder using huggingface_hub
Browse files- app.py +43 -33
- requirements.txt +2 -1
app.py
CHANGED
@@ -1,44 +1,54 @@
|
|
1 |
-
from
|
2 |
import gradio as gr
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
|
31 |
with gr.Blocks() as demo:
|
32 |
gr.Markdown(
|
33 |
"""
|
34 |
-
#
|
35 |
-
###
|
36 |
""")
|
37 |
|
38 |
interface = gr.Interface(
|
39 |
-
fn =
|
40 |
-
inputs = [gr.Textbox(placeholder="Enter the
|
41 |
-
|
|
|
|
|
|
|
42 |
)
|
43 |
|
44 |
demo.launch(server_port=7860)
|
|
|
1 |
+
from transformers import pipeline, Conversation
|
2 |
import gradio as gr
|
3 |
+
from datetime import datetime
|
4 |
+
|
5 |
+
from transformers.utils import logging
|
6 |
+
logging.set_verbosity_error()
|
7 |
+
|
8 |
+
# Info about ['google/gemma-2b-it'](https://huggingface.co/google/gemma-2b-it)
|
9 |
+
chatbot = pipeline(task="conversational",
|
10 |
+
model="./models/google/gemma-2b-it")
|
11 |
+
|
12 |
+
def get_job_description(company_name, sector, job_position):
|
13 |
+
start_time = datetime.now()
|
14 |
+
|
15 |
+
messages = [
|
16 |
+
{
|
17 |
+
"role": "user",
|
18 |
+
"content": f"""
|
19 |
+
You are the Talent Acquisition Manager at { company_name }, a company of the { sector } sector.
|
20 |
+
Your goal is to hire people in different departments of the company.
|
21 |
+
I want to generate a Job Description for the role '{ job_position }' in a creative, modern, formal and attractive way.
|
22 |
+
"""
|
23 |
+
},
|
24 |
+
{
|
25 |
+
"role": "assistant",
|
26 |
+
"content": "Description:"
|
27 |
+
}
|
28 |
+
]
|
29 |
+
|
30 |
+
conversation = Conversation(messages)
|
31 |
+
conversation = chatbot(conversation, do_sample=True, max_new_tokens=600, temperature=1)
|
32 |
+
response = conversation.messages[-1]["content"]
|
33 |
+
|
34 |
+
delta_time = datetime.now() - start_time
|
35 |
+
|
36 |
+
return response, delta_time
|
37 |
|
38 |
with gr.Blocks() as demo:
|
39 |
gr.Markdown(
|
40 |
"""
|
41 |
+
# Job Description generator
|
42 |
+
### This SLM demo uses ['google/gemma-2b-it'](https://huggingface.co/google/gemma-2b-it)
|
43 |
""")
|
44 |
|
45 |
interface = gr.Interface(
|
46 |
+
fn = get_job_description,
|
47 |
+
inputs = [gr.Textbox(placeholder="Enter the company name", label="Company name"),
|
48 |
+
gr.Textbox(placeholder="Enter the company sector", label="Company sector"),
|
49 |
+
gr.Textbox(placeholder="Enter the job position", label="Job position")],
|
50 |
+
outputs = [gr.Markdown(),
|
51 |
+
gr.Textbox(label="Elapsed time")]
|
52 |
)
|
53 |
|
54 |
demo.launch(server_port=7860)
|
requirements.txt
CHANGED
@@ -1,2 +1,3 @@
|
|
1 |
-
|
|
|
2 |
gradio
|
|
|
1 |
+
transformers
|
2 |
+
torch
|
3 |
gradio
|