Spaces:
Runtime error
Runtime error
Create app.py
Browse filesResume Summary Generator initial deployment.
app.py
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from peft import PeftModel, PeftConfig
|
| 3 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 4 |
+
|
| 5 |
+
peft_model_id = "gkrishnan/Resume_Parsing_Model"
|
| 6 |
+
config = PeftConfig.from_pretrained(peft_model_id)
|
| 7 |
+
base_model = AutoModelForCausalLM.from_pretrained(
|
| 8 |
+
config.base_model_name_or_path,
|
| 9 |
+
return_dict=True,
|
| 10 |
+
load_in_8bit=False,
|
| 11 |
+
device_map="auto",
|
| 12 |
+
)
|
| 13 |
+
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
|
| 14 |
+
|
| 15 |
+
# Load the Lora model
|
| 16 |
+
model = PeftModel.from_pretrained(base_model, peft_model_id)
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def make_inference(resume):
|
| 20 |
+
batch = tokenizer(f"Write a summary based off this resume.\n\n### Resume:\n{resume}", return_tensors='pt')
|
| 21 |
+
|
| 22 |
+
with torch.cuda.amp.autocast():
|
| 23 |
+
output_tokens = model.generate(**batch, max_new_tokens=200)
|
| 24 |
+
|
| 25 |
+
return tokenizer.decode(output_tokens[0], skip_special_tokens=True)
|
| 26 |
+
|
| 27 |
+
if __name__ == "__main__":
|
| 28 |
+
import gradio as gr
|
| 29 |
+
|
| 30 |
+
gr.Interface(
|
| 31 |
+
make_inference,
|
| 32 |
+
[
|
| 33 |
+
gr.inputs.Textbox(lines=2, label="Resume"),
|
| 34 |
+
],
|
| 35 |
+
gr.outputs.Textbox(label="Summarized Resume"),
|
| 36 |
+
title="Resume Summary Generator",
|
| 37 |
+
description="This generates a summary from a Resume",
|
| 38 |
+
).launch()
|