Skip to main content

Automatically mask sentences from a given input where certain words vary, and fil-mask from given candidates

Project description

autoFillMaskWithCandy

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.

Limitations

  • May not be compatible with model using inference key like roBerta LLM. This algorithm uses [CLS] and [SEP] which are compatible with Bert and electra.

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 autoFillMaskWithCandy==0.0.4

Examples of Usage

from autoFillMaskWithCandy 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 = [
    "Pasensya heto lng ako, bobo sa pagaral",
    "Pasensya hito lng ako, bobo sa pagaral",
    "Pasensya heto lng ako, bubo sa pagaral",
    "Pasensya hito lng ako, bubo sa pagaral"
]

# 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

autoFillMaskWithCandy-0.0.4.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

autoFillMaskWithCandy-0.0.4-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file autoFillMaskWithCandy-0.0.4.tar.gz.

File metadata

  • Download URL: autoFillMaskWithCandy-0.0.4.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

Hashes for autoFillMaskWithCandy-0.0.4.tar.gz
Algorithm Hash digest
SHA256 e0e05e48278815e3ec4e551dcabb271c39bd60cc86e4484c3c46da7bbb948137
MD5 c96128515d114d0b22bf3ba7dcc01157
BLAKE2b-256 2fc5efb787ef29216a97a7663a93cf6a7f4430c847cddf5170f945f0bc6e4231

See more details on using hashes here.

File details

Details for the file autoFillMaskWithCandy-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for autoFillMaskWithCandy-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f603766bef9dc4d414d0bf343295c23c7c95743d7e45141f9853edce21a9e110
MD5 21eec9073e9ba80cc35699154721836b
BLAKE2b-256 62bc6c37a22c3e8dc09d584ef3e1dbd53bb41b9801d0dd8ff6b2cb37801c575c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page