TextMachina: A Python Framework for MGT Dataset Generation

This repository profile is provided by osrepos.com, an open source repository discovery platform.

TextMachina: A Python Framework for MGT Dataset Generation

Summary

TextMachina is a modular and extensible Python framework designed for creating high-quality, unbiased datasets for Machine-Generated Text (MGT) tasks. It supports detection, attribution, and boundary detection, offering a user-friendly pipeline with LLM integrations, prompt templating, and bias mitigation. This tool streamlines the process of building robust models for understanding and identifying AI-generated content.

Repository Information

Analyzed by OSRepos on December 21, 2025

Topics

Click on any tag to explore related repositories

Use at your own risk

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of code from these repositories is the user's own responsibility. Always review the repository, source code, dependencies, licenses, and security implications before running or installing anything. OSRepos is not responsible for issues, damages, or losses resulting from third-party repositories.

Introduction

TextMachina is a modular and extensible Python framework, designed to aid in the creation of high-quality, unbiased datasets. These datasets are crucial for building robust models for Machine-Generated Text (MGT)-related tasks such as detection, attribution, boundary detection, and mixcase. The framework provides a unified approach to generate diverse datasets, abstracting away the complexities involved in working with various LLM providers and ensuring data quality.

Installation

You can easily install TextMachina and its dependencies using pip.

To install all dependencies:

pip install text-machina[all]

For specific LLM providers or development dependencies, you can specify them:

pip install text-machina[anthropic,dev]

Alternatively, you can install directly from the source:

pip install .[all]

If you plan to modify the code for custom use cases, install in development mode:

pip install -e .[dev]

Examples

TextMachina offers both a Command Line Interface (CLI) and a programmatic API for generating MGT datasets.

Using the CLI

The CLI provides explore and generate endpoints. The explore endpoint allows you to inspect a small generated dataset interactively and compute metrics. For instance, to check an MGT detection dataset generated using XSum news articles and gpt-3.5-turbo-instruct:

text-machina explore --config-path etc/examples/xsum_gpt-3-5-turbo-instruct_openai.yaml \
--task-type detection \
--metrics-path etc/metrics.yaml \
--max-generations 10

This command will display an interactive interface showing generated and human text for detection, allowing you to verify dataset quality.

Once satisfied, use the generate endpoint to create a full dataset:

text-machina generate --config-path etc/examples/xsum_gpt-3-5-turbo-instruct_openai.yaml \
--task-type detection

TextMachina caches results, allowing you to resume interrupted runs using a --run-name flag.

Programmatically

For more control, you can use TextMachina programmatically. Instantiate a dataset generator with a Config object, which defines input, model, and generation parameters, then call its generate method.

Here's how to replicate the previous example in Python:

from text_machina import get_generator
from text_machina import Config, InputConfig, ModelConfig

input_config = InputConfig(
    domain="news",
    language="en",
    quantity=10,
    random_sample_human=True,
    dataset="xsum",
    dataset_text_column="document",
    dataset_params={"split": "test"},
    template=(
        "Write a news article whose summary is '{summary}'"
        "using the entities: {entities}\n\nArticle:"
    ),
    extractor="combined",
    extractors_list=["auxiliary.Auxiliary", "entity_list.EntityList"],
    max_input_tokens=256,
)

model_config = ModelConfig(
    provider="openai",
    model_name="gpt-3.5-turbo-instruct",
    api_type="COMPLETION",
    threads=8,
    max_retries=5,
    timeout=20,
)

generation_config = {"temperature": 0.7, "presence_penalty": 1.0}

config = Config(
    input=input_config,
    model=model_config,
    generation=generation_config,
    task_type="detection",
)
generator = get_generator(config)
dataset = generator.generate()

Why Use TextMachina

TextMachina stands out as a powerful tool for MGT dataset generation due to several key features:

  • Comprehensive MGT Dataset Generation: It supports a range of MGT tasks, including detection, attribution, boundary detection, and mixcase, providing a versatile solution for various research and application needs.
  • Extensive LLM Integrations: The framework seamlessly integrates with numerous LLM providers, such as Anthropic, Cohere, OpenAI, Google Vertex AI, Amazon Bedrock, AI21, Azure OpenAI, VLLM, TRT inference servers, and HuggingFace models, offering flexibility in model choice.
  • Advanced Dataset Quality Features: TextMachina incorporates prompt templating, constrained decoding to infer LLM hyperparameters, and post-processing functions to enhance dataset quality and prevent common biases.
  • Bias Mitigation: Built with bias prevention in mind, it helps users avoid introducing spurious correlations in their datasets throughout the entire pipeline.
  • User-Friendly Workflow: With both a robust CLI and a programmatic API, TextMachina caters to different user preferences, making dataset generation accessible and efficient.
  • Dataset Exploration: It provides tools to explore generated datasets and quantify their quality with a set of metrics, ensuring transparency and reliability.

Links

Related repositories

Similar repositories that may be relevant next.

RL4LMs: A Modular RL Library for Fine-tuning Language Models

RL4LMs: A Modular RL Library for Fine-tuning Language Models

July 6, 2026

RL4LMs is a powerful and modular reinforcement learning library designed to fine-tune language models to human preferences. It offers easily customizable building blocks for training, including on-policy algorithms, reward functions, and metrics. Thoroughly tested and benchmarked, RL4LMs supports a wide range of NLP tasks and models.

reinforcement-learningnatural-language-processinglanguage-modeling
torchtune: PyTorch Native Library for LLM Post-Training and Experimentation

torchtune: PyTorch Native Library for LLM Post-Training and Experimentation

July 5, 2026

torchtune is a PyTorch native library designed for authoring, post-training, and experimenting with Large Language Models (LLMs). It offers hackable training recipes, simple PyTorch implementations of popular LLMs, and best-in-class memory efficiency. Please note: torchtune is no longer actively maintained as of 2025.

PythonPyTorchLLM
RouteLLM: Optimize LLM Costs and Maintain Quality with Intelligent Routing

RouteLLM: Optimize LLM Costs and Maintain Quality with Intelligent Routing

July 5, 2026

RouteLLM is a powerful framework designed to serve and evaluate LLM routers, enabling significant cost savings without compromising response quality. It intelligently routes simpler queries to cheaper models while maintaining high performance, offering a drop-in replacement for existing OpenAI clients or a compatible server. This solution helps balance the dilemma of LLM deployment costs versus model capabilities.

PythonLLM RoutingAI
Memoripy: An AI Memory Layer for Context-Aware Applications

Memoripy: An AI Memory Layer for Context-Aware Applications

July 5, 2026

Memoripy is a Python library designed to provide an AI memory layer for context-aware applications. It offers both short-term and long-term storage, semantic clustering, and optional memory decay. This robust tool helps AI systems manage and retrieve relevant information efficiently, supporting various LLM APIs like OpenAI and Ollama.

aillmmemory

Source repository

Open the original repository on GitHub.

6 counted GitHub visits

View on GitHub
OS
OSRepos

Analysis and discovery of open source repositories. Find interesting projects and follow their updates.

Monitor your website with YourWebsiteScore

OSRepos shares public repositories for knowledge and discovery only. Any installation, execution, configuration, or use of third-party repository code is at your own risk. Always review source code, dependencies, licenses, and security implications before running anything.

© 2025 OSRepos. Built with Nuxt 3 and lots of ❤️