Skip to main content

A Pytorch-based package by LightOn AI Research allowing to perform inference with PAGnol models.

Project description

LairGPT

GitHub license Twitter

A Python package in Pytorch by LightOn AI Research that allows to perform inference with PAGnol models. You can test the generation capabilities of PAGnol on our interactive demo website.

Install

Requirements

The package is tested with Python 3.9. After cloning this repository, you can create a conda environment with the necessary dependencies from its root by

conda env create --file=environment.yml

If you prefer control on your environment, the dependencies are

pytorch==1.8.1
tokenizers==0.10
python-wget==3.2

pip

Simply run pip install . from the root of this repository.

Text generation

The simplest way to generate text with PAGnol using lairgpt is

from lairgpt.models import PAGnol

pagnol = PAGnol.small()
pagnol("Salut PAGnol, comment ça va ?")

We include a demo script main.py in this repository that takes the path to models and tokenizers, and an input text, and generates sentences from it. To use it:

python main.py --size large --text "LightOn est une startup technologique"

To generate text we rely on the infer method of the TextGenerator class that takes the usual parameters:

  • mode: (default: "nucleus")
    • "greedy": always select the most likely word as its next word.
    • "top-k": filter to the K most likely next words and redistribute the probability mass among only those K next words.
    • "nucleus": filter to the smallest possible set of words whose cumulative probability exceeds the probability p and redistribute the probability mass among this set of words.
  • temperature: a control over randomness. As this value approaches zero, the model becomes more deterministic. (default: 1.0)
  • k: size of the set of words to consider for "top-k" sampling (default: 5)
  • p: a control over diversity in nucleus sampling. A value of 0.5 means that half of the options are considered. (default: 0.9)
  • max_decoding_steps: number of tokens to generate. (default: 32)
  • skip_eos: when True, generation does not stop at end of sentence. (default: True)

More on LightOn

LightOn is a company that produces hardware for machine learning. To lease a LightOn Appliance, please visit: https://lighton.ai/lighton-appliance/

To request access to LightOn Cloud and try our photonic co-processor, please visit: https://cloud.lighton.ai/ For researchers, we also have a LightOn Cloud for Research program, please visit https://cloud.lighton.ai/lighton-research/ for more information.

Citation

We will soon have a preprint on arXiv, stay tuned ;)

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

lairgpt-0.5.2-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file lairgpt-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: lairgpt-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.1

File hashes

Hashes for lairgpt-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9fd53e3acf05cb2e27d18d1c4cb4205ab6739c1737231e13d513e629f00cbd18
MD5 0d7c7f9829944aafda7a527008e2f457
BLAKE2b-256 721b2baae81bc6a347c6e43054584b1876bc405d4cc06a5b33228ef748d362c3

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