A python library based on transformers for transfer learning
Project description
Predacons
Predacons is a Python library based on transformers used for transfer learning. It offers a suite of tools for data processing, model training, and text generation, making it easier to apply advanced machine learning techniques to your projects.
Installation
To install Predacons, use the following pip command:
pip install predacons
Usage
Here's a quick start guide to using Predacons in your Python projects:
from predacons import predacons
# Initialize the library
predacons.rollout()
# Load documents from a directory
predacons.read_documents_from_directory('your/directory/path')
# Clean text data
cleaned_text = predacons.clean_text("Your dirty text here")
# Train a model with your data
predacons.train(train_file_path="path/to/train/file",
model_name="your_model_name",
output_dir="path/to/output/dir",
overwrite_output_dir=True,
per_device_train_batch_size=4,
num_train_epochs=3,
save_steps=100)
# Generate text using a trained model
generated_text = predacons.generate_text(model_path="path/to/your/model",
sequence="Seed text for generation",
max_length=50)
#
# Stream text generation using a trained model
for text in predacons.text_stream(model_path="path/to/your/model",
sequence="Seed text for generation",
max_length=50):
print(text)
# Get text streamer
thread,streamer = predacons.text_generate(model=model, tokenizer = tokenizer, sequence = seq, max_length=100, temperature=0.1,stream=True)
thread.start()
try:
out = ""
for new_text in streamer:
out = out + new_text
print(new_text, end=" ")
finally:
thread.join()
# Generate chat using a trained model
chat = [
{"role": "user", "content": "Hey, what is a car?"}
]
chat_output = predacons.chat_generate(model = model,
sequence = chat,
max_length = 50,
tokenizer = tokenizers,
trust_remote_code = True)
# Stream chat generation using a trained model
for chat in predacons.chat_stream(model = model,
sequence = chat,
max_length = 50,
tokenizer = tokenizers,
trust_remote_code = True):
print(chat)
# get chat streamer
thread,streamer = predacons.chat_generate(model=model, tokenizer = tokenizer, sequence = chat, max_length=500, temperature=0.1,stream=True)
thread.start()
try:
out = ""
for new_text in streamer:
out = out + new_text
print(new_text, end="")
finally:
thread.join()
# Generate embeddings for sentences
from predacons.src.embeddings import PredaconsEmbedding
# this embedding_model object can be used directly in every method langchain
embedding_model = PredaconsEmbedding(model_name="sentence-transformers/paraphrase-MiniLM-L6-v2")
sentence_embeddings = embedding_model.get_embedding(["Your sentence here", "Another sentence here"])
Features
Predacons provides a comprehensive set of features for working with transformer models, including:
- Data Loading: Easily load data from directories or files.
- Text Cleaning: Clean your text data with built-in functions.
- Model Training: Train transformer models with custom data.
- Text Generation: Generate text using trained models.
- Text Streaming: Stream text generation using trained models.
- Chat Generation: Generate chat responses using trained models.
- Chat Streaming: Stream chat generation using trained models.
- Embeddings: Generate embeddings for sentences using pre-trained transformer models. and is fully compatible with langchain methods
Contributing
Contributions to the Predacons library are welcome! If you have suggestions for improvements or new features, please open an issue first to discuss your ideas. For code contributions, please submit a pull request.
License
This project is licensed under multiple licenses:
-
For free users, the project is licensed under the terms of the GNU Affero General Public License (AGPL). See
LICENSE-AGPL
for more details. -
For paid users, there are two options:
- A perpetual commercial license. See
LICENSE-COMMERCIAL-PERPETUAL
for more details. - A yearly commercial license. See
LICENSE-COMMERCIAL-YEARLY
for more details.
- A perpetual commercial license. See
Please ensure you understand and comply with the license that applies to you.
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
File details
Details for the file predacons-0.0.127.tar.gz
.
File metadata
- Download URL: predacons-0.0.127.tar.gz
- Upload date:
- Size: 37.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bde6656ef30a7f67ebc717ceca7e8ba193db01dcb27b00223faf953dc57cb1fa |
|
MD5 | 8a9fcad64ae95b547e4bd605497f41b4 |
|
BLAKE2b-256 | 3f828efce39557de3cb480fbcc4aec98dc3e8121b77eec8213fa15807621bee0 |
File details
Details for the file predacons-0.0.127-py3-none-any.whl
.
File metadata
- Download URL: predacons-0.0.127-py3-none-any.whl
- Upload date:
- Size: 44.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad8bc60fb25cc7d54e6a390a325cf264c9ae6c7059ae7677e5f62ed13940e3fc |
|
MD5 | 396a6659d0f30cb2b7179b3345e3669a |
|
BLAKE2b-256 | 3da8362b4630d4d03051a4c1ed6b2d44d0f20bcaa9d1ead255a895b1c4f57811 |