shahrukhx01 / bert-multitask-query-classifiers

huggingface.co
Total runs: 41
24-hour runs: 0
7-day runs: -3
30-day runs: 30
Model's Last Updated: November 09 2023
text-classification

Introduction of bert-multitask-query-classifiers

Model Details of bert-multitask-query-classifiers

A Multi-task learning model with two prediction heads

  • One prediction head classifies between keyword sentences vs statements/questions
  • Other prediction head corresponds to classifier for statements vs questions
Scores
Spaadia SQuaD Test acc: 0.9891
Quora Keyword Pairs Test acc: 0.98048
Datasets:

Quora Keyword Pairs: https://www.kaggle.com/stefanondisponibile/quora-question-keyword-pairs Spaadia SQuaD pairs: https://www.kaggle.com/shahrukhkhan/questions-vs-statementsclassificationdataset

Article

Medium article

Demo Notebook

Colab Notebook Multi-task Query classifiers

Clone the model repo
git clone https://huggingface.co/shahrukhx01/bert-multitask-query-classifiers
%cd bert-multitask-query-classifiers/
Load model
from multitask_model import BertForSequenceClassification
from transformers import AutoTokenizer
import torch
model = BertForSequenceClassification.from_pretrained(
        "shahrukhx01/bert-multitask-query-classifiers",
        task_labels_map={"quora_keyword_pairs": 2, "spaadia_squad_pairs": 2},
    )
tokenizer = AutoTokenizer.from_pretrained("shahrukhx01/bert-multitask-query-classifiers")
Run inference on both Tasks
from multitask_model import BertForSequenceClassification
from transformers import AutoTokenizer
import torch
model = BertForSequenceClassification.from_pretrained(
        "shahrukhx01/bert-multitask-query-classifiers",
        task_labels_map={"quora_keyword_pairs": 2, "spaadia_squad_pairs": 2},
    )
tokenizer = AutoTokenizer.from_pretrained("shahrukhx01/bert-multitask-query-classifiers")

## Keyword vs Statement/Question Classifier
input = ["keyword query", "is this a keyword query?"]
task_name="quora_keyword_pairs"
sequence = tokenizer(input, padding=True, return_tensors="pt")['input_ids']
logits = model(sequence, task_name=task_name)[0]
predictions = torch.argmax(torch.softmax(logits, dim=1).detach().cpu(), axis=1)
for input, prediction in zip(input, predictions):
  print(f"task: {task_name}, input: {input} \n prediction=> {prediction}")
  print()
  

## Statement vs Question Classifier
input = ["where is berlin?", "is this a keyword query?", "Berlin is in Germany."]
task_name="spaadia_squad_pairs"
sequence = tokenizer(input, padding=True, return_tensors="pt")['input_ids']
logits = model(sequence, task_name=task_name)[0]
predictions = torch.argmax(torch.softmax(logits, dim=1).detach().cpu(), axis=1)
for input, prediction in zip(input, predictions):
  print(f"task: {task_name}, input: {input} \n prediction=> {prediction}")
  print()

Runs of shahrukhx01 bert-multitask-query-classifiers on huggingface.co

41
Total runs
0
24-hour runs
-2
3-day runs
-3
7-day runs
30
30-day runs

More Information About bert-multitask-query-classifiers huggingface.co Model

bert-multitask-query-classifiers huggingface.co

bert-multitask-query-classifiers huggingface.co is an AI model on huggingface.co that provides bert-multitask-query-classifiers's model effect (), which can be used instantly with this shahrukhx01 bert-multitask-query-classifiers model. huggingface.co supports a free trial of the bert-multitask-query-classifiers model, and also provides paid use of the bert-multitask-query-classifiers. Support call bert-multitask-query-classifiers model through api, including Node.js, Python, http.

bert-multitask-query-classifiers huggingface.co Url

https://huggingface.co/shahrukhx01/bert-multitask-query-classifiers

shahrukhx01 bert-multitask-query-classifiers online free

bert-multitask-query-classifiers huggingface.co is an online trial and call api platform, which integrates bert-multitask-query-classifiers's modeling effects, including api services, and provides a free online trial of bert-multitask-query-classifiers, you can try bert-multitask-query-classifiers online for free by clicking the link below.

shahrukhx01 bert-multitask-query-classifiers online free url in huggingface.co:

https://huggingface.co/shahrukhx01/bert-multitask-query-classifiers

bert-multitask-query-classifiers install

bert-multitask-query-classifiers is an open source model from GitHub that offers a free installation service, and any user can find bert-multitask-query-classifiers on GitHub to install. At the same time, huggingface.co provides the effect of bert-multitask-query-classifiers install, users can directly use bert-multitask-query-classifiers installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

bert-multitask-query-classifiers install url in huggingface.co:

https://huggingface.co/shahrukhx01/bert-multitask-query-classifiers

Url of bert-multitask-query-classifiers

bert-multitask-query-classifiers huggingface.co Url

Provider of bert-multitask-query-classifiers huggingface.co

shahrukhx01
ORGANIZATIONS

Other API from shahrukhx01