Skip to main content

A library, based on PyTorch, that implements bertserini code.

Project description

Bertserini-on-Telegram

schema.jpeg

Bertserini-on-Telegram is a pytorch Bertserini implementation with a small utility to plug it in a Telegram bot. The models and dataloaders are written in PyTorchLightning, and are usable on their own, or via PyTorchLightning CLI.

Project Structure

A typical top-level directory layout

.
├── bertserini_on_telegram      # Actual project code
|    ├── data                   # contains the DataModules to handle SQuAD V1.1
|    ├── models                 # holds the Modules to run validation and inference with BERT
|    └── utils                  # general helper functions
├── examples                    # Example scripts of how to run the code
├── LICENSE
└── README.md

Installation

Install via pip

pip install bertserini-on-telegram

Usage

The fastest way to learn how to use this package is by heading on tothe examples folder, and have a look at the python scripts saved in there. In each example folder, there is a config.yaml file holding the run parameters, a script.py file where the actual example code is, and a runnable script.sh file that shows how to run a PytorchLightningCli script with a config file.

To run an example, simply

cd examples/<example_dir>
./example_shell_script.sh

Running it on Telegram

The telegram example supposes that the used knows how to create a Telegram bot in the first place. Telegram has an awesome tutorial on how to do it, you can find it here.

Once the bot is online, the next step is to insert the bot's private token into the config.yaml file, as shown below (the file needs to be created)

./example/telegram_bot/telegram_token_id.yaml

token_id: <token_id>

Be careful when adding a bot to a group, it must have the necessary permission to be able to read the messages.

Now just run the example as shown in the snippet below, and you are good to go :)

cd examples/telegram_bot
./run_bertbot.sh

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

bertserini_on_telegram-1.2.tar.gz (24.8 kB view hashes)

Uploaded Source

Built Distribution

bertserini_on_telegram-1.2-py3-none-any.whl (20.6 kB view hashes)

Uploaded Python 3

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