Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,10 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
max_new_tokens=250
|
| 9 |
-
)
|
| 10 |
|
| 11 |
def generate_interview_questions(job_role, level, count):
|
| 12 |
prompt = f"""
|
|
@@ -26,22 +24,7 @@ Tip:
|
|
| 26 |
Keep it clear, simple, and helpful.
|
| 27 |
"""
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
# --------- Gradio UI ----------
|
| 34 |
-
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 35 |
-
gr.Markdown("<h1 style='text-align:center;'>Interview Question Generator Agent</h1>")
|
| 36 |
-
|
| 37 |
-
with gr.Row():
|
| 38 |
-
job = gr.Textbox(label="Job Role", placeholder="e.g., Python Developer, Data Analyst")
|
| 39 |
-
level = gr.Radio(["Beginner", "Intermediate", "Advanced"], label="Difficulty Level", value="Beginner")
|
| 40 |
-
count = gr.Slider(3, 15, value=5, label="Number of Questions")
|
| 41 |
-
|
| 42 |
-
btn = gr.Button("Generate")
|
| 43 |
-
output = gr.Textbox(label="Generated Interview Questions", lines=20)
|
| 44 |
-
|
| 45 |
-
btn.click(generate_interview_questions, inputs=[job, level, count], outputs=output)
|
| 46 |
-
|
| 47 |
-
demo.launch()
|
|
|
|
| 1 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 2 |
+
import torch
|
| 3 |
|
| 4 |
+
model_name = "meta-llama/Llama-3.1-8B-Instruct"
|
| 5 |
+
|
| 6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 7 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, device_map="auto")
|
|
|
|
|
|
|
| 8 |
|
| 9 |
def generate_interview_questions(job_role, level, count):
|
| 10 |
prompt = f"""
|
|
|
|
| 24 |
Keep it clear, simple, and helpful.
|
| 25 |
"""
|
| 26 |
|
| 27 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 28 |
+
output = model.generate(**inputs, max_new_tokens=800, temperature=0.7)
|
| 29 |
+
text = tokenizer.decode(output[0], skip_special_tokens=True)
|
| 30 |
+
return text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|