{"name":"TextMachina: A Python Framework for MGT Dataset Generation","description":"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.","github":"https://github.com/Genaios/TextMachina","url":"https://osrepos.com/repo/genaios-textmachina","source":"osrepos.com","sourceDescription":"This repository profile is provided by osrepos.com, an open source repository discovery platform.","repositoryProfile":"https://osrepos.com/repo/genaios-textmachina","generatedFor":"open source discovery and AI-assisted research","markdown":"https://osrepos.com/repo/genaios-textmachina.md","json":"https://osrepos.com/repo/genaios-textmachina.json","topics":["Python","MGT","LLM","AI","NLP","Dataset Generation","Machine Learning","Text Generation"],"keywords":["Python","MGT","LLM","AI","NLP","Dataset Generation","Machine Learning","Text Generation"],"stars":null,"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.","content":"## Introduction\nTextMachina 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.\n\n## Installation\nYou can easily install TextMachina and its dependencies using pip.\n\nTo install all dependencies:\nbash\npip install text-machina[all]\n\n\nFor specific LLM providers or development dependencies, you can specify them:\nbash\npip install text-machina[anthropic,dev]\n\n\nAlternatively, you can install directly from the source:\nbash\npip install .[all]\n\n\nIf you plan to modify the code for custom use cases, install in development mode:\nbash\npip install -e .[dev]\n\n\n## Examples\nTextMachina offers both a Command Line Interface (CLI) and a programmatic API for generating MGT datasets.\n\n## Using the CLI\nThe 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`:\n\nbash\ntext-machina explore --config-path etc/examples/xsum_gpt-3-5-turbo-instruct_openai.yaml \\\n--task-type detection \\\n--metrics-path etc/metrics.yaml \\\n--max-generations 10\n\nThis command will display an interactive interface showing generated and human text for detection, allowing you to verify dataset quality.\n\nOnce satisfied, use the `generate` endpoint to create a full dataset:\nbash\ntext-machina generate --config-path etc/examples/xsum_gpt-3-5-turbo-instruct_openai.yaml \\\n--task-type detection\n\nTextMachina caches results, allowing you to resume interrupted runs using a `--run-name` flag.\n\n## Programmatically\nFor 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.\n\nHere's how to replicate the previous example in Python:\npython\nfrom text_machina import get_generator\nfrom text_machina import Config, InputConfig, ModelConfig\n\ninput_config = InputConfig(\n    domain=\"news\",\n    language=\"en\",\n    quantity=10,\n    random_sample_human=True,\n    dataset=\"xsum\",\n    dataset_text_column=\"document\",\n    dataset_params={\"split\": \"test\"},\n    template=(\n        \"Write a news article whose summary is '{summary}'\"\n        \"using the entities: {entities}\\n\\nArticle:\"\n    ),\n    extractor=\"combined\",\n    extractors_list=[\"auxiliary.Auxiliary\", \"entity_list.EntityList\"],\n    max_input_tokens=256,\n)\n\nmodel_config = ModelConfig(\n    provider=\"openai\",\n    model_name=\"gpt-3.5-turbo-instruct\",\n    api_type=\"COMPLETION\",\n    threads=8,\n    max_retries=5,\n    timeout=20,\n)\n\ngeneration_config = {\"temperature\": 0.7, \"presence_penalty\": 1.0}\n\nconfig = Config(\n    input=input_config,\n    model=model_config,\n    generation=generation_config,\n    task_type=\"detection\",\n)\ngenerator = get_generator(config)\ndataset = generator.generate()\n\n\n## Why Use TextMachina\nTextMachina stands out as a powerful tool for MGT dataset generation due to several key features:\n*   **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.\n*   **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.\n*   **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.\n*   **Bias Mitigation:** Built with bias prevention in mind, it helps users avoid introducing spurious correlations in their datasets throughout the entire pipeline.\n*   **User-Friendly Workflow:** With both a robust CLI and a programmatic API, TextMachina caters to different user preferences, making dataset generation accessible and efficient.\n*   **Dataset Exploration:** It provides tools to explore generated datasets and quantify their quality with a set of metrics, ensuring transparency and reliability.\n\n## Links\n*   **GitHub Repository:** [Genaios/TextMachina](https://github.com/Genaios/TextMachina){:target=\"_blank\"}\n*   **Official Documentation:** [TextMachina Readthedocs](https://textmachina.readthedocs.io/en/latest/){:target=\"_blank\"}\n*   **PyPI Package:** [text-machina on PyPI](https://pypi.org/project/text-machina/){:target=\"_blank\"}","metrics":{"detailViews":1,"githubClicks":6},"dates":{"published":null,"modified":"2025-12-21T20:01:05.000Z"}}