.ipynb
.pdf
Beam
Beam#
Beam makes it easy to run code on GPUs, deploy scalable web APIs,
schedule cron jobs, and run massively parallel workloads — without managing any infrastructure.
Calls the Beam API wrapper to deploy and make subsequent calls to an instance of the gpt2 LLM in a cloud deployment. Requires installation of the Beam library and registration of Beam Client ID and Client Secret. By calling the wrapper an instance of the model is created and run, with returned text relating to the prompt. Additional calls can then be made by directly calling the Beam API.
Create an account, if you don’t have one already. Grab your API keys from the dashboard.
Install the Beam CLI
!curl https://raw.githubusercontent.com/slai-labs/get-beam/main/get-beam.sh -sSfL | sh
Register API Keys and set your beam client id and secret environment variables:
import os
import subprocess
beam_client_id = "<Your beam client id>"
beam_client_secret = "<Your beam client secret>"
# Set the environment variables
os.environ['BEAM_CLIENT_ID'] = beam_client_id
os.environ['BEAM_CLIENT_SECRET'] = beam_client_secret
# Run the beam configure command
!beam configure --clientId={beam_client_id} --clientSecret={beam_client_secret}
Install the Beam SDK:
!pip install beam-sdk
Deploy and call Beam directly from langchain!
Note that a cold start might take a couple of minutes to return the response, but subsequent calls will be faster!
from langchain.llms.beam import Beam
llm = Beam(model_name="gpt2",
           name="langchain-gpt2-test",
           cpu=8,
           memory="32Gi",
           gpu="A10G",
           python_version="python3.8",
           python_packages=[
rtdocs_stable/api.python.langchain.com/en/stable/modules/models/llms/integrations/beam.html