🐍 | Python library for langchain using RunPod API endpoint as LLM.
Project description
Runpod LLM API Endpoint Lib for LangChain
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
- Goto www.runpod.io. Create a RunPod account.
- From the portal, goto Settings>APIKeys
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for langchain-runpod-llm-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13d2a95dea79cbaf81ebe5094a5705e6aff6925f08c616804a747a9ae64d8c18 |
|
MD5 | bb86aa505fd9f01d0e30e8b68b851ebb |
|
BLAKE2b-256 | 37d7655fd1223daa3915bd945b9b70f44355e4c6ccd4089b94a239c52d32f8cf |
Close
Hashes for langchain_runpod_llm-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37acbf27fa60105524fd455fa25eceb0be351e888a0915e14d5aeae7130dae57 |
|
MD5 | 5ff48d89d53ae65ffdaa7b0b2e272a67 |
|
BLAKE2b-256 | d0a2175d51ccda953ccfc70f165456e506448d00e06e726857b7d6af1e8036a4 |