Package: pop-ml
pop-mlis a Python library that simplifies the integration of AI-powered
capabilities into any POP-based Python project.Aboutpop-mlis a comprehensive Python library designed to facilitate the integration of AI-
powered capabilities, such as translation, into POP-based Python projects.pop-mlcurrently 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-mlensures high-quality translations while maintaining simplicity in
its API.What is POP?This project is built withpop, a Python-based
implementation ofPlugin 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:Intro to Plugin Oriented Programming (POP)pop-awesomepop-createGetting StartedPrerequisitesPython 3.8+git(if installing from source, or contributing to the project)InstallationNoteIf wanting to contribute to the project, and setup your local development
environment, see theCONTRIBUTING.rstdocument in the source repository
for this project.If wanting to usepop-ml, you can do so by either
installing from PyPI or from source.Install from PyPITo installpop-mlfrom PyPI, simply run the following command:pipinstallpop-mlThis will install the latest version ofpop-ml, along with all required dependencies.Install from sourceTo installpop-mlfrom source, first clone the repository from GitLab:gitclonehttps://gitlab.com/vmware/pop/pop-ml.gitNext, navigate to the cloned repository directory:cdpop-mlFinally, install the package using pip:pipinstall.Usagepop-mlcan be used both as a command-line tool (pop-translate) and as a Python library.
Below are examples of how to usepop-mlin both ways.CLI ExamplesTo use thepop-translatecommand-line tool, you can pass the text you want to translate as
an argument, along with any additional options:pop-translate"Hello, World!"--translate-toesThis 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--helpPython ExamplesHere is an example of how to use pop-ml as a Python library:importpop.hub# Initialize the hubhub=pop.hub.Hub()# Add the "ml" dynamic namespace to the hubhub.pop.sub.add(dyne_name="ml")# Load config values onto hub.OPThub.pop.config.load(["pop_ml"],cli="pop_ml")# Call the idempotent "init" of pop-ml's tokenizer using values from confighub.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 textresult=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.RoadmapReference theopen issuesfor a list of
proposed features (and known issues).AcknowledgementsImg Shieldsfor making repository badges easy.