Ihor commited on
Commit
7c8985e
1 Parent(s): 9f43e8d

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 utilize the [LLM2Vec](https://github.com/McGill-NLP/llm2vec/tree/main/llm2vec) approach for converting modern decoders to bi-directional encoder. It brings the following benefits:
27
+ * Enhanced performance and generalization capabilities;
28
+ * Support for Flash Attention;
29
+ * Extended context window.
30
+
31
+
32
+ ### How to use:
33
+ First of all, you need to install GLiClass library:
34
+ ```bash
35
+ pip install gliclass
36
+ ```
37
+
38
+ Than you need to initialize a model and a pipeline:
39
+ ```python
40
+ from gliclass import GLiClassModel, ZeroShotClassificationPipeline
41
+ from transformers import AutoTokenizer
42
+
43
+ model = GLiClassModel.from_pretrained("knowledgator/gliclass-large-v1.0-lw")
44
+ tokenizer = AutoTokenizer.from_pretrained("knowledgator/gliclass-large-v1.0-lw")
45
+
46
+ pipeline = ZeroShotClassificationPipeline(model, tokenizer, classification_type='multi-label', device='cuda:0')
47
+
48
+ text = "One day I will see the world!"
49
+ labels = ["travel", "dreams", "sport", "science", "politics"]
50
+ results = pipeline(text, labels, threshold=0.5)[0] #because we have one text
51
+
52
+ for result in results:
53
+ print(result["label"], "=>", result["score"])
54
+ ```
55
+
56
+ ### Benchmarks:
57
+ While the model is some how comparable to DeBERTa version in zero-shot setting, it demonstrates state-of-the-art performance in few-shot setting.
58
+ ![Few-shot performance](few_shot.png)
59
+
60
+ ### Join Our Discord
61
+
62
+ Connect with our community on Discord for news, support, and discussion about our models. Join [Discord](https://discord.gg/dkyeAgs9DG).