Ihor commited on
Commit
2ca5909
1 Parent(s): 7f23c9e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +62 -3
README.md CHANGED
@@ -1,3 +1,62 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - MoritzLaurer/synthetic_zeroshot_mixtral_v0.1
5
+ language:
6
+ - en
7
+ metrics:
8
+ - f1
9
+ pipeline_tag: zero-shot-classification
10
+ tags:
11
+ - text classification
12
+ - zero-shot
13
+ - small language models
14
+ - RAG
15
+ - sentiment analysis
16
+ ---
17
+
18
+ # ⭐ GLiClass: Generalist and Lightweight Model for Sequence Classification
19
+
20
+ This is an efficient zero-shot classifier inspired by [GLiNER](https://github.com/urchade/GLiNER/tree/main) work. It demonstrates the same performance as a cross-encoder while being more compute-efficient because classification is done at a single forward path.
21
+
22
+ It can be used for `topic classification`, `sentiment analysis` and as a reranker in `RAG` pipelines.
23
+
24
+ The model was trained on synthetic data and can be used in commercial applications.
25
+
26
+ This version of the model uses a layer-wise selection of features that enables a better understanding of different levels of language.
27
+
28
+ ### How to use:
29
+ First of all, you need to install GLiClass library:
30
+ ```bash
31
+ pip install gliclass
32
+ ```
33
+
34
+ Than you need to initialize a model and a pipeline:
35
+ ```python
36
+ from gliclass import GLiClassModel, ZeroShotClassificationPipeline
37
+ from transformers import AutoTokenizer
38
+
39
+ model = GLiClassModel.from_pretrained("knowledgator/gliclass-base-v1.0-lw")
40
+ tokenizer = AutoTokenizer.from_pretrained("knowledgator/gliclass-base-v1.0-lw")
41
+
42
+ pipeline = ZeroShotClassificationPipeline(model, tokenizer, classification_type='multi-label', device='cuda:0')
43
+
44
+ text = "One day I will see the world!"
45
+ labels = ["travel", "dreams", "sport", "science", "politics"]
46
+ results = pipeline(text, labels, threshold=0.5)[0] #because we have one text
47
+
48
+ for result in results:
49
+ print(result["label"], "=>", result["score"])
50
+ ```
51
+
52
+ ### Benchmarks:
53
+ Below, you can see the F1 score on several text classification datasets. All tested models were not fine-tuned on those datasets and were tested in a zero-shot setting.
54
+ | Model | IMDB | AG_NEWS | Emotions |
55
+ |-----------------------------|------|---------|----------|
56
+ | [gliclass-large-v1.0 (438 M)](https://huggingface.co/knowledgator/gliclass-large-v1.0) | 0.9404 | 0.7516 | 0.4874 |
57
+ | [gliclass-base-v1.0 (186 M)](https://huggingface.co/knowledgator/gliclass-base-v1.0) | 0.8650 | 0.6837 | 0.4749 |
58
+ | [gliclass-small-v1.0 (144 M)](https://huggingface.co/knowledgator/gliclass-small-v1.0) | 0.8650 | 0.6805 | 0.4664 |
59
+ | [Bart-large-mnli (407 M)](https://huggingface.co/facebook/bart-large-mnli) | 0.89 | 0.6887 | 0.3765 |
60
+ | [Deberta-base-v3 (184 M)](https://huggingface.co/cross-encoder/nli-deberta-v3-base) | 0.85 | 0.6455 | 0.5095 |
61
+ | [Comprehendo (184M)](https://huggingface.co/knowledgator/comprehend_it-base) | 0.90 | 0.7982 | 0.5660 |
62
+ | SetFit [BAAI/bge-small-en-v1.5 (33.4M)](https://huggingface.co/BAAI/bge-small-en-v1.5) | 0.86 | 0.5636 | 0.5754 |