#expansion #token #axis

batch-mode-token-expansion-traits

Traits for describing distinct token expansion axes, used for instructing expansions in an LLM context

2 releases

Uses new Rust 2024

0.1.2 Jul 13, 2025
0.1.1 Mar 31, 2025

#27 in #expansion

Download history 216/week @ 2025-10-27 269/week @ 2025-11-03 244/week @ 2025-11-10 278/week @ 2025-11-17 219/week @ 2025-11-24 342/week @ 2025-12-01 169/week @ 2025-12-08 241/week @ 2025-12-15 282/week @ 2025-12-22 208/week @ 2025-12-29 185/week @ 2026-01-05 105/week @ 2026-01-12 317/week @ 2026-01-19 300/week @ 2026-01-26 293/week @ 2026-02-02 185/week @ 2026-02-09

1,117 downloads per month
Used in 110 crates (5 directly)

Custom license

160KB
1.5K SLoC

batch-mode-token-expansion-traits

This crate provides trait definitions for describing and implementing token expansion axes. It is particularly useful when orchestrating batch-based expansions for language models or similar systems. By defining an axis, you specify a distinct dimension or perspective along which a token can be expanded.

Features

  • AxisName: Associates each axis variant with a concise, programmatic name string.
  • AxisDescription: Provides a descriptive prompt or explanation, typically used to guide language model expansions.
  • TokenExpansionAxis: Combines both naming and descriptive functionality, establishing a standard interface for axis-related traits.

Example Usage

Implement these traits on an enum or struct to define multiple axes for token expansion:

use std::borrow::Cow;
use std::fmt::Debug;

#[derive(Debug)]
enum MyAxis {
    VariantOne,
    VariantTwo,
}

impl crate::AxisName for MyAxis {
    fn axis_name(&self) -> Cow<'_, str> {
        match self {
            MyAxis::VariantOne => "variant_one".into(),
            MyAxis::VariantTwo => "variant_two".into(),
        }
    }
}

impl crate::AxisDescription for MyAxis {
    fn axis_description(&self) -> Cow<'_, str> {
        match self {
            MyAxis::VariantOne => "Instructions or description for VariantOne".into(),
            MyAxis::VariantTwo => "Instructions or description for VariantTwo".into(),
        }
    }
}

impl crate::TokenExpansionAxis for MyAxis {}

You can now treat MyAxis as a token expansion axis, iterating over each variant to build prompts or instructions for your batch-based expansions.

Getting Started

  1. Add this crate to your Cargo.toml.
  2. Use the provided traits to define your own axes.
  3. Integrate them into your batch expansion flow.

Dependencies

~29–51MB
~707K SLoC