File size: 1,881 Bytes
2f89ddd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
---
license: apache-2.0
language:
- en
pipeline_tag: text2text-generation
---
**flan-t5-small-for-classification**
<img src="https://github.com/Knowledgator/unlimited_classifier/raw/main/images/tree.jpeg" style="display: block; margin: auto;" height="720" width="720">
This is an additional fine-tuned [flan-t5-base](https://huggingface.co/google/flan-t5-base) model on many classification datasets.
The model supports prompt-tuned classification and is suitable for complex classification settings such as resumes classification by criteria.
You can use the model simply generating the text class name or using our [unlimited-classifier](https://github.com/Knowledgator/unlimited_classifier).
The library allows to set constraints on generation and classify text into millions of classes.
### How to use:
To use it with transformers library take a look into the following code snippet:
```python
# pip install accelerate
from transformers import T5Tokenizer, T5ForConditionalGeneration
tokenizer = T5Tokenizer.from_pretrained("knowledgator/flan-t5-base-for-classification")
model = T5ForConditionalGeneration.from_pretrained("knowledgator/flan-t5-base-for-classification", device_map="auto")
input_text = "Define sentiment of the following text: I love to travel and someday I will see the world."
input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
outputs = model.generate(input_ids)
print(tokenizer.decode(outputs[0]))
```
**Using unlimited-classifier**
```python
# pip install unlimited-classifier
from unlimited_classifier import TextClassifier
classifier = TextClassifier(
labels=[
'positive',
'negative',
'neutral'
],
model='knowledgator/flan-t5-base-for-classification',
tokenizer='knowledgator/flan-t5-base-for-classification',
)
output = classifier.invoke(input_text)
print(output)
```
|