A lightweight, no-strings-attached Chain-of-Thought framework for your LLM, ensuring reliable results for bulk input requests.
Project description
bulk-chain 1.1.0
Third-party providers hosting↗️
👉demo👈
A no-strings-attached framework for your LLM that allows applying Chain-of-Thought-alike prompt schema towards a massive textual collections using custom third-party providers ↗️.
Main Features
- ✅ No-strings: you're free to LLM dependencies and flexible
venvcustomization. - ✅ Support schemas descriptions for Chain-of-Thought concept.
- ✅ Provides iterator over infinite amount of input contexts
Installation
From PyPI:
pip install --no-deps bulk-chain
or latest version from here:
pip install git+https://github.com/nicolay-r/bulk-chain@master
Chain-of-Thought Schema
To declare Chain-of-Though (CoT) schema, this project exploits JSON format.
This format adopts name field for declaring a name and schema is a list of CoT instructions for the Large Language Model.
Each step represents a dictionary with prompt and out keys that corresponds to the input prompt and output variable name respectively.
All the variable names are expected to be mentioned in {}.
Below, is an example on how to declare your own schema:
{
"name": "schema-name",
"schema": [
{"prompt": "Given the question '{text}', let's think step-by-step.",
"out": "steps"},
{"prompt": "For the question '{text}' the reasoining steps are '{steps}'. what would be an answer?",
"out": "answer"},
]
}
Usage
🤖 Prepare
- schema
- LLM model from the Third-party providers hosting↗️.
- Data (iter of dictionaries)
🚀 Launch
API: For more details see the related Wiki page
from bulk_chain.core.utils import dynamic_init
from bulk_chain.api import iter_content
content_it = iter_content(
# 1. Your schema.
schema="YOUR_SCHEMA.json",
# 2. Your third-party model implementation.
llm=dynamic_init(class_filepath="replicate_104.py", class_name="Replicate")(api_token="<API-KEY>"),
# 3. Customize your inference and result providing modes:
infer_mode="batch_async",
return_mode="batch",
# 4. Your iterator of dictionaries
input_dicts_it=YOUR_DATA_IT,
)
for content in content_it:
# Handle your LLM responses here ...
Embed your LLM
All you have to do is to implement BaseLM class, that includes:
__init__-- for setting up batching mode support and (optional) model name;ask(prompt)-- infer your model with the givenprompt.
See examples with models at nlp-thirdgate 🌌.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bulk_chain-1.1.0.tar.gz.
File metadata
- Download URL: bulk_chain-1.1.0.tar.gz
- Upload date:
- Size: 12.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.67.1 urllib3/1.26.5 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ecb3218c8eebf02cabf1ced098fae3ddbf3b0115a29cd5ba0fd8492dfc2eb8d
|
|
| MD5 |
98aaae9cf213bff6c69bfe86e696c8ce
|
|
| BLAKE2b-256 |
b981e54e2767ecc669bf323d30c9b2c3f5634b22e68e6b7e2f9eea356f5a53cd
|
File details
Details for the file bulk_chain-1.1.0-py3-none-any.whl.
File metadata
- Download URL: bulk_chain-1.1.0-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.67.1 urllib3/1.26.5 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
24273fc9c181de7bc9dba56483aee9917a7a41215b46f8c1219576daa2fdb6c2
|
|
| MD5 |
dec8370b13b7f475b394e1ea96276cb6
|
|
| BLAKE2b-256 |
848f02d9ae4e063e549aa59753672ab3765964f0327c90fbb80c1aeb7a8b6997
|