Skip to main content

bulk-chain 1.3.0

twitter PyPI downloads

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 venv customization.
  • ✅ 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 we use JSON format. The field schema is a list of CoT instructions for the Large Language Model. Each item of the list represent a dictionary with prompt and out keys that corresponds to the input prompt and output variable name respectively. All the variable names should be mentioned in {}.

Example:

[
  {"prompt": "extract topic: {text}", "out": "topic"},
  {"prompt": "extract subject: {text}", "out": "subject"},
]

Usage

🤖 Prepare

  1. schema
  2. LLM model from the Third-party providers hosting↗️.
  3. 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=[
      {"prompt": "extract topic: {text}", "out": "topic" },
      {"prompt": "extract subject: {text}", "out": "subject"},
    ],
    # 2. Your third-party model implementation.
    llm=dynamic_init(class_filepath="replicate_104.py")(
       api_token="<API-KEY>",
       model_name="meta/meta-llama-3-70b-instruct"),
    # 3. Toggle streaming if needed
    stream=False,
    # 4. Toggle Async API mode usage.
    async_mode=True,
    async_policy='prompt',
    # 5. Batch size.
    batch_size=10,
    # 6. Your iterator of dictionaries
    input_dicts_it=[
        # Example of data ...
        { "text": "Rocks are hard" },
        { "text": "Water is wet" },
        { "text": "Fire is hot" }
    ],
)
    
for batch in content_it:
   for entry in batch:
      print(entry)

Outputs entries represent texts augmented with topic and subject:

{'text': 'Rocks are hard', 'topic': 'The topic is: Geology/Rocks', 'subject': 'The subject is: "Rocks"'}
{'text': 'Water is wet', 'topic': 'The topic is: Properties of Water', 'subject': 'The subject is: Water'}
{'text': 'Fire is hot', 'topic': 'The topic is: Temperature/Properties of Fire', 'subject': 'The subject is: "Fire"'}

API

Methods that accept single prompt:

Method Mode Description
ask(prompt) Sync Infers the model with a single prompt.
ask_stream(prompt) Sync Returns a generator that yields chunks of the inferred result.
ask_async(prompt) Async Asynchronously infers the model with a single prompt.
ask_stream_async(prompt) Async Asynchronously returns a generator of result chunks of the inferred result.

Methods that accept batch:

Method Mode Description
ask_batch(batch) Sync Infers the model with a single prompt.
ask_async_batch(batch) Async Asynchronously infers the model with a single prompt.

See examples with models at nlp-thirdgate 🌌.

Similar Concepts

Primary similarity:

  • LangGraph workflow state
  • ETL/dataflow systems

Minor similarity:

Metadata

Release files for bulk-chain 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bulk-chain 1.3.0
File Size Uploaded Provenance Actions
bulk_chain-1.3.0.tar.gz 14.6 kB Without provenance Details for bulk_chain-1.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bulk-chain 1.3.0
File Interpreter ABI Platform Actions
bulk_chain-1.3.0-py3-none-any.whl Python 3 none any Details for bulk_chain-1.3.0-py3-none-any.whl

Total release size: 27.7 kB

Release files / bulk_chain-1.3.0.tar.gz

Download URL bulk_chain-1.3.0.tar.gz
Size 14.6 kB
Tags Source
SHA-256 checksum
How to use checksums
fe87a98f3666c397de173b6fbf5fe1f74a9b327ed37ac9957e6e58bb1e66c376
BLAKE2b-256 checksum
How to use checksums
2886c6eb63181dbb68f750c5e6fc7902b548b567d066ba83a8df335ef8c8f500
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.5

Release files / bulk_chain-1.3.0-py3-none-any.whl

Download URL bulk_chain-1.3.0-py3-none-any.whl
Size 13.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c624774605502be6383322c749386d0513428474e3b00dfeb129299d6909f5b7
BLAKE2b-256 checksum
How to use checksums
05670bc1a84554dcfb136cf0eb42c3a2fe079fe2b2a093c15f1636acad04e444
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.5

Security for bulk-chain 1.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page