BatchIR is a standardized batch encoding for training and inference interchange across backends. It provides typed batch structs, explicit schema tags, JSON/Msgpack serialization, and validation helpers for safe data transport and storage.
- Typed batch structs for text, tokens, labels, chat, and instructions
- Explicit schema tags embedded in every encoded payload
- JSON + Msgpack encoding/decoding helpers
- Validation for batch shapes, lengths, and required fields
- Compatibility helpers for Kitchen and TrainingIR payloads
Add to your mix.exs:
def deps do
[
{:batch_ir, "~> 0.1.0"}
]
endOr from GitHub:
def deps do
[
{:batch_ir, git: "https://github.com/North-Shore-AI/batch_ir.git"}
]
end| Struct | Purpose |
|---|---|
BatchIR.TextBatch |
Raw text samples |
BatchIR.TokenBatch |
Tokenized sequences |
BatchIR.LabeledBatch |
Labeled inputs for supervision |
BatchIR.ChatBatch |
Conversation-style batches |
BatchIR.InstructBatch |
Instruction-following samples |
alias BatchIR.TextBatch
batch = TextBatch.from_strings(["hello", "world"])
{:ok, json} = TextBatch.encode(batch, :json)
{:ok, decoded} = TextBatch.decode(json, :json)alias BatchIR.Schema
Schema.tag(:text)
# => "batch_ir/text@1"alias BatchIR.Validation
Validation.valid?(batch)
Validation.errors(batch)alias BatchIR.Compat
{:ok, batch} = Compat.from_kitchen_batch(["hello", "world"])
training_payload = Compat.to_training_payload(batch)mix deps.get
mix format
mix test
mix credo --strict
mix dialyzerMIT License - Copyright (c) 2026 North-Shore-AI