owaiskha9654 commited on
Commit
415ed22
β€’
1 Parent(s): cd334dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -15,8 +15,17 @@ tokenizer = BertTokenizer.from_pretrained('owaiskha9654/Multi-Label-Classificati
15
  def Multi_Label_Classification_of_Pubmed_Articles(model_input: str) -> Dict[str, float]:
16
 
17
  # Encoding input data
18
- encodings = tokenizer.batch_encode_plus(model_input,max_length=1024,padding=True,truncation=True) # tokenizer's encoding method
19
- outs = model(torch.tensor(encodings['input_ids']), token_type_ids=None, attention_mask=torch.tensor(encodings['attention_mask']))
 
 
 
 
 
 
 
 
 
20
  b_logit_pred = outs[0]
21
  pred_label = torch.sigmoid(b_logit_pred)
22
 
@@ -68,9 +77,9 @@ examples = [
68
  title = "Multi Label Classification of Pubmed Articles (Paper Night July Edition at Thoucentric)"
69
  description = "The traditional machine learning models give a lot of pain when we do not have sufficient labeled data for the specific task or domain we care about to train a reliable model. Transfer learning allows us to deal with these scenarios by leveraging the already existing labeled data of some related task or domain. We try to store this knowledge gained in solving the source task in the source domain and apply it to our problem of interest. In this work, I have utilized Transfer Learning utilizing BertForSequenceClassification model to fine tune on Pubmed MultiLabel classification Dataset."
70
  article = (
71
- "Author: Owais Ahmad Data Scientist at Thoucentric <a href=\"https://www.linkedin.com/in/owaiskhan9654/\">Link</a> \n"
72
  "Model Trained Kaggle on <a href=\"https://www.kaggle.com/code/owaiskhan9654/multi-label-classification-of-pubmed-articles\">Link</a> \n "
73
- "My Kaggle Profile <a href=\"https://www.kaggle.com/owaiskhan9654\">Link</a>"
74
  "HuggingFace Model Deployed Repository <a href=\"https://huggingface.co/owaiskha9654/Multi-Label-Classification-of-PubMed-Articles\">Link</a> \n"
75
  )
76
 
 
15
  def Multi_Label_Classification_of_Pubmed_Articles(model_input: str) -> Dict[str, float]:
16
 
17
  # Encoding input data
18
+ dict_custom={}
19
+ Preprocess_part1=model_input[:len(model_input)]
20
+ Preprocess_part2=model_input[len(model_input):]
21
+ dict1=tokenizer.encode_plus(Preprocess_part1,max_length=1024,padding=True,truncation=True)
22
+ dict2=tokenizer.encode_plus(Preprocess_part2,max_length=1024,padding=True,truncation=True)
23
+
24
+ dict_custom['input_ids']=[dict1['input_ids'],dict1['input_ids']]
25
+ dict_custom['token_type_ids']=[dict1['token_type_ids'],dict1['token_type_ids']]
26
+ dict_custom['attention_mask']=[dict1['attention_mask'],dict1['attention_mask']]
27
+
28
+ outs = model(torch.tensor(dict_custom['input_ids']), token_type_ids=None, attention_mask=torch.tensor(dict_custom['attention_mask']))
29
  b_logit_pred = outs[0]
30
  pred_label = torch.sigmoid(b_logit_pred)
31
 
 
77
  title = "Multi Label Classification of Pubmed Articles (Paper Night July Edition at Thoucentric)"
78
  description = "The traditional machine learning models give a lot of pain when we do not have sufficient labeled data for the specific task or domain we care about to train a reliable model. Transfer learning allows us to deal with these scenarios by leveraging the already existing labeled data of some related task or domain. We try to store this knowledge gained in solving the source task in the source domain and apply it to our problem of interest. In this work, I have utilized Transfer Learning utilizing BertForSequenceClassification model to fine tune on Pubmed MultiLabel classification Dataset."
79
  article = (
80
+ "Author: Owais Ahmad Data Scientist at <b> Thoucentric <b> <a href=\"https://www.linkedin.com/in/owaiskhan9654/\">Link</a> "
81
  "Model Trained Kaggle on <a href=\"https://www.kaggle.com/code/owaiskhan9654/multi-label-classification-of-pubmed-articles\">Link</a> \n "
82
+ "My Kaggle Profile <a href=\"https://www.kaggle.com/owaiskhan9654\">Link</a> "
83
  "HuggingFace Model Deployed Repository <a href=\"https://huggingface.co/owaiskha9654/Multi-Label-Classification-of-PubMed-Articles\">Link</a> \n"
84
  )
85