Instructions to use encodingai/electra-base-discriminator-im-multilabel with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use encodingai/electra-base-discriminator-im-multilabel with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="encodingai/electra-base-discriminator-im-multilabel")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("encodingai/electra-base-discriminator-im-multilabel") model = AutoModelForSequenceClassification.from_pretrained("encodingai/electra-base-discriminator-im-multilabel", device_map="auto") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from encodingai/electra-base-discriminator-im-multilabel: direct link, hf CLI and curl.
- Browser
- Download file 4.31 kB
-
https://huggingface.co/encodingai/electra-base-discriminator-im-multilabel/resolve/main/README.md
- Command line
-
hf download hf://encodingai/electra-base-discriminator-im-multilabel/README.md
-
curl -L -H "Authorization: Bearer $HF_TOKEN" -o README.md https://huggingface.co/encodingai/electra-base-discriminator-im-multilabel/resolve/main/README.md
4.31 kB
| license: cc-by-nc-nd-4.0 | |
| language: | |
| - en | |
| library_name: transformers | |
| pipeline_tag: text-classification | |
| widget: | |
| - text: "Mr. Jones, an architect is going to surprise his family by building them a new house." | |
| example_title: "Pow" | |
| - text: "They want the research to go well and be productive." | |
| example_title: "Ach" | |
| - text: "The man is trying to see a friend on board, but the officer will not let him go as the whistle for all ashore who are not going has already blown." | |
| example_title: "Aff" | |
| - text: "The recollection of skating on the Charles, and the time she had pushed me through the ice, brought a laugh to the conversation; but it quickly faded in the murky waters of the river that could no longer freeze over." | |
| example_title: "Pow + Aff" | |
| - text: "They are also well-known research scientists and are quite talented in this field." | |
| example_title: "Pow + Ach" | |
| - text: "After a nice evening with his family, he will be back at work tomorrow, doing the best job he can on his drafting." | |
| example_title: "Ach + Aff" | |
| - text: "She is surprised that she is able to make these calls and pleasantly surprised that her friends respond to her request." | |
| example_title: "Pow + Aff" | |
| This is an updated version of the classifier reported in [Pang & Ring (2020)](https://rdcu.be/b38pm) | |
| and found at [implicitmotives.com](https://implicitmotives.com). The classifier identifies the | |
| presence of implicit motive imagery in sentences, namely the three felt needs for Power, Achievement, | |
| and Affiliation. | |
| The current classifier is finetuned from ELECTRA-base and achieves > 0.86 Pearson correlation on the | |
| Winter (1994) training data (see the [OSF repo](https://osf.io/563xn) for the benchmark dataset, or follow this [direct link](https://osf.io/6fnz5)). | |
| Development of this classifier is ongoing, as it achieves only > ~0.7 Pearson correlation on larger | |
| unseen datasets, though all correlations are highly significant. | |
| This model is being made available to other researchers for inference via a Huggingface api. The | |
| current license allows for free use without modification for non-commercial purposes. If you would | |
| like to use this model commercially, get in touch with us for access to our most recent model. | |
| ``` | |
| Predictions on Winter manual dataset | |
| ----- | |
| Pearson correlations: | |
| | Pow (Label_0): 0.81695 | | |
| | Ach (Label_1): 0.92673 | | |
| | Aff (Label_2): 0.85618 | | |
| | mean: 0.86544 | | |
| Category agreement: | |
| | Pow (Label_0): | 0.84034 | | |
| | Ach (Label_1): | 0.93274 | | |
| | Aff (Label_2): | 0.87429 | | |
| | mean: | 0.88163 | | |
| Intra-class Correlation Coefficient: | |
| | Pow (Label_0): | 0.89889 | | |
| | Ach (Label_1): | 0.96200 | | |
| | Aff (Label_2): | 0.92231 | | |
| | mean: | 0.92736 | | |
| ``` | |
| ## Inference guide | |
| The inference api requires a Huggingface token. The sample code below illustrates how it can be used to classify individual sentences. | |
| ```python | |
| import json | |
| import requests | |
| api_key = "<HF Token>" | |
| headers = {"Authorization": f"Bearer {api_key}"} | |
| api_url = "https://api.url.here" | |
| # This is a sentence from the Winter manual that is dual-scored for both Pow and Aff | |
| prompt = """The recollection of skating on the Charles, and the time she had | |
| pushed me through the ice, brought a laugh to the conversation; but | |
| it quickly faded in the murky waters of the river that could no | |
| longer freeze over.""" | |
| # Since this is a multilabel classifier, we want to return scores for the top 3 labels | |
| data = {"inputs": prompt, "parameters": {"top_k": 3}} | |
| response = requests.request("POST", api_url, headers=headers, json=data) | |
| # The labels are arranged according to likelihood of classification | |
| repdict = {"LABEL_0": "Pow", "LABEL_1": "Ach", "LABEL_2": "Aff"} | |
| # so we replace them in the output | |
| scores = {repdict[x['label']]: x['score'] for x in response.json()} | |
| print(scores) | |
| # output: {'Pow': 0.8279141187667847, 'Aff': 0.7250356674194336, 'Ach': 0.0020263446494936943} | |
| ``` | |
| ## References | |
| McClelland, D. C. (1965). Toward a theory of motive acquisition. American Psychologist, 20,321-333. | |
| Pang, J. S., & Ring, H. (2020). Automated Coding of Implicit Motives: A Machine-Learning Approach. | |
| Motivation and Emotion, 44(4), 549-566. DOI: 10.1007/s11031-020-09832-8. | |
| Winter, D.G. (1994). Manual for scoring motive imagery in running text. Unpublished Instrument. Ann Arbor: University of Michigan. |