RAWENTER/accountzy / scripts /build_business_ai_training_examples.py
RAWENTER's picture
download
raw
7.47 kB
import csv
import json
from pathlib import Path
OUT_DIR = Path("training_examples")
OUT_DIR.mkdir(parents=True, exist_ok=True)
examples = []
def add_example(instruction, input_text, output_text, category, source_file):
examples.append({
"instruction": instruction,
"input": input_text,
"output": output_text,
"category": category,
"source_file": source_file,
"license": "Derived from Realigns Business Open Data Pack for AI training examples"
})
def read_csv(path, limit=50):
p = Path(path)
if not p.exists():
print(f"Missing file, skipped: {path}")
return []
with p.open("r", encoding="utf-8") as f:
return list(csv.DictReader(f))[:limit]
# Accounting examples
for row in read_csv("data/synthetic_accounting/synthetic_general_ledger.csv", 80):
add_example(
"Explain this accounting ledger line in simple business terms.",
json.dumps(row, ensure_ascii=False),
f"This ledger line records {row.get('memo')} for {row.get('entity')}. "
f"The account affected is {row.get('account_name')} ({row.get('account_type')}). "
f"Debit is {row.get('debit')} {row.get('currency')} and credit is {row.get('credit')} {row.get('currency')}.",
"accounting",
"data/synthetic_accounting/synthetic_general_ledger.csv"
)
# Sales CRM examples
for row in read_csv("data/synthetic_sales_crm/synthetic_sales_crm_pipeline.csv", 80):
add_example(
"Analyze this sales opportunity and summarize its pipeline value.",
json.dumps(row, ensure_ascii=False),
f"This opportunity is at the {row.get('stage')} stage with a deal value of "
f"{row.get('deal_value_usd')} USD. Its probability is {row.get('probability')}, "
f"so the weighted pipeline value is {row.get('weighted_pipeline_usd')} USD. "
f"The expected close date is {row.get('expected_close_date')}.",
"sales_crm",
"data/synthetic_sales_crm/synthetic_sales_crm_pipeline.csv"
)
# eCommerce examples
for row in read_csv("data/synthetic_ecommerce/synthetic_ecommerce_orders.csv", 80):
add_example(
"Summarize this eCommerce order and calculate its business meaning.",
json.dumps(row, ensure_ascii=False),
f"This order was placed through {row.get('channel')} for {row.get('quantity')} unit(s) of "
f"{row.get('product_name')} in the {row.get('category')} category. "
f"The total order value is {row.get('order_total_usd')} USD and gross profit is "
f"{row.get('gross_profit_usd')} USD.",
"ecommerce",
"data/synthetic_ecommerce/synthetic_ecommerce_orders.csv"
)
# Marketing examples
for row in read_csv("data/synthetic_marketing/synthetic_marketing_daily_performance.csv", 80):
add_example(
"Analyze this marketing campaign performance row.",
json.dumps(row, ensure_ascii=False),
f"This {row.get('channel')} campaign spent {row.get('spend_usd')} USD and generated "
f"{row.get('clicks')} clicks, {row.get('conversions')} conversions, and "
f"{row.get('revenue_usd')} USD revenue. The ROAS is {row.get('roas')}, "
f"CTR is {row.get('ctr')}, and CPC is {row.get('cpc_usd')} USD.",
"marketing",
"data/synthetic_marketing/synthetic_marketing_daily_performance.csv"
)
# Finance examples
for row in read_csv("data/synthetic_finance/synthetic_cashflow_forecast.csv", 80):
add_example(
"Explain this cash-flow forecast row.",
json.dumps(row, ensure_ascii=False),
f"In the {row.get('scenario')} scenario for month {row.get('month')}, opening cash is "
f"{row.get('opening_cash_usd')} USD, revenue inflow is {row.get('revenue_inflow_usd')} USD, "
f"total outflow is {row.get('total_outflow_usd')} USD, and net cash flow is "
f"{row.get('net_cashflow_usd')} USD. Closing cash is {row.get('closing_cash_usd')} USD.",
"finance",
"data/synthetic_finance/synthetic_cashflow_forecast.csv"
)
# Inventory examples
for row in read_csv("data/synthetic_inventory_supply_chain/synthetic_inventory_items.csv", 80):
add_example(
"Analyze this inventory item and identify whether reorder is needed.",
json.dumps(row, ensure_ascii=False),
f"The item {row.get('sku')} has {row.get('stock_on_hand')} units on hand and a reorder point of "
f"{row.get('reorder_point')}. Reorder needed is {row.get('reorder_needed')}. "
f"The item is stored in warehouse {row.get('warehouse')}.",
"inventory",
"data/synthetic_inventory_supply_chain/synthetic_inventory_items.csv"
)
# HR examples
for row in read_csv("data/synthetic_hr_payroll/synthetic_payroll_records.csv", 80):
add_example(
"Summarize this payroll record.",
json.dumps(row, ensure_ascii=False),
f"This payroll record is for employee {row.get('employee_id')} in {row.get('department')}. "
f"Gross salary is {row.get('gross_salary_usd')} USD, bonus is {row.get('bonus_usd')} USD, "
f"tax withheld is {row.get('tax_withheld_usd')} USD, and net pay is {row.get('net_pay_usd')} USD.",
"hr_payroll",
"data/synthetic_hr_payroll/synthetic_payroll_records.csv"
)
# Support examples
for row in read_csv("data/synthetic_customer_support/synthetic_support_tickets.csv", 80):
add_example(
"Classify and summarize this customer support ticket.",
json.dumps(row, ensure_ascii=False),
f"This is a {row.get('priority')} priority {row.get('category')} ticket for "
f"{row.get('product')}. Status is {row.get('status')}, sentiment is {row.get('sentiment')}, "
f"and SLA breached is {row.get('sla_breached')}.",
"customer_support",
"data/synthetic_customer_support/synthetic_support_tickets.csv"
)
# Procurement examples
for row in read_csv("data/synthetic_procurement_vendor/synthetic_supplier_performance.csv", 80):
add_example(
"Analyze this supplier performance record.",
json.dumps(row, ensure_ascii=False),
f"Vendor {row.get('vendor_name')} has an on-time delivery rate of "
f"{row.get('on_time_delivery_rate')}, quality score {row.get('quality_score')}, "
f"return rate {row.get('return_rate')}, and supplier score {row.get('supplier_score')}. "
f"Risk level is {row.get('risk_level')}.",
"procurement",
"data/synthetic_procurement_vendor/synthetic_supplier_performance.csv"
)
out_file = OUT_DIR / "business_ai_instruction_tuning.jsonl"
with out_file.open("w", encoding="utf-8") as f:
for ex in examples:
f.write(json.dumps(ex, ensure_ascii=False) + "\n")
metadata = {
"dataset": "Business AI Instruction Tuning Examples",
"prepared_by": "Realigns Inc.",
"record_count": len(examples),
"format": "instruction-input-output JSONL",
"intended_use": [
"AI business assistant fine-tuning",
"instruction tuning examples",
"RAG evaluation examples",
"business reasoning demos",
"ERP/CRM/accounting AI prototype testing"
],
"note": "Examples are derived from public and synthetic datasets in this repository. Synthetic examples contain no private business or personal data."
}
(OUT_DIR / "metadata.json").write_text(json.dumps(metadata, indent=2), encoding="utf-8")
print("Done. Training examples created.")
print(json.dumps(metadata, indent=2))

Xet Storage Details

Size:
7.47 kB
·
Xet hash:
dc7bea4f709de58bef974d81ee3534d6fde1511bac7b9be23fa0a95f7e483ee8

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.