TextMachina: A Python Framework for MGT Dataset Generation
This repository profile is provided by osrepos.com, an open source repository discovery platform.
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
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
- GitHub Repository: Genaios/TextMachina
- Official Documentation: TextMachina Readthedocs
- PyPI Package: text-machina on PyPI
Related repositories
Similar repositories that may be relevant next.

dify-official-plugins: Extending Dify with AI Models, Tools, and Agent Strategies
August 18, 2026
The `dify-official-plugins` repository hosts a collection of official plugins for Dify, an open-source platform for developing LLM-powered AI applications. These plugins, including models, tools, agent strategies, and extensions, enhance Dify's capabilities and are maintained by the official Dify team. They are designed to help developers efficiently build, deploy, and manage AI-driven solutions.

Agent Skills: A Standardized Way to Give AI Agents New Capabilities
August 18, 2026
Agent Skills provides a lightweight, open format for extending AI agent capabilities with specialized knowledge and workflows. It allows packaging procedural knowledge and context into portable, version-controlled folders that agents load on demand. This enables agents to gain domain expertise, follow repeatable workflows, and reuse skills across various compatible AI tools.

A-MEM: Self-Evolving Memory for Coding Agents
August 17, 2026
A-MEM is an innovative self-evolving memory system designed for coding agents, organizing knowledge into a dynamic Zettelkasten-style graph. It allows memories to evolve and connect over time, enhancing an agent's ability to recall and utilize information effectively. This system offers both semantic and structural search capabilities for a richer knowledge base.

Agent Sandbox: Secure Local Development for AI Coding Agents
August 17, 2026
Agent Sandbox provides a robust and secure local development environment specifically designed for collaborating with AI coding agents. It ensures minimal filesystem access, configurable network egress policies, and secure secret injection, protecting your local machine from potentially risky agent operations. This project supports various AI agents and integrates seamlessly with both CLI and popular IDE devcontainer setups.
Source repository
Open the original repository on GitHub.
10 counted GitHub visits