Automatically mask sentences from a given input where certain words vary, and fil-mask from given candidates
Project description
autoFillMaskWithCandidates
Under construction! Not ready for use yet! Currently experimenting and planning!
Developed by Elatot (c) 2024
PyTorch and Transformers
This Python package provides advanced text processing functionalities utilizing PyTorch and Hugging Face's Transformers library. It includes capabilities for setting up a tokenizer and model from Hugging Face, automatically masking differing words in sentences, calculating the probability of candidate words, and more.
Features
- Initialize tokenizer and model from Hugging Face's Transformer library.
- Automatically mask differing words in a set of input sentences.
- Calculate the probability of a candidate word.
- Show masked inputs and provide scores for candidate words.
- Replace masked words with the most probable candidates.
Installation
- To use this package, you need to have Python installed on your system, along with PyTorch and the Transformers library. If you haven't installed these dependencies yet, you can do so using pip:
pip install torch transformers
pip install autoFillMaskWithCandi==0.0.3
Examples of Usage
from autoFillMaskWithCandi import setTokenModel, show_mask_fill, mask_fill_replaced
# Set the model for tokenizer
model_name = "Your-Model-Name-Here"
setTokenModel(model_name)
# Example sentences
input_sentences = [
"maling hindi maligo",
"maling hindi malego"
]
# Show masked input and scores for candidate words
show_mask_fill(input_sentences)
# Print the sentence with masked words replaced
print(mask_fill_replaced(input_sentences))
- Replace "Your-Model-Name-Here" with the model name you want to use from Hugging Face.
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 autoFillMaskWithCandi-0.0.3.tar.gz
.
File metadata
- Download URL: autoFillMaskWithCandi-0.0.3.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21a3415062e7f02227281aab0d37ab88bf784ec5d03c1214060c6480d9d27ac7 |
|
MD5 | a07985d5e6405d263f68957bcb527612 |
|
BLAKE2b-256 | e1e4912271f43bcce77f62f92a1bce72e903f52fedde4794e24eeee950807ed1 |
File details
Details for the file autoFillMaskWithCandi-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: autoFillMaskWithCandi-0.0.3-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8fbcb06657581e6fbfba58190063f8bee22bd97385c95b744f2ec0efb0ac2756 |
|
MD5 | 19547bc645a75d66b8363aca165908b6 |
|
BLAKE2b-256 | bf2bf44000e5453aa8529a7564a96b6a80c492f13e609c23b5c120579765fe48 |