LLM-based style replication: The Style Tool#
Experimental context#
The Style Tool arose from a discussion about the possibilities of large language models as fundamental tools for working with language. The central question was: To what extent can LLMs copy and imitate language and writing styles?
The question seemed interesting because styles are more than just sentence structure. They structure differently, have different narratives, sequences, and flows. While simple style prompts can already imitate general styles, the aim was to explore whether these more complex dimensions can also be replicated. The project was conceived as a learning vehicle.
The tool and how it works#
Style is a Gradio-based web application with four main functions:
Transform: Converts input text according to style profiles. Profiles can be loaded from a library, uploaded, or entered as a direct prompt. A feedback function enables iterative refinement.
Analyze style: Systematically extracts style features from sample texts. The analysis captures linguistic features (sentence length, complexity, passive voice, nominal style), lexical aspects (technical terminology, degree of abstraction), pragmatic dimensions (formality, reader address, objective), and structural properties (paragraph length, depth of structure). Optionally, target texts or target descriptions can be specified.
Fine-tuning: Users can load a base profile and submit before-and-after text pairs. The system analyzes the change patterns between the original and the edited text and derives transformation rules from them. This approach reflects the common practice of receiving AI responses and then adapting them. Up to five pairs can be processed.
Style overview: Visualizes style profiles and displays generated prompts. Profiles can be exported as JSON, prompt text, or ZIP package.
The tool processes TXT, Markdown, and DOCX files and supports a context window of 250,000 tokens.
Technical architecture#
The application comprises 2140 lines of Python code in six files. The main application (1200 lines) orchestrates four specialized modules: LLM integration with token management (llm_client.py), document processing (document_processor.py), profile management (profile_manager.py), and export functions (export_handler.py).
A central approach is the combination of structured JSON data and natural language prompts. Style profiles contain structured features (numbers, categories) and natural language transformation instructions. This mixture had already proven beneficial in other experiments.
The three system prompts for analysis, transformation, and diff comparison are organized as separate template files. The tool uses an LLM from Humboldt University Berlin via an OpenAI-compatible interface.
Development process#
The development followed a clear pattern: First, there was intensive interaction to exchange solutions until a clear picture emerged—especially regarding the division into functional areas (tabs). During this discussion, it became clear that JSON was suitable as an import/export format.
The idea was not only to derive styles from input texts, but also to be able to give instructions on what should be taken into account. In addition, it should be possible to fine-tune by tracking changes – a pattern that is also frequently used in everyday life.
Only after the specification, technical approaches, and architecture had been fully clarified did implementation take place. KISS principles were strictly adhered to during the specification coordination in order to achieve a simple, effective solution.
The high-quality specification enabled complete implementation in just one iteration. The entire first implementation, including coding and deployment, took about 90 minutes. After that, only two small iterations were necessary for error corrections (30 minutes each).
Validation and findings#
The tool is currently being tested. Initial tests show that it works very well. So far, about ten style profiles have been created.
The range of replicable styles is particularly interesting: Not only author styles such as Goethe work, but also speech styles of Helmut Schmidt or Barack Obama. Genres such as interviews or comics can also be reproduced.
The comic style works particularly well: the tool generates comic language and describes individual panels. These texts could then be converted into graphic comics using a diffusion model. The linguistic basis works very well.
The possibilities seem very impressive. So far, they seem to be very far-reaching. A surprising finding: style is apparently a cultural phenomenon and not just a linguistic one – and yet it can still be replicated.
Methodological findings#
The key transferable finding: the higher the quality of the specification process and the specification, the better the idea can be implemented. Architectural experience is very important here.
At 4,000 lines (2,000 of which were Python), the project was small and easily manageable – only six Python files, the rest are prompts. By focusing on a detailed, complete specification, the development time was reduced to 90 minutes.
The hybrid approach of linguistic instructions and structured JSON data proved to be elegant and practical. Token management as a standard pattern and JSON structuring from LLM outputs work reliably from the outset when adopted as proven techniques from previous projects.
The diff-based approach to fine-tuning works well but needs to be explored further. It maps real workflows and makes implicit adjustments explicit.