Commit ·
8bfa9d1
1
Parent(s): b703349
small files
Browse filesFiles changed (4)
- README.md+61-3
- special_tokens_map.jsonAdded+37
- tokenizer_config.jsonAdded+849
- vocab.txtAdded
123---license: mit---12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061---language:- fametrics:- f1- accuracy- precision- recallbase_model:- sbunlp/fabertpipeline_tag: text-classificationtags:- code---# **Fine-Tuned FaBERT Model for Formality Classification**This repository contains a fine-tuned version of **FABERT**, a pre-trained language model designed for **formality classification**. This model has been specifically trained to classify text as **formal** or **informal**, making it ideal for applications in content moderation, social media monitoring, and customer support automation.## **Model Overview**- **Architecture:** Built on the **FABERT** model, a transformer-based architecture optimized for NLP tasks.- **Task:** **Formality Classification** – distinguishing between formal and informal language in text.- **Fine-Tuning:** The model has been fine-tuned on a custom dataset containing a variety of formal and informal text.## **Key Features**- **Multilingual Support:** This model is capable of classifying text in multiple languages, ensuring robustness in diverse linguistic contexts.- **High Performance:** Fine-tuned to provide accurate predictions for formal vs. informal text classification.- **Efficient for Deployment:** Optimized for real-time use in environments like social media platforms, content moderation tools, and communication systems.## **How to Use the Model**You can use this model in your Python code with the Hugging Face `transformers` library and PyTorch. The following code snippet demonstrates how to tokenize text, make predictions, and classify whether the text is formal or informal.```pythonimport torchfrom transformers import AutoTokenizer, AutoModelForSequenceClassification# Load the pre-trained tokenizer and modeltokenizer = AutoTokenizer.from_pretrained("FAIMs/fabert_formality_classifier")model = AutoModelForSequenceClassification.from_pretrained("FAIMs/fabert_formality_classifier")# Ensure the model runs on GPU if availabledevice = torch.device("cuda" if torch.cuda.is_available() else "cpu")model.to(device)# Example input textinput_text = "Please find attached the report for your review."# Tokenize the inputinputs = tokenizer(input_text, return_tensors="pt", padding=True, truncation=True, max_length=512)# Move the model and input to GPU if availableinputs = {key: value.to(device) for key, value in inputs.items()}# Make predictionswith torch.no_grad():outputs = model(**inputs)logits = outputs.logits# Get the predicted labelpredicted_label = logits.argmax(dim=1).item()print(f"Predicted Label: {predicted_label}")
12345678910111213141516171819202122232425262728293031323334353637{ "cls_token": { "content": "[CLS]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "mask_token": { "content": "[MASK]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "pad_token": { "content": "[PAD]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "sep_token": { "content": "[SEP]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }, "unk_token": { "content": "[UNK]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false }}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849{ "added_tokens_decoder": { "0": { "content": "[PAD]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "1": { "content": "[unused1]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "2": { "content": "[unused2]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "3": { "content": "[unused3]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "4": { "content": "[unused4]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "5": { "content": "[unused5]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "6": { "content": "[unused6]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "7": { "content": "[unused7]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "8": { "content": "[unused8]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "9": { "content": "[unused9]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "10": { "content": "[unused10]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "11": { "content": "[unused11]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "12": { "content": "[unused12]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "13": { "content": "[unused13]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "14": { "content": "[unused14]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "15": { "content": "[unused15]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "16": { "content": "[unused16]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "17": { "content": "[unused17]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "18": { "content": "[unused18]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "19": { "content": "[unused19]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "20": { "content": "[unused20]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "21": { "content": "[unused21]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "22": { "content": "[unused22]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "23": { "content": "[unused23]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "24": { "content": "[unused24]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "25": { "content": "[unused25]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "26": { "content": "[unused26]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "27": { "content": "[unused27]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "28": { "content": "[unused28]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "29": { "content": "[unused29]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "30": { "content": "[unused30]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "31": { "content": "[unused31]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "32": { "content": "[unused32]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "33": { "content": "[unused33]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "34": { "content": "[unused34]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "35": { "content": "[unused35]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "36": { "content": "[unused36]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "37": { "content": "[unused37]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "38": { "content": "[unused38]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "39": { "content": "[unused39]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "40": { "content": "[unused40]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "41": { "content": "[unused41]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "42": { "content": "[unused42]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "43": { "content": "[unused43]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "44": { "content": "[unused44]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "45": { "content": "[unused45]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "46": { "content": "[unused46]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "47": { "content": "[unused47]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "48": { "content": "[unused48]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "49": { "content": "[unused49]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "50": { "content": "[unused50]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "51": { "content": "[unused51]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "52": { "content": "[unused52]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "53": { "content": "[unused53]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "54": { "content": "[unused54]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "55": { "content": "[unused55]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "56": { "content": "[unused56]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "57": { "content": "[unused57]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "58": { "content": "[unused58]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "59": { "content": "[unused59]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "60": { "content": "[unused60]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "61": { "content": "[unused61]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "62": { "content": "[unused62]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "63": { "content": "[unused63]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "64": { "content": "[unused64]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "65": { "content": "[unused65]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "66": { "content": "[unused66]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "67": { "content": "[unused67]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "68": { "content": "[unused68]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "69": { "content": "[unused69]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "70": { "content": "[unused70]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "71": { "content": "[unused71]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "72": { "content": "[unused72]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "73": { "content": "[unused73]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "74": { "content": "[unused74]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "75": { "content": "[unused75]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "76": { "content": "[unused76]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "77": { "content": "[unused77]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "78": { "content": "[unused78]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "79": { "content": "[unused79]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "80": { "content": "[unused80]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "81": { "content": "[unused81]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "82": { "content": "[unused82]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "83": { "content": "[unused83]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "84": { "content": "[unused84]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "85": { "content": "[unused85]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "86": { "content": "[unused86]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "87": { "content": "[unused87]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "88": { "content": "[unused88]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "89": { "content": "[unused89]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "90": { "content": "[unused90]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "91": { "content": "[unused91]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "92": { "content": "[unused92]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "93": { "content": "[unused93]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "94": { "content": "[unused94]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "95": { "content": "[unused95]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "96": { "content": "[unused96]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "97": { "content": "[unused97]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "98": { "content": "[unused98]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "99": { "content": "[unused99]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "100": { "content": "[UNK]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "101": { "content": "[CLS]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "102": { "content": "[SEP]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true }, "103": { "content": "[MASK]", "lstrip": false, "normalized": false, "rstrip": false, "single_word": false, "special": true } }, "clean_up_tokenization_spaces": true, "cls_token": "[CLS]", "do_basic_tokenize": true, "do_lower_case": true, "mask_token": "[MASK]", "model_max_length": 512, "never_split": null, "pad_token": "[PAD]", "sep_token": "[SEP]", "strip_accents": null, "tokenize_chinese_chars": true, "tokenizer_class": "BertTokenizer", "unk_token": "[UNK]"}README.md+61-3
special_tokens_map.jsonAdded+37
tokenizer_config.jsonAdded+849
vocab.txtAdded