Skip to main content

Machine learning library for pop projects

Project description

Made with pop, a Python implementation of Plugin Oriented Programming Documentation is published with Sphinx on GitLab Pages Made with Python

pop-ml is a Python library that simplifies the integration of AI-powered capabilities into any POP-based Python project.

About

pop-ml is a comprehensive Python library designed to facilitate the integration of AI- powered capabilities, such as translation, into POP-based Python projects.

pop-ml currently provides developers with an easy-to-use and seamless translation experience, allowing them to translate strings to other languages, such as english to spanish.

The library currently supports making use of Hugging Face Transformers library and can utilize pretrained tokenizers for delivering accurate and efficient translations. By leveraging state-of-the-art language models, pop-ml ensures high-quality translations while maintaining simplicity in its API.

What is POP?

This project is built with pop, a Python-based implementation of Plugin Oriented Programming (POP). POP seeks to bring together concepts and wisdom from the history of computing in new ways to solve modern computing problems.

For more information:

Getting Started

Prerequisites

  • Python 3.8+

  • git (if installing from source, or contributing to the project)

Installation

If wanting to use pop-ml, you can do so by either installing from PyPI or from source.

Install from PyPI

To install pop-ml from PyPI, simply run the following command:

pip install pop-ml

This will install the latest version of pop-ml, along with all required dependencies.

Install from source

To install pop-ml from source, first clone the repository from GitLab:

git clone https://gitlab.com/vmware/pop/pop-ml.git

Next, navigate to the cloned repository directory:

cd pop-ml

Finally, install the package using pip:

pip install .

Usage

pop-ml can be used both as a command-line tool (pop-translate) and as a Python library. Below are examples of how to use pop-ml in both ways.

CLI Examples

To use the pop-translate command-line tool, you can pass the text you want to translate as an argument, along with any additional options:

pop-translate "Hello, World!" --translate-to es

This command will translate the input text “Hello, world!” from English (en) to Spanish (es).

To see a full list of available options, run:

pop-translate --help

Python Examples

Here is an example of how to use pop-ml as a Python library:

import pop.hub

# Initialize the hub
hub = pop.hub.Hub()

# Add the "ml" dynamic namespace to the hub
hub.pop.sub.add(dyne_name="ml")

# Load config values onto hub.OPT
hub.pop.config.load(["pop_ml"], cli="pop_ml")

# Call the idempotent "init" of pop-ml's tokenizer using values from config
hub.ml.tokenizer.init(
    model_name=hub.OPT.pop_ml.model_name,
    dest_lang=hub.OPT.pop_ml.dest_lang,
    source_lang=hub.OPT.pop_ml.source_lang,
    pretrained_model=hub.OPT.pop_ml.pretrained_model_class,
    pretrained_tokenizer=hub.OPT.pop_ml.pretrained_tokenizer_class,
)
# Call the function to translate the text
result = hub.ml.tokenizer.translate([text])
print(result)

In this example, we initialize the hub, load the “ml” dynamic namespace and config values onto it, initialize the tokenizer, and call the function to translate the text. The output will be the translated text.

Roadmap

Reference the open issues for a list of proposed features (and known issues).

Acknowledgements

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

pop-ml-0.2.0.tar.gz (14.0 kB view hashes)

Uploaded Source

Built Distribution

pop_ml-0.2.0-py3-none-any.whl (13.4 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