Skip to content

Long form LLM document creation using hierachical expansion. Focused on creating artificial procurement examples.

License

Notifications You must be signed in to change notification settings

makefinks/synthetic-docs

Repository files navigation

Synthetic Document Generator

A tool that automatically generates synthetic technical documents, such as tenders (requests for proposals) or offers (responses to tenders), using LLMs.

Overview

  1. Generate Structure: Based on your input (title, description, document type), the LLMs propose a logical structure for the document, including chapters and sections, along with brief summaries. For 'tender' documents, it can optionally use a guidance text for structure ideas. For 'offer' documents, it uses the structure of a previously generated 'tender' JSON file.
  2. Expand Summaries: The LLMs take the brief summaries from the structure step and expand them into more detailed summaries for each chapter.
  3. Generate Content: Using the detailed summaries and considering previous chapters for context, the LLMs write the full content for each section. For 'offer' documents, it can refer to specific content from the original tender document.
  4. Produce Output: The tool assembles the generated content into a final Markdown or LateX document.

Details

  • Generates two types of documents: tender (like a requirements specification) and offer (a response to a tender).
  • Creates document structure, summaries, and full content automatically.
  • Supports generation in German (de) and English (en).
  • Controls the level of detail (low, medium, high), influencing 'offer' generation.
  • Outputs documents in LaTeX (compiles to PDF if LaTeX is installed) or Markdown format.
  • Tracks LLM token usage and estimated costs.
  • Configurable context window (--content-context-window) to control how many previous chapters' content is considered when generating the next section.

Getting Started

Prerequisites

  • Python 3.10 or higher
  • uv (for installing dependencies)
  • A LaTeX distribution (like TeX Live, MiKTeX, or MacTeX) installed only if you need PDF output.

Installation

  1. Clone the repository:
    git clone <repository-url>
    cd <repository-directory>
  2. Install dependencies using uv:
    uv sync
    This command creates a virtual environment (if one doesn't exist) and installs all required packages listed in pyproject.toml.

Installing LaTeX (Optional, for PDF Output)

If you want to generate PDF files, you need a working LaTeX installation.

  • Ubuntu/Debian:
    sudo apt-get update && sudo apt-get install texlive-full
  • macOS (using Homebrew):
    brew install --cask mactex
  • Windows: Download and install MiKTeX from miktex.org.

Usage

Run the main script synth.py with the required arguments.

Basic Command Structure:

python synth.py <document_type> "<Document Title>" "<Document Description/Info>" [options]

cli args

Argument Description
{tender,offer} Type of document to create (required)
document_title Title of the document (required)
document_info Document information/guidance (required)
--guidance-doc Path to guidance document. For tender documents, this is a description of the document structure. For offer documents, it needs to be the final tender output JSON.
--output-dir Directory to store output files (default: output)
--model LLM to use for content generation
--structure-model LLM to use for structure generation
--temperature Temperature for LLM generation (default: 0.7)
--output-format Output format: markdown or latex (default: markdown)
--no-track-costs Disable token usage and cost tracking
--num-chapters Number of chapters to generate (optional, mainly for tender)
--language Language to use: de (German) or en (English) (default: de)
--detail-level Detail level for offer documents: low, medium, or high (default: medium)
--content-context-window Number of previous full chapter contents to consider for next section generation (default: 10)

Examples:

python synth.py tender "Lastenheft TeboTec Antriebssystem" " Das Dokument soll die Produktionslinie für das TeboTec Antriebssystem beschreiben. Es geht dabei um ein elektrisches Antriebssystem, das in einer industriellen Fertigungslinie produziert wird. Der Inhalt umfasst die Beschreibung der beteiligten Produktionsprozesse, der eingesetzten Anlagen und der allgemeinen Abläufe innerhalb der Linie. Ziel ist es, ein gemeinsames Verständnis für die Auslegung, Struktur und Funktion der gesamten Produktionslinie zu schaffen."
python synth.py tender "OptiLine Softwareentwicklung" " DDas Dokument soll die Softwareentwicklung für ein System zur Linienüberwachung beschreiben. Die Software „OptiLine“ dient der Beobachtung und Analyse von Fertigungsabläufen. Der Fokus liegt auf der Beschreibung der Softwarefunktionen, der allgemeinen Systemstruktur sowie der Interaktion mit anderen Systemen in der Produktionsumgebung. Es geht darum, den geplanten Funktionsumfang, den Zweck der Software und das Einsatzumfeld nachvollziehbar darzustellen."
python synth.py tender "Lastenheft Montage MDrive" "Das Dokument soll die Montagelinie für das MDrive Fahrwerk beschreiben. Das MDrive ist ein Fahrwerksystem, das im Rahmen einer Montagelinie zusammengesetzt wird. Der Inhalt bezieht sich auf die Abläufe, die beteiligten Stationen sowie auf die Integration in die bestehende Produktionsumgebung. Ziel ist es, die Struktur und Organisation der Linie sowie die Rahmenbedingungen für die Montageprozesse zu dokumentieren."

About

Long form LLM document creation using hierachical expansion. Focused on creating artificial procurement examples.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published