Spaces:
Build error
Build error
Commit ·
79539fd
1
Parent(s): 1a4dad2
add slider
Browse files
app.py
CHANGED
|
@@ -7,14 +7,14 @@ tokenizer = AutoTokenizer.from_pretrained("distilbert/distilbert-base-uncased")
|
|
| 7 |
model = AutoModelForSequenceClassification.from_pretrained("usman-yello/job-tagging")
|
| 8 |
|
| 9 |
|
| 10 |
-
def tag_job_description(job_description):
|
| 11 |
job_description = re.sub(r'[^a-zA-Z]', ' ', job_description)
|
| 12 |
inputs = tokenizer(job_description, truncation=True, max_length=512, return_tensors="pt")
|
| 13 |
outputs = model(**inputs)
|
| 14 |
-
topk_values, topk_indices = torch.topk(outputs.logits,
|
| 15 |
-
predicted_tags = [model.config.id2label[i] for i in topk_indices[0]]
|
| 16 |
return predicted_tags
|
| 17 |
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
|
|
|
| 7 |
model = AutoModelForSequenceClassification.from_pretrained("usman-yello/job-tagging")
|
| 8 |
|
| 9 |
|
| 10 |
+
def tag_job_description(job_description, num_tags):
|
| 11 |
job_description = re.sub(r'[^a-zA-Z]', ' ', job_description)
|
| 12 |
inputs = tokenizer(job_description, truncation=True, max_length=512, return_tensors="pt")
|
| 13 |
outputs = model(**inputs)
|
| 14 |
+
topk_values, topk_indices = torch.topk(outputs.logits, num_tags)
|
| 15 |
+
predicted_tags = [model.config.id2label[i.item()] for i in topk_indices[0]]
|
| 16 |
return predicted_tags
|
| 17 |
|
| 18 |
|
| 19 |
+
job_tagger = gr.Interface(fn=tag_job_description, inputs=["text", gr.Slider(value=1, minimum=1, maximum=10, step=1)], outputs="text")
|
| 20 |
+
job_tagger.launch()
|