Skip to main content

a package with modular components for building X of Though (XoT) systems

Project description

XoT: A Modular X of Thought Library

XoT is a Python library designed to facilitate the creation, sharing, and training of X of Thought (XoT) agents. These agents are implemented using modular components known as Strategies, allowing for flexible and composable reasoning systems. Inspired by PyTorch's modular design, DSPy's signature-based approach, and Hugging Face's emphasis on shareability, XoT offers a powerful framework for building multi-modal reasoning pipelines that can be fine-tuned and shared across different tasks and domains.

Installation

pip install xot

TODO

Example Usage

Loading strategy from hub

from xot import AutoStrategy
from datasets import load_dataset

strat = AutoStrategy.from_pretrained('PrimeIntellect/Numina-TIR')
ds = load_dataset('openai/gsm8k')
print(strat)

for q, a in zip(ds['question'], ds['answer'])
    output, log = strat(q, output_log=True)
    print(output, a)

Creating your own strategy and pushing it to the hub

import xot

# Define a simple strategy
class MyStrategy(xot.Strategy):
    def __init__(self):
        super().__init__()
        self.rationale = xot.steps.Rationale("Provide detailed image prompt to improve aesthetics")
        self.image_gen = xot.steps.AutoImageGenerator.from('black-forest-labs/FLUX.1-dev')

    def forward(self, input: str):
        prompt = self.rationale(input)
        image = self.image_gen(prompt)
        return image

strat = MyStrategy()
print(strat)

img = strat("porsche 911")
img.save('porsche_911.png')

strat.push_to_hub('my_username')

Getting Started

To get started with XoT, check out the documentation which provides detailed guides on creating strategies, fine-tuning them and sharing your work with the community.

Core Concepts

Strategy

A Strategy in XoT is the overarching blueprint that defines how an agent thinks and reasons. It encapsulates the following components:

  • Objective / Vision: The high-level goal or purpose of the strategy.
  • Policy / Constitution: The guiding principles or methods used to achieve the objective.

Configuration

Configuration is where the fine-tuning happens. It allows users to customize the behavior of their strategies through:

  • Hyperparameters: Key variables that influence the behavior of the strategy.
  • Distributions: Ranges or specific values that hyperparameters can take, enabling higher diversity trajectories for synthetic data generation.

Step

A Step represents a single unit of reasoning or action within a strategy. Steps are defined by their Signatures—a general template describing what the step should accomplish without being tied to a specific implementation.

Steps can be categorized as:

  • Reasoning:
    • Rationale: Logic or explanation behind decisions.
    • Explainer: Components that provide understandable justifications.
  • Tools:
    • ImageGenerator: Generates images based on input data.
    • Calculator: Performs arithmetic or logical calculations.
    • Terminal: Executes shell commands or scripts.
    • WebSearch: Queries the web for information.
    • FunctionCall: Calls a specific function or API.
  • Modality Adapters:
    • TextToImage: Converts text input to an image format.
    • ImageToText: Converts image input to a text format.
    • ...and more for Audio, Video, Graphs, Time series, etc.
  • Memory Interfaces:
    • ShortTerm: Components managing short-term memory.
    • LongTerm: Components managing long-term memory.
    • Working: Components for active, working memory.
  • Diversifier:
    • Components specialized in generating diverse training data, crucial for robust strategy development.

Metrics

XoT includes built-in Metrics to evaluate the performance of strategies and individual steps. Metrics help in understanding the effectiveness, efficiency, and accuracy of the reasoning process.

Visualizer

The Visualizer provides tools for inspecting and understanding the behavior of strategies and steps. This feature is crucial for debugging, sharing and communicating strategies with others.

Key Features

  • PyTorch-inspired Composability: Design reasoning components using a familiar and flexible modular system akin to PyTorch’s nn.Module, but for thought processes.
  • Modality-Agnostic Design: Supports a wide range of input and output modalities, including text, image, audio, video, graphs, and more.
  • Strategy Sharing and Fine-Tuning: Emphasis on reusing and fine-tuning existing strategies rather than starting from scratch, making it easy to adapt strategies to new tasks.
  • Dataset Generation and Trajectory Evaluation: Built-in support for creating diverse datasets and evaluating the paths taken by reasoning strategies.
  • Flexible Configuration System: Customize your strategies with fine-grained control over prompts, weights, and other hyperparameters.
  • Agent Support: Special subsets of strategies designed for memory-intensive tasks, with support for various types of memory interfaces.

Contributing

Contributions to XoT are very much welcome! If you'd like to contribute, please check out contributing guide.

License

XoT is licensed under the MIT License. See the LICENSE file for more information.

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

xot-0.1.2.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

xot-0.1.2-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file xot-0.1.2.tar.gz.

File metadata

  • Download URL: xot-0.1.2.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for xot-0.1.2.tar.gz
Algorithm Hash digest
SHA256 9e55c51e6c46458bf4bbaeda482a7b6a9c0077fd18951d0a6b94571f13bff5bb
MD5 436909961a1db7f61ddec0115a72a5d2
BLAKE2b-256 378b6c4512e2da55ab7bf28edfcad816ebc6b3dba620ac5eeeacab79e23ea895

See more details on using hashes here.

File details

Details for the file xot-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: xot-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for xot-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1c7c464534d432f3ad1835d134aabc213f556a45c930270bb199c3908cf853c8
MD5 fd6bc7d2c35683cf1292f698242a8e0c
BLAKE2b-256 cfff593402aaf9c32c31e68ed3786a006ed6e547c4c425e44b15e61bd94b5642

See more details on using hashes here.

Supported by

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