SysGen
SysGen is a powerful CLI tool that creates high-quality synthetic datasets from documents using the Gemini API. It intelligently chunks documents, generates comprehensive questions, and produces detailed answers for machine learning training datasets.
Features
- Smart Document Chunking: Automatically splits large documents into manageable chunks with overlap
- Comprehensive Question Generation: Extracts ALL possible questions from content using advanced AI prompting
- High-Quality Answer Generation: Creates detailed 4-5 sentence answers with supporting evidence
- Multiple Output Formats: Supports Alpaca, ChatML, and Conversation formats
- Semantic Duplicate Detection: Automatically removes duplicate questions using sentence embeddings
- Token-Aware Processing: Uses tiktoken for accurate token counting and chunking
- Batch Processing: Process multiple markdown/text files in a single run
- Quality Validation: Ensures answer length and content quality standards
Installation
Install from pip
pip install sysgen
Set Up Environment Variables
Before running sysgen, set the API key in your terminal:
# Windows
set GEMINI_API_KEY=your_gemini_api_key_here
# Linux/Mac
export GEMINI_API_KEY=your_gemini_api_key_here
Usage
Basic Usage
sysgen --input-folder md --output dataset.json --format alpaca
Advanced Usage
sysgen --input-folder documents --output training_data.json --format chatml --similarity-threshold 0.85
Arguments
--input-folder: Folder containing markdown/text files (default:md)--output: Output JSON file (default:output.json)--format: Output format -alpaca,chatml, orconversation(default:alpaca)--similarity-threshold: Similarity threshold for duplicate detection, 0.0-1.0 (default:0.85)
Output Formats
Alpaca Format
{
"instruction": "What is the main concept discussed in this section?",
"input": "",
"output": "The main concept discussed is the implementation of neural networks...",
"source_document": "document.md"
}
ChatML Format
{
"messages": [
{"role": "user", "content": "What is the main concept discussed in this section?"},
{"role": "assistant", "content": "The main concept discussed is the implementation of neural networks..."}
],
"source_document": "document.md"
}
Conversation Format
{
"conversations": [
{"from": "human", "value": "What is the main concept discussed in this section?"},
{"from": "gpt", "value": "The main concept discussed is the implementation of neural networks..."}
],
"source_document": "document.md"
}
How It Works
- Document Chunking: Splits documents into 3000-token chunks with 200-token overlap
- Question Extraction: Uses advanced AI prompting to extract ALL possible questions from each chunk
- Answer Generation: Creates comprehensive 4-5 sentence answers with supporting evidence
- Quality Filtering: Validates answer length (3-6 sentences) and content quality
- Duplicate Detection: Uses sentence embeddings to identify semantically similar questions
- Format Conversion: Converts to specified output format (Alpaca/ChatML/Conversation)
- Batch Processing: Processes multiple files and combines results
Advanced Features
Smart Chunking
- Token-Aware: Uses tiktoken for accurate token counting
- Sentence Preservation: Keeps sentences intact during chunking
- Overlap Management: Maintains context between chunks with configurable overlap
Comprehensive Question Generation
- Multi-Level Questions: Generates factual, conceptual, analytical, and application questions
- Exhaustive Extraction: Extracts ALL possible questions from content
- Quality Standards: Ensures questions are clear, specific, and answerable
Semantic Duplicate Detection
- Embedding-Based: Uses sentence-transformers for semantic similarity
- Configurable Threshold: Adjust sensitivity with similarity_threshold parameter
- Quality Preservation: Keeps highest quality version from duplicate groups
Dependencies
google-genai: Gemini API client for question and answer generationsentence-transformers: Semantic similarity detection for duplicate removalscikit-learn: Cosine similarity calculationstiktoken: Token counting for document chunkingtorch: PyTorch backend for sentence transformerstransformers: Hugging Face transformers librarynumpy: Numerical operationsscipy: Scientific computing utilities
Contributing
We welcome contributions! Please feel free to submit issues, feature requests, or pull requests.
How to Contribute
- Fork the Repository: Start by forking the project on GitHub
- Clone the Repository: Clone it to your local machine
- Create a Branch: Create a new branch for your changes
- Make Changes: Implement your improvements or bug fixes
- Test Your Changes: Ensure the tool works correctly with your modifications
- Submit a Pull Request: Open a PR describing your changes
License
This project is licensed under the MIT License. See LICENSE for details.
Contact
- Author: Adhishtanaka
- Email: kulasoooriyaa@gmail.com
Metadata
Release files for sysgen 0.2.2
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 |
|---|---|---|---|---|
| sysgen-0.2.2.tar.gz | 11.3 kB | Without provenance | Details for sysgen-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sysgen-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for sysgen-0.2.2-py3-none-any.whl |
Total release size: 20.9 kB
Release files / sysgen-0.2.2.tar.gz
| Download URL | sysgen-0.2.2.tar.gz |
|---|---|
| Size | 11.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
be67e5ad6292084afbe9c0331608559c55613a980e94dedf577418b972169f4c
|
|
BLAKE2b-256 checksum How to use checksums |
196b01bfbf12d875cab27f5ccb2027a9debf7f2f2f595f776c5026aac8943617
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.4
|
Release files / sysgen-0.2.2-py3-none-any.whl
| Download URL | sysgen-0.2.2-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
317a8d92eef218af56c73fbee2163655042ad69331d8cb369424ec1471de86f2
|
|
BLAKE2b-256 checksum How to use checksums |
7fcc85e59c2d5d4e39ca7258c5b85cbd4f7e927a006b2e6b8195d3d35d202a01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.4
|
Security for sysgen 0.2.2
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.