Skip to main content

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.

Metadata

Release files for xot 0.1.2

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

Source distribution (sdist)

Source distribution for xot 0.1.2
File Size Uploaded
xot-0.1.2.tar.gz 8.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xot 0.1.2
File Interpreter ABI Platform
xot-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 18.4 kB

Release files / xot-0.1.2.tar.gz

Download URL xot-0.1.2.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9e55c51e6c46458bf4bbaeda482a7b6a9c0077fd18951d0a6b94571f13bff5bb
BLAKE2b-256 checksum
How to use checksums
378b6c4512e2da55ab7bf28edfcad816ebc6b3dba620ac5eeeacab79e23ea895
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.5

Release files / xot-0.1.2-py3-none-any.whl

Download URL xot-0.1.2-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c7c464534d432f3ad1835d134aabc213f556a45c930270bb199c3908cf853c8
BLAKE2b-256 checksum
How to use checksums
cfff593402aaf9c32c31e68ed3786a006ed6e547c4c425e44b15e61bd94b5642
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.5

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

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