SFT Data Generator
This is a tool for generating data for Supervised Fine-Tuning (SFT) using large language models like GPT-3.5. It can read data from CSV or Excel files and generate corresponding output data using OpenAI's API based on a given prompt.
Features
- Supports reading CSV and Excel files
- Uses OpenAI's Chat Completion API to generate data
- Supports customizable prompts and models
- Supports batch generation with customizable batch size
- Supports setting the number of generation epochs, i.e., generating multiple rounds for the entire dataset
- Supports JSON format output
- Can set OpenAI API URL and key via command line arguments or environment variables
Usage
-
Install dependencies:
pip install -r requirements.txt -
Prepare the input data file (CSV or Excel) and prompt template.
-
Run the command:
sft-data-generator --file_path <input_file_path> --prompt <prompt_template> --model <model_name> [other optional arguments]
or
python data_generator.py --file_path <input_file_path> --prompt <prompt_template> --model <model_name> [other optional arguments]
Required arguments:
--file_path: Path to the input data file, must be a CSV or Excel file.--prompt: Prompt template used for generating data.--model: Name of the OpenAI model used for generating data, e.g.,gpt-3.5-turbo.
Optional arguments:
--output_file: Output file path, defaults to input file path +.output.jsonl.--batch_size: Batch size, i.e., the number of samples per concurrent request, defaults to 1.--generate_epoch: Number of generation epochs, i.e., the number of rounds to generate for the entire dataset, defaults to 1.--openai_base_url: Base URL for the OpenAI API, if not given, will use the environment variableOPENAI_API_BASE.--openai_api_key: OpenAI API key, if not given, will use the environment variableOPENAI_API_KEY.--json_output: Whether to use JSON format output, defaults to False.
-
The generated data will be saved in the specified output file, with each line being a JSON object.
Example
sft-data-generator --file_path data.csv --prompt "Please generate a question-answer pair based on the given data:" --model gpt-3.5-turbo --batch_size 10 --generate_epoch 3
or
python data_generator.py --file_path data.csv --prompt "Please generate a question-answer pair based on the given data:" --model gpt-3.5-turbo --batch_size 10 --generate_epoch 3
This will read the data.csv file, use the prompt "Please generate a question-answer pair based on the given data:", call the gpt-3.5-turbo model with a batch size of 10, and generate 3 epochs of data. The output will be saved in the data.csv.output.jsonl file.
Metadata
Release files for sft-data-generator 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sft-data-generator-0.0.3.tar.gz | 6.2 kB | Without provenance | Details for sft-data-generator-0.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sft_data_generator-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for sft_data_generator-0.0.3-py3-none-any.whl |
Total release size: 12.9 kB
Release files / sft-data-generator-0.0.3.tar.gz
| Download URL | sft-data-generator-0.0.3.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0067840f1f69b02d616146216c32fe807aa797b3828d44d9c01dc0ca9979bde9
|
|
BLAKE2b-256 checksum How to use checksums |
e133253dda90dae6d2867392b26857129a610260e1a134d82fe43635d9240599
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.13
|
Release files / sft_data_generator-0.0.3-py3-none-any.whl
| Download URL | sft_data_generator-0.0.3-py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b9c961ed392a199e7c15ca8ee67c062a218e724934117f70f2028ef6c06cd7f6
|
|
BLAKE2b-256 checksum How to use checksums |
4fcadc182544055f0110bb628e26280143e2c2069bc3f341dca18ee94c1410a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.13
|
Security for sft-data-generator 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.