Skip to main content

🐍 | Python library for langchain using RunPod API endpoint as LLM.

Project description

Installation

# Install the latest release version
pip install runpod-llm

# or

# Install the latest development version (main branch)
pip install git+https://https://github.com/tsangwailam/langchain-runpod-llm

Get Runpod API key

  1. Goto www.runpod.io. Create a RunPod account.
  2. From the portal, goto Settings>APIKeys
  3. Create a new API key by click the "+ API Key" button.

Usage

from runpod_llm import RunpodLlama2

llm = RunpodLlama2(
        apikey="YOU_RUNPOD_API_KEY",
        llm_type="7b|13b",
        config={
            "max_tokens": 500, 
            #Maximum number of tokens to generate per output sequence.
            "n": 1,  # Number of output sequences to return for the given prompt.
            "best_of": 1,  # Number of output sequences that are generated from the prompt. From these best_of sequences, the top n sequences are returned. best_of must be greater than or equal to n. This is treated as the beam width when use_beam_search is True. By default, best_of is set to n.
            "Presence penalty": 0.2,  # Float that penalizes new tokens based on whether they appear in the generated text so far. Values > 0 encourage the model to use new tokens, while values < 0 encourage the model to repeat tokens.
            "Frequency penalty": 0.5,  # Float that penalizes new tokens based on their frequency in the generated text so far. Values > 0 encourage the model to use new tokens, while values < 0 encourage the model to repeat tokens.
            "temperature": 0.3,  # Float that controls the randomness of the sampling. Lower values make the model more deterministic, while higher values make the model more random. Zero means greedy sampling.
            "top_p": 1,  # Float that controls the cumulative probability of the top tokens to consider. Must be in (0, 1]. Set to 1 to consider all tokens.
            "top_k": -1,  # Integer that controls the number of top tokens to consider. Set to -1 to consider all tokens.
            "use_beam_search": False,  # Whether to use beam search instead of sampling.
        },
        verbose=True, # verbose output
    )

    some_prompt_template = xxxxx
    output_chain = some_prompt_template | llm
    output_chain.invoke({"input":"some input to prompt template"})

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

langchain-runpod-llm-0.0.2a0.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_runpod_llm-0.0.2a0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file langchain-runpod-llm-0.0.2a0.tar.gz.

File metadata

  • Download URL: langchain-runpod-llm-0.0.2a0.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for langchain-runpod-llm-0.0.2a0.tar.gz
Algorithm Hash digest
SHA256 fc76a70ac863e3b76d39dd90f12c893fd97361888098fa2abdb52cbf3baad56d
MD5 1f83e85e5b27ec492744ac8beeadab05
BLAKE2b-256 33b12cca821212e1684b6584c963aca188e5d3850dc011618dd53e5ce5d73828

See more details on using hashes here.

File details

Details for the file langchain_runpod_llm-0.0.2a0-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_runpod_llm-0.0.2a0-py3-none-any.whl
Algorithm Hash digest
SHA256 0cf68c01c903edd2fef8be7fa2cdc2615fce0606a1a3595a2617f452a26307aa
MD5 411751ccc947a2ddb7d12e9c7d489077
BLAKE2b-256 449e61e1293bc307a32f093abb5773e2d8a4d958b1f789aed5d11871f6455e93

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page