Skip to main content

Steerable data generation system for LLM fine-tuning

Project description

⬜️ Open Datagen ⬜️

Open Datagen, a steerable data generation system for ML models training.

Features

  • Generate high-quality synthetic datasets using simple templates

  • Quality enhancement with RAG from Internet and local files

  • Data anonymization

  • Data evaluation & cleaning agent

  • Open-source model support (HuggingFace Inference API)

  • (SOON) Data decontamination

  • (SOON) Multimodality

Installation

pip install --upgrade opendatagen

Setting up your API keys

export OPENAI_API_KEY='your_openai_api_key' #(using openai>=1.2)
export HUGGINGFACE_API_KEY='your_huggingface_api_key'
export MISTRAL_API_KEY='your_mistral_api_key'
export SERPLY_API_KEY='your_serply_api_key' #Google Search API 

Usage

Example: Generate a low-biased dataset to improve factuality of an LLM.

template.json:

{
    "factuality": {
        "description": "Factuality",
        "prompt": "Given the following text:\n\n'''{wikipedia_content}'''\n\nAnswer to this factually checkable question:\n'''{question}'''.",
        "completion": "Answer: '''{answer}'''. Rate the answer out of 10: {score}",
        "prompt_variation_number": 0,
        "variables": {
            "wikipedia_content": {
                "name": "Wikipedia content",
                "generation_number": 1,
                "get_value_from_huggingface": {
                    "dataset_name": "20220301.en",
                    "dataset_path": "wikipedia",
                    "column_name": "text",
                    "max_tokens": 512
                }
            },
            "question": {
                "name": "Factually checkable question",
                "generation_number": 3,
                "models": [
                    {
                        "openai_chat_model": {
                            "name": "gpt-3.5-turbo-1106",
                            "temperature": 0,
                            "max_tokens": 128
                        }
                    }
                ]
            }, 
            "answer": {
                "name": "Short answer to the question",
                "generation_number": 1,
                "models": [
                    {
                        "openai_instruct_model": {
                            "name": "gpt-3.5-turbo-instruct",
                            "temperature": 0,
                            "max_tokens": 128,
                            "start_with": ["Answer:"]
                        }
                    }
                ]
            
            },
            "score": {
                "name": "Score",
                "generation_number": 1,
                "note": ["You must answer with an integer."],
                "models": [
                    {
                        "openai_chat_model": {
                            "name": "gpt-3.5-turbo-1106",
                            "temperature": 0,
                            "max_tokens": 5
                        }
                    }
                ]
            }
            
        }
    }
}

Python code to generate the dataset:

from opendatagen.template import TemplateManager
from opendatagen.data_generator import DataGenerator

output_path = "factuality.csv"
template_name = "factuality"
manager = TemplateManager(template_file_path="template.json")
template = manager.get_template(template_name=template_name)

if template:
    
    generator = DataGenerator(template=template)
    
    data = generator.generate_data(output_path=output_path)
    
    print(data)

Using this template you will:

  1. Get text content from the Wikipedia dataset hosted on HuggingFace
  2. Generate 3 questions about this content
  3. Generate an short answer
  4. Rate the answer

Once the CSV created, you can ask an AI Agent to evaluate and correct your dataset

from opendatagen.agent import DataAgent

agent = DataAgent()

agent.run()

Contribution

We welcome contributions to Open Datagen! Whether you're looking to fix bugs, add templates, new features, or improve documentation, your help is greatly appreciated.

Note

Please note that opendatagen is initially powered by OpenAI's models. Be aware of potential biases and use the note field to guide outputs.

Acknowledgements

We would like to express our gratitude to the following open source projects and individuals that have inspired and helped us:

Connect

Reach us on Twitter: @thoddnn.

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

opendatagen-0.0.18.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

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

opendatagen-0.0.18-py3-none-any.whl (37.8 kB view details)

Uploaded Python 3

File details

Details for the file opendatagen-0.0.18.tar.gz.

File metadata

  • Download URL: opendatagen-0.0.18.tar.gz
  • Upload date:
  • Size: 23.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for opendatagen-0.0.18.tar.gz
Algorithm Hash digest
SHA256 f3cead5ab044b211a728e7463264aeae1c590bf4adda0d6ee9cd7171648a5887
MD5 3c9e757c4ec4e01b173dce2afd257c2c
BLAKE2b-256 8d9812843db84d8f37de821a0ec8a053824be1031f775c26bbb77eea2a50eb1e

See more details on using hashes here.

File details

Details for the file opendatagen-0.0.18-py3-none-any.whl.

File metadata

  • Download URL: opendatagen-0.0.18-py3-none-any.whl
  • Upload date:
  • Size: 37.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.6

File hashes

Hashes for opendatagen-0.0.18-py3-none-any.whl
Algorithm Hash digest
SHA256 1bfe0aac00186b32ca23aa8b9321cc549a51dde8b07b2edcd8b0cd9ac3c63a3d
MD5 7a2f42b75c49187b725a0aadc189892f
BLAKE2b-256 997bf37e51efe54b675c404143c2bbe3949563fcbb9b7ad9b355eb29069e2b76

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