Skip to main content

A compact, human-writable format for storing content paired with feedback/labels

Project description

MarkBack

A compact, human-writable format for storing content paired with feedback/labels.

Installation

pip install -e .

Quick Start

Parse a MarkBack file

from markback import parse_file, parse_string

# Parse a file
result = parse_file("labels.mb")
for record in result.records:
    print(f"{record.uri}: {record.feedback}")

# Parse a string
text = """
@uri local:example

Some content here.
<<< positive; good quality
"""
result = parse_string(text)

Write MarkBack files

from markback import Record, SourceRef, write_file, OutputMode

records = [
    Record(feedback="good", uri="local:1", content="First item"),
    Record(feedback="bad", uri="local:2", content="Second item"),
]

# Write multi-record file
write_file("output.mb", records, mode=OutputMode.MULTI)

# Write compact label list
write_file("labels.mb", records, mode=OutputMode.COMPACT)

Lint files

from markback import lint_file

result = lint_file("myfile.mb")
if result.has_errors:
    for d in result.diagnostics:
        print(d)

CLI Usage

Initialize configuration

markback init

Creates a .env file with all configuration options.

Lint files

# Lint a single file
markback lint myfile.mb

# Lint a directory
markback lint ./data/

# JSON output
markback lint myfile.mb --json

Normalize to canonical format

# Output to stdout
markback normalize input.mb

# Output to file
markback normalize input.mb output.mb

# In-place normalization
markback normalize input.mb --in-place

List records

markback list myfile.mb
markback list ./data/ --json

Convert between formats

# Convert to multi-record format
markback convert input.mb output.mb --to multi

# Convert to compact label list
markback convert input.mb output.mb --to compact

# Convert to paired files
markback convert input.mb ./output_dir/ --to paired

Run LLM workflow

# Run editor/operator workflow
markback workflow run dataset.mb --prompt "Initial prompt" --output results.json

# View evaluation results
markback workflow evaluate results.json

# Extract refined prompt
markback workflow prompt results.json --output refined_prompt.txt

File Formats

Single Record

@uri local:example

Content goes here.
<<< positive; quality=high

Multi-Record

@uri local:item-1

First content.
<<< good

---
@uri local:item-2

Second content.
<<< bad; needs improvement

Compact Label List

@source ./images/001.jpg <<< approved; scene=beach
@source ./images/002.jpg <<< rejected; too dark
@source ./images/003.jpg <<< approved; scene=mountain

Paired Files

content.txt:

The actual content goes here.

content.label.txt:

@uri local:content-id
<<< approved; reviewer=alice

Configuration

Configuration is loaded from .env:

# File handling mode
FILE_MODE=git  # or "versioned"

# Label file discovery
LABEL_SUFFIXES=.label.txt,.feedback.txt,.mb

# Editor LLM
EDITOR_API_BASE=https://api.openai.com/v1
EDITOR_API_KEY=your-key
EDITOR_MODEL=gpt-4

# Operator LLM
OPERATOR_API_BASE=https://api.openai.com/v1
OPERATOR_API_KEY=your-key
OPERATOR_MODEL=gpt-4

Development

Run tests

pip install -e ".[dev]"
pytest

Run with coverage

pytest --cov=markback

License

MIT

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

markback-0.1.0.tar.gz (44.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

markback-0.1.0-py3-none-any.whl (26.3 kB view details)

Uploaded Python 3

File details

Details for the file markback-0.1.0.tar.gz.

File metadata

  • Download URL: markback-0.1.0.tar.gz
  • Upload date:
  • Size: 44.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for markback-0.1.0.tar.gz
Algorithm Hash digest
SHA256 922cec8dc3132d524d5d5c671e3655d4f90e1370e64629bab6e236688f9149db
MD5 53bde83e93008b31230ab7f670224d77
BLAKE2b-256 eeffbefc24e65f9d2197eb05d29ac0e09a343c00807515504a42ef0227c16697

See more details on using hashes here.

File details

Details for the file markback-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: markback-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 26.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for markback-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 28abba87efb570088242538c6ba13cd0ba46d177b90f3d81ba054659e578b166
MD5 e0e3321c23fd9bb3ca8c518ed444d2b5
BLAKE2b-256 9b936230ec01046812b2d3dc6438ac7455032471fcd7e6437a7b60da078e298c

See more details on using hashes here.

Supported by

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