Skip to main content

A lightweight, no-strings-attached Chain-of-Thought framework for your LLM, ensuring reliable results for bulk input requests.

Project description

bulk-chain 0.24.2

twitter

A lightweight, no-strings-attached Chain-of-Thought framework for your LLM, ensuring reliable results for bulk input requests stored in CSV / JSONL / sqlite. It allows applying series of prompts formed into schema (See related section)

Features

  • No-strings: you're free to LLM dependencies and flexible venv customization.
  • Provides iterator over infinite amount of input contexts served in CSV/JSONL.
  • Progress caching: withstanding exception during LLM calls by using sqlite3 engine for caching LLM answers;
  • Support schemas descriptions for Chain-of-Thought concept.

Installation

pip install bulk-chain

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"},
]
}

Another templates are available here.

Usage

Just three simple steps:

  1. Define your CoT Schema, or fetch it as shown below:
!wget https://raw.githubusercontent.com/nicolay-r/bulk-chain/refs/heads/master/ext/schema/default.json
  1. Fetch or write your own model or pick the one preset here:
!wget https://raw.githubusercontent.com/nicolay-r/bulk-chain/refs/heads/master/ext/flan_t5.py
  1. Launch inference in (chat mode):
!python -m bulk_chain.infer \
    --schema "default.json" \
    --adapter "dynamic:flan_t5.py:FlanT5" \
    %% \
    --device "cpu" \
    --temp 0.1

Embed your LLM

All you have to do is to implement BaseLM class, that includes:

  • __init__ -- for initialization;
  • ask(prompt) -- infer your model with the given prompt.

See examples with models here.

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

bulk_chain-0.24.2.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

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

bulk_chain-0.24.2-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file bulk_chain-0.24.2.tar.gz.

File metadata

  • Download URL: bulk_chain-0.24.2.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.5

File hashes

Hashes for bulk_chain-0.24.2.tar.gz
Algorithm Hash digest
SHA256 54848d24d4f8a44b5daceef52fc3d3febe1be822a18afb526313fbc06c14a6c2
MD5 f28b39450c607355c259df02bd617d79
BLAKE2b-256 0c0cc326c39dc39f1c46086f9c5217dd7aaaebb533f102d5837581638b18b628

See more details on using hashes here.

File details

Details for the file bulk_chain-0.24.2-py3-none-any.whl.

File metadata

  • Download URL: bulk_chain-0.24.2-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.5

File hashes

Hashes for bulk_chain-0.24.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a8d8f40d5b5a46955bcd3b11a05143e318a6db3b63948740962a050d3d17fd84
MD5 308fc5ebb3dc1e8e9b2a28995a02cd97
BLAKE2b-256 c5d37e8a59c2b7668dfca21b6c48723a7bf72a5f01752edb442ac9e9d578d524

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