sekuxrious commited on
Commit
d25ebb3
·
verified ·
1 Parent(s): 8385747

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -13
app.py CHANGED
@@ -1,29 +1,27 @@
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
- # Load your text-generation model from HF
5
- # (change "YourUsername/YourModel" to whichever model you want to use)
6
- generator = pipeline("text-generation", model="gpt2")
 
 
7
 
8
  def generate_cv(name, education, experience):
9
- # Build a "prompt" for your model
10
  prompt = (
11
- f"Generate a CV based on these details:\n"
12
  f"Name: {name}\n"
13
  f"Education: {education}\n"
14
  f"Experience: {experience}\n"
15
  "CV:\n"
16
  )
 
 
 
17
 
18
- # Call the pipeline to generate text (you can tweak max_length, etc.)
19
- outputs = generator(prompt, max_length=300)
20
- cv_text = outputs[0]["generated_text"]
21
- return cv_text
22
-
23
- # Create a Gradio interface with 3 textboxes as input
24
  demo = gr.Interface(
25
- fn=generate_cv,
26
- inputs=["text", "text", "text"], # or gr.Textbox(…), etc.
27
  outputs="text",
28
  title="Automated CV Generator"
29
  )
 
1
  import gradio as gr
2
  from transformers import pipeline
3
 
4
+ generator = pipeline(
5
+ "text-generation",
6
+ model="gpt2",
7
+ pad_token_id=50256 # crucial for GPT-2
8
+ )
9
 
10
  def generate_cv(name, education, experience):
 
11
  prompt = (
12
+ f"Generate a CV:\n"
13
  f"Name: {name}\n"
14
  f"Education: {education}\n"
15
  f"Experience: {experience}\n"
16
  "CV:\n"
17
  )
18
+ # Use max_new_tokens=100 (or something smaller) for speed
19
+ outputs = generator(prompt, max_new_tokens=100)
20
+ return outputs[0]["generated_text"]
21
 
 
 
 
 
 
 
22
  demo = gr.Interface(
23
+ fn=generate_cv,
24
+ inputs=["text", "text", "text"],
25
  outputs="text",
26
  title="Automated CV Generator"
27
  )