Lingua-SDK
A user toolkit for analyzing and interfacing with Large Language Models (LLMs)
Overview
lingua-sdk is a Python module used to interact with large language models
hosted via the Lingua service (available at https://github.com/VectorInstitute/lingua).
It provides a simple interface launch LLMs on an HPC cluster, ask them to
perform basic features like text generation, but also retrieve intermediate
information from inside the model such as log probabilities and activations.
These features are exposed via a few high-level APIs, namely:
generate- Returns an LLM text generation based on prompt inputmodule_names- Returns all modules in the LLM neural networkmodel_instances- Returns all active LLMs instantiated and avaiable to useget_activations- Retrieves all activations for a set of modules
Full documentation and API reference are available at http://lingua-sdk.readthedocs.io.
Getting Started
Install
python3 -m pip install pylingua
or install from source:
pip install git+https://github.com/VectorInstitute/lingua-sdk.git
Authentication
In order to submit generation jobs, a designated Vector Institute cluster account is required. Please contact the AI Engineering Team in charge of Lingua for more information.
Sample Workflow
The following workflow shows how to load and interact with an OPT-175B model on the Vector Institute Vaughan cluster.
import lingua
import time
# Establish a client connection to the Lingua service
# If you have not previously authenticated with the service, you will be prompted to now
client = lingua.Client(gateway_host="llm.cluster.local", gateway_port=3001)
# See which models are available to use
print(client.models)
# Get a handle to a model. If this model is not actively running, it will get launched in the background.
# In this example we want to use the OPT-175B model
opt_model = client.load_model("OPT-175B")
# If not the was not actively running, this it could take several minutes to load. Wait for it come online.
while opt_model.state != "ACTIVE":
time.sleep(1)
# Sample text generation w/ input parameters
text_gen = opt_model.generate("What is the answer to life, the universe, and everything?", {'max_tokens': 5, 'top_k': 4, 'top_p': 3, 'rep_penalty': 1, 'temperature': 0.5})
dir(text_gen) # display methods associated with generated text object
text_gen.generation['text'] # display only text
text_gen.generation['logprobs'] # display logprobs
text_gen.generation['tokens'] # display tokens
# Now let's retrieve some activations from the model
# First, show a list of modules in the neural network
print(opt_model.module_names)
# Setup a request for module acivations for a certain module layer
requested_activations = ['_fsdp_wrapped_module._fpw_module.decoder.layers.0._fsdp_wrapped_module._fpw_module']
activations = opt_model.get_activations("What are activations?", requested_activations)
print(activations)
Documentation
More information can be found on the Lingua documentation site.
Contributing
Contributing to lingua is welcomed. See Contributing for guidelines.
License
Citation
Reference to cite when you use Lingua in a project or a research paper:
Sivaloganathan, J., Coatsworth, M., Willes, J., Choi, M., & Shen, G. (2022). Lingua. http://VectorInstitute.github.io/lingua. computer software, Vector Institute for Artificial Intelligence. Retrieved from https://github.com/VectorInstitute/lingua-sdk.git.
Metadata
Release files for pylingua 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pylingua-0.3.0.tar.gz | 6.7 kB | Without provenance | Details for pylingua-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pylingua-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for pylingua-0.3.0-py3-none-any.whl |
Total release size: 14.4 kB
Release files / pylingua-0.3.0.tar.gz
| Download URL | pylingua-0.3.0.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4ec2dbd85df3f9fc4a65388892fd7d84570d89138c1b88f5ded328be37bb9e92
|
|
BLAKE2b-256 checksum How to use checksums |
5e8e0854f3f8d6bbe9588b9109bcf833d4a16897ba4212514f43622ba6885ebb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.0
|
Release files / pylingua-0.3.0-py3-none-any.whl
| Download URL | pylingua-0.3.0-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1058a1ca4fe3853a88282350904dfb3d9f86723ab904db242e49534519f3fe1f
|
|
BLAKE2b-256 checksum How to use checksums |
af404356cb61ad4fb31c740f2bdc6be71ffff4eedc257e8e2f87ea3dc75a278f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.0
|
Security for pylingua 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.