Ihor commited on
Commit
4910d3c
1 Parent(s): 749586c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +67 -3
README.md CHANGED
@@ -1,3 +1,67 @@
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
+ To use this particular Qwen-based model you need different `transformers` package version than llm2vec requires, so install it manually:
39
+ ```bash
40
+ pip install transformers==4.44.1
41
+ ```
42
+
43
+ Than you need to initialize a model and a pipeline:
44
+ ```python
45
+ from gliclass import GLiClassModel, ZeroShotClassificationPipeline
46
+ from transformers import AutoTokenizer
47
+
48
+ model = GLiClassModel.from_pretrained("knowledgator/gliclass-qwen-0.5B-v1.0")
49
+ tokenizer = AutoTokenizer.from_pretrained("knowledgator/gliclass-qwen-0.5B-v1.0")
50
+
51
+ pipeline = ZeroShotClassificationPipeline(model, tokenizer, classification_type='multi-label', device='cuda:0')
52
+
53
+ text = "One day I will see the world!"
54
+ labels = ["travel", "dreams", "sport", "science", "politics"]
55
+ results = pipeline(text, labels, threshold=0.5)[0] #because we have one text
56
+
57
+ for result in results:
58
+ print(result["label"], "=>", result["score"])
59
+ ```
60
+
61
+ ### Benchmarks:
62
+ 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.
63
+ ![Few-shot performance](few_shot.png)
64
+
65
+ ### Join Our Discord
66
+
67
+ Connect with our community on Discord for news, support, and discussion about our models. Join [Discord](https://discord.gg/dkyeAgs9DG).