--- license: apache-2.0 language: - en pipeline_tag: text2text-generation --- **flan-t5-small-for-classification** This is an additional fine-tuned [flan-t5-large](https://huggingface.co/google/flan-t5-large) 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-large-for-classification") model = T5ForConditionalGeneration.from_pretrained("knowledgator/flan-t5-large-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-large-for-classification', tokenizer='knowledgator/flan-t5-large-for-classification', ) output = classifier.invoke(input_text) print(output) ```