A Python package for text classification using transformer models.
Project description
TextPredict
Advanced Text Classification with Transformer Models
TextPredict is a powerful Python package designed for text classification tasks leveraging advanced transformer models. It supports a variety of tasks including sentiment analysis, emotion detection, and zero-shot classification, making it an essential tool for developers and data scientists working in natural language processing (NLP), machine learning (ML), and artificial intelligence (AI).
Features
- Sentiment Analysis: Classify text based on sentiment with high accuracy.
- Emotion Detection: Detect emotions in text effortlessly.
- Zero-Shot Classification: Classify text into unseen categories without any additional training.
- Fine-Tuning: Easily fine-tune models to improve performance on specific datasets.
- Model Evaluation: Evaluate model performance with robust metrics.
- Distributed Training: Support for distributed training to leverage multiple GPUs.
Installation
pip install textpredict
Usage
Sentiment Analysis
from textpredict import TextPredict
tp = TextPredict()
result = tp.analyse("I love using this package!", task="sentiment")
print(result)
Emotion Detection
result = tp.analyse("I am excited about this!", task="emotion")
print(result)
Zero-Shot Classification
result = tp.analyse(
"This package is great for zero-shot learning.",
task="zeroshot",
class_list=["positive", "negative", "neutral"],
)
print(result)
Fine-Tuning Models
from datasets import load_dataset
# Load dataset
dataset = load_dataset("imdb")
# Fine-tune model
tp.tune_model(
task="sentiment",
training_data=dataset["train"],
eval_data=dataset["test"],
num_train_epochs=1,
batch_size=8,
learning_rate=2e-5,
early_stopping_patience=3,
)
Evaluating Models
metrics = tp.evaluate_model(task="sentiment", eval_data=dataset["test"])
print("Evaluation metrics:", metrics)
Saving and Loading Models
tp.save_model(task="sentiment", output_dir="./fine_tuned_sentiment_model")
tp.load_model(task="sentiment", model_dir="./fine_tuned_sentiment_model")
result = tp.analyse("I love using this package after fine-tuning!", task="sentiment")
print(result)
Contributing
Contributions are welcome! Please feel free to submit a pull request or open an issue on GitHub.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Links
- GitHub Repository: Github
- PyPI Project: PYPI
- Documentation: Readthedocs
- Source Code: Source Code
- Issue Tracker: Issue Tracker
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for textpredict-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cbc9cd94566d702f61d15edaeb44523ddf8576cc3d9509e70ee3b5da0e957ea |
|
MD5 | edf0e74b9bc7f8b181ba649a5ac26412 |
|
BLAKE2b-256 | 21e9a8b65d418776fdf84488c716ed02dcea20c9b079a93da6eaca5ea3bb5a86 |