usman-yello commited on
Commit
79539fd
·
1 Parent(s): 1a4dad2

add slider

Browse files
Files changed (1) hide show
  1. app.py +5 -5
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, 3)
15
- predicted_tags = [model.config.id2label[i] for i in topk_indices[0]]
16
  return predicted_tags
17
 
18
 
19
- demo = gr.Interface(fn=tag_job_description, inputs="text", outputs="text")
20
- demo.launch()
 
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()