-
Notifications
You must be signed in to change notification settings - Fork 2
Exploring Creative Capabilities of Local Language Models
Artem Kazakov Kozlov edited this page Nov 21, 2024
·
3 revisions
Presenting a systematic approach to evaluating local language models' fiction writing capabilities through Python implementations. Using Gemma 2:27B, we tested narrative generation abilities through structured prompting and automated quality control systems. From minimal parameters (Fantasy genre, theme: "Anton falls in love with Garry", 5 chapters), the model produced sophisticated narrative content with impressive metrics. The findings indicate that local LLMs can generate sophisticated narrative content when properly engineered.
The book generation process consists of several key stages:
- Initialization and Environment Check:
- Validates Ollama (local LLM server) availability
- Configures logging system with color formatting for console
- Establishes base parameters (minimum/maximum word count per chapter, etc.)
- User Input Collection:
- Book genre
- Target audience
- Main themes
- Number of chapters
- Special requirements
- Writing style (from 4 options)
-
Book Concept Initialization (
initialize_book
):
- Creates unique title
- Forms core premise
- Describes setting
- Defines main conflict
- Creates stylistic notes
- Determines key locations and connections
- Initializes main plot threads
-
Character Creation (
create_characters
):
- Generates 3-5 unique characters
- For each character defines:
- Name
- Background
- Personality
- Goals
- Relationships with other characters
- Initial location
- Active goals
- Character development stage
- Motivation strength (0.0-1.0)
-
Plot Structure Creation (
create_plot_outline
):
- Divides story into three acts
- Creates key events for each chapter
- Determines character development
- Plans plot thread development
- Creates timeline markers
- Balances plot structure
-
Chapter Generation (
generate_chapter
): For each chapter:
- Creates context based on:
- Previous chapter
- Active plot threads
- Current character states
- Timeline markers
- Book themes
- Generates content considering:
- Narrative continuity
- Plot thread development
- Character interactions
- Movement logic
- Word count limits
- Validates and fixes continuity issues
- Updates world state
-
Book Export (
export_book
): Creates files:
- Complete manuscript (manuscript.txt)
- Individual chapter files
- Character profiles
- Plot outline
- Book metadata
- Timeline
- Error Handling System:
- Retry attempts for failed generation
- Intermediate results saving on interruption
- Detailed logging of all stages
- Continuity Maintenance:
- Character location tracking
- Movement logic verification
- Character relationship validation
- Plot thread development tracking
- Character consistency maintenance
- Logging System:
- Records all generation stages
- Color formatting for console
- Saves logs to separate files
- Tracks errors and warnings
-
Flesch-Kincaid Grade Level (9-10)
- Suitable for high school students aged 14-16
- Indicates sophisticated but accessible writing
- Based on sentence length and syllables per word analysis
-
Gunning Fog Index (11.2)
- College freshman level complexity
- Demonstrates advanced vocabulary usage
- Complex sentence structures while maintaining readability
Text demonstrated professional-grade complexity:
- 15-17 words average sentence length
- 25% unique terms in vocabulary
- 12% complex word usage rate
Overall Score: 4.8/5
Category | Score | Details |
---|---|---|
Plot Consistency | 5/5 | Clear narrative progression, logical event sequencing |
Character Development | 4.5/5 | Well-defined personality evolution, consistent motivation |
Emotional Depth | 5/5 | Nuanced relationship dynamics, complex internal conflicts |
Dialogue Quality | 4.5/5 | Natural conversations reflecting distinct character voices |
Atmosphere Creation | 5/5 | Rich sensory details, immersive world-building |
- Structured prompt engineering for story development
- Quality control system for validation
- Context management for coherence
- Character voice consistency automation
graph TD
A[User Input] --> B[NovelGenerator Core]
B --> C[Plot Generator]
B --> D[Character Generator]
B --> E[Scene Generator]
C --> F[Quality Control]
D --> F
E --> F
F --> G[Output Text]
- Plot structure development
- Character creation & relationship mapping
- Scene generation & pacing control
- Quality validation & refinement
- Final text compilation
- Plot coherence scoring
- Character consistency tracking
- Dialogue naturality assessment
- Narrative pacing analysis
- Style adherence verification