AI Novel Prompter
AI Novel Prompter создает консистентные промпты для написания романов с помощью ИИ и улучшает прозу через LLM. Включает надежное версионирование, поддержку нескольких проектов и гибкую интеграцию с ИИ для писателей.
AI Novel Prompter — это десктопное приложение, предназначенное для помощи писателям в создании последовательных и хорошо структурированных промптов для ИИ-ассистентов письма, таких как ChatGPT и Claude, а также для доработки существующих текстов с помощью LLM. Инструмент помогает управлять элементами повествования, деталями персонажей, генерировать промпты для продолжения романа и итеративно улучшать текст с помощью ИИ-подсказок.
Ключевые особенности
Варианты использования
AI Novel Prompter can generate writing prompts for novels based on user-specified characteristics.
AI Novel Prompter is a desktop application designed to help writers create consistent and well-structured prompts for AI writing assistants like ChatGPT and Claude, and also to refine existing prose using LLMs. The tool helps manage story elements, character details, generate prompts for continuing your novel, and iteratively improve text through AI-powered suggestions.
The Executable is on build/bin Executable
- Task Type Selection: Define and customize different types of writing tasks (e.g., "Write Next Chapter", "Revise Chapter").
- Sample Chapter Management: Store and reference sample chapters for style consistency.
- Chapter Content Tabs:
- Story Beats: Plan the main points for your next chapter.
- Previous Chapter: Reference the last written chapter.
- Future Notes: Keep track of planned future developments.
Each category can be edited, saved, and reused across different prompts:
- Rules: Define writing rules and style guidelines.
- Characters: Manage character profiles and details.
- Locations: Keep track of story locations and their descriptions.
- Codex: Store world-building elements and lore.
- Dual AI Support:
- ChatGPT-optimized formatting.
- Claude-optimized XML formatting.
- Real-time Preview: See your formatted prompt as you build it.
- Token Counting: Track token usage for AI model limits.
- Custom Instructions: Add specific requirements or guidelines to the main prompt.
- Iterative Text Refinement: Paste your text and apply a series of AI-powered improvement prompts.
- Customizable Improvement Prompts:
- Manage a list of prompts (e.g., "Enhance Imagery," "Strengthen Verbs," "Check for Clichés," "Grammar and Punctuation").
- Add, edit, delete, and reorder these improvement prompts.
- Prompts include examples of the expected JSON output format to guide the LLM.
- LLM Provider Integration:
- Supports Manual (copy/paste), LM Studio, and OpenRouter.
- Configure API URLs, API keys, and model identifiers for each provider.
- Flexible Configuration: Provider settings (API keys, models) can be loaded from a
.envfile (recommended for sensitive data),server/config.yaml, or overridden and saved via the UI to a localllm_provider_settings.jsonfile.
- Step-by-Step Processing: Execute improvement prompts one by one against your text.
- Change Review System:
- AI suggestions are parsed from JSON responses.
- Review each suggested change (
initialvs.improvedtext, and thereasonfor the change). - Accept or reject suggestions.
- View context for each change within the original text.
- Live Preview of Accepted Changes:
- A diff viewer (
react-diff-viewer) shows theoriginalTextvs. thecurrentText(with all accepted changes applied).
- A diff viewer (
- Robust JSON Parsing: The system attempts to extract and parse JSON even if the LLM includes conversational text around the JSON payload.
📁 Folder-Based Storage with Complete Version History
- Revolutionary folder-based system replacing single JSON files
- Complete version history with timestamped versioning for every entity
- Never lose data - every create, update, and delete operation is preserved
- One-click restore to any previous version of any entity
- Multiple data directories support for different projects/stories
📂 Storage Structure:
.ai-novel-prompter/
├── characters/
│ ├── aragorn_20250113_120000_create.json
│ ├── aragorn_20250113_130000_update.json
│ └── gandalf_20250113_140000_create.json
├── locations/
│ ├── rivendell_20250113_120000_create.json
│ └── mordor_20250113_130000_create.json
├── codex/
├── rules/
├── chapters/
├── story_beats/
├── future_notes/
├── sample_chapters/
├── task_types/
├── prose_prompts/
└── .metadata/
├── config.json
└── indexes.json
🔄 Version Management Features:
- Complete Audit Trail: Every change tracked with timestamp and operation type
- Intelligent File Naming:
{entity_name}_{YYYYMMDD_HHMMSS}_{operation}.jsonformat - Instant Restore: Restore any entity to any previous version with one click
- Storage Analytics: Detailed statistics on files, versions, and storage usage
- Retention Policies: Configurable cleanup of old versions to manage disk space
- Atomic Operations: All file operations are atomic and safe from corruption
💾 Automatic Migration Support:
- Seamless Upgrade: Automatic detection and migration from old JSON format
- Safe Migration: Backup creation before migration ensures data safety
- Validation: Complete verification that all data migrated successfully
- Zero Downtime: All existing functionality preserved during transition
🚀 Enhanced CLI with Data Directory Management:
# Use default data directory (~/.ai-novel-prompter)
./ainovelprompter
# Specify custom data directory for project isolation
./ainovelprompter --data-dir /path/to/project
./ainovelprompter -d "./Fantasy Novel"
# Multiple projects with different directories
./ainovelprompter -d "./Project A"
./ainovelprompter -d "./Project B"
# Show help and available options
./ainovelprompter --help
./ainovelprompter -h📁 Data Directory Benefits:
- Project Isolation: Keep different stories completely separate
- Easy Backup: Copy entire project folder for instant backup
- Team Collaboration: Share project folders via cloud storage
- Version Control: Track entire project history with git
- Portable Projects: Move projects between computers easily
- Clean, Modern Design: Built with shadcn/ui components.
- Tabbed Interface: Organized access to "Prompt Generation" and "Prose Improvement" features.
- Modal Editors: Easy editing of all manageable data types.
- Version History UI: Timeline view of all entity versions with visual operation indicators.
- Data Directory Manager: Frontend interface for switching between project directories.
- Frontend:
- React
- TypeScript
- Tailwind CSS
- shadcn/ui components
react-diff-viewerfor visualizing text changes.
- Backend:
- Go
- Wails framework
- Atomic file operations for data integrity
- JSON-based storage with versioning
github.com/joho/godotenvfor.envfile support.github.com/spf13/viperfor configuration management.
- User Data: Saved in configurable data directories with complete version history
- Default:
~/.ai-novel-prompterorC:\Users\YourUser\.ai-novel-prompter - Custom: Any directory specified via CLI or frontend settings
- Default:
- Version Management: Each entity maintains complete history with atomic file operations
- LLM Provider Configuration Priority:
- Settings saved via the UI (
llm_provider_settings.json). - Values from a
.envfile located in the project root (forwails dev) or next to the executable (for built app). Environment variables should be prefixed (e.g.,APP_OPENROUTER_API_KEY). - Values from
server/config.yaml. - Hardcoded defaults in the application.
- Settings saved via the UI (
.envFile: Create a.envfile in your project root for development to store API keys and default models (e.g.,APP_OPENROUTER_API_KEY="your_key"). Add.envto your.gitignorefile.
# Clone the repository
git clone https://github.com/danielsobrado/ainovelprompter
cd ainovelprompter
# Install Go dependencies for the backend (if not already handled by Wails)
# cd server
# go mod tidy
# cd ..
# Install frontend dependencies
cd frontend
npm install
cd ..
# Generate Wails bindings (important after Go backend changes)
wails generate bindings
# Build and run the application in development mode
wails dev
# Or run with custom data directory
wails dev --data-dir ./my-project-dataThe application now supports CLI options for enhanced project management:
# Use default data directory (~/.ai-novel-prompter)
./ainovelprompter
# Specify custom data directory
./ainovelprompter --data-dir /path/to/project
./ainovelprompter -d "./Fantasy Novel"
# Multiple projects with different directories
./ainovelprompter -d "./Project A"
./ainovelprompter -d "./Project B"
# Show help
./ainovelprompter --help
./ainovelprompter -hData Directory Benefits:
- Project Isolation: Keep different stories completely separate
- Easy Backup: Copy entire project folder for backup
- Team Collaboration: Share project folders via cloud storage
- Version Control: Track entire project history with git
To build a redistributable, production mode package, use wails build.
wails buildThe Executable is on build/bin Executable
Or generate it with:
wails build -nsisThis can be done for Mac as well see the latest part of this guide
The built application will be available in the build directory.
- Initial Setup:
- In the "Prompt Generation" tab, define your task types (e.g., "Write Next Chapter," "Revise Chapter") by clicking the edit icon next to the "Task Type" selector.
- Add sample chapters for style reference via the "Sample Chapters" selector and its edit icon.
- Set up your "Rules," "Characters," "Locations," and "Codex" entries using their respective selectors and edit icons. All these are saved locally with complete version history.
- Creating a Prompt:
- Select your desired "Task Type."
- Input content into the "Story Beats," "Previous Chapter," and "Future Notes" tabs.
- Select the relevant "Rules," "Characters," "Locations," and "Codex" entries that apply to the chapter you're planning.
- Add any specific "Custom Instructions" in the text area provided.
- Generating Output:
- Choose between "ChatGPT" or "Claude" optimized prompt formats using the buttons in the "Generated Prompt" section.
- Review the dynamically generated prompt in the preview area.
- Use the "Copy to Clipboard" button and paste the prompt into your preferred AI writing assistant.
- Configure LLM Provider:
- Navigate to the "Prose Improvement" tab.
- Click the "Provider Settings" button (cog icon).
- In the modal:
- Select your LLM provider: Manual (for copy/pasting), LM Studio, or OpenRouter.
- LM Studio: Enter the API URL (e.g.,
http://localhost:1234/v1/chat/completions) and the model identifier loaded in your LM Studio instance. - OpenRouter: Enter your OpenRouter API Key and the desired model identifier (e.g.,
anthropic/claude-3-haiku,openai/gpt-4o). This is a free-text field.
- These settings are loaded with a priority:
- Previously saved settings from the UI (stored in
llm_provider_settings.json). - Settings from your project's
.envfile (e.g.,APP_OPENROUTER_API_KEY). - Settings from
server/config.yaml. - Application defaults.
- Previously saved settings from the UI (stored in
- Changes made here are saved to
llm_provider_settings.jsonfor future sessions.
- Manage Improvement Prompts:
- Within the "Prose Improvement" tab, go to the "Prompts" sub-tab.
- Review the default prompts (e.g., "Enhance Imagery," "Strengthen Verbs," "Check for Clichés," "Grammar and Punctuation").
- You can add your own custom improvement prompts, edit existing ones (including their label, prompt text, category, and order), or delete them.
- Important: For prompts expected to return structured data (like lists of changes), ensure the prompt text clearly instructs the LLM on the desired JSON format and includes an example of the JSON structure with specific keys (e.g.,
"initial_text","improved_text","reason"). This greatly improves parsing reliability. - These prompts are saved locally with full version history.
- Process Text:
- Go to the "Input Text" sub-tab, paste the text you want to improve, and click "Start Improvement Session."
- Navigate to the "Process" sub-tab.
- The first prompt from your managed list will be displayed.
- Click "Execute Prompt."
- If using LM Studio or OpenRouter, the application will send the prompt and text to the LLM.
- If using Manual mode, the full prompt (including your text) will be copied to your clipboard. Paste this into your chosen LLM, get the response, then paste the LLM's JSON response back into the "Paste AI response here..." text area in the app and click "Process Response."
- The application will attempt to parse the LLM's JSON response.
- Review Changes:
- After processing, navigate to the "Review Changes" sub-tab.
- Suggested changes from the LLM will be listed. Each card will show:
- The original text segment (
initial). - The LLM's suggested improvement (
improved). - The LLM's
reasonfor the change. - Context snippets from the original text (if available and enabled).
- The original text segment (
- You can "Accept" or "Reject" each suggestion.
- The "Current Text Preview" at the bottom uses
react-diff-viewerto show a live diff between your original input text for the session and the current state of the text with all accepted changes applied. - Once you've reviewed changes from one prompt, you can go back to the "Process" tab to execute the next prompt in your list against the updated text.
🏠 Default Location: ~/.ai-novel-prompter (Windows: C:\Users\{username}\.ai-novel-prompter)
📁 Custom Directories: Use CLI options or frontend settings to work with multiple projects:
# Different story projects
./ainovelprompter -d "./Fantasy Novel"
./ainovelprompter -d "./Sci-Fi Story"
./ainovelprompter -d "./Historical Fiction"🔧 Frontend Management:
- Open Settings → Data Directory Manager
- Browse for new directory or select from recent
- Validate directory before switching
- View storage statistics and entity counts
- Migrate from old JSON format if needed
📖 Viewing History:
- Every entity maintains complete version history with timestamps
- Timeline shows all create/update/delete operations with visual indicators
- Click History icon next to any entity to view versions
- Preview any version before restoring
⏪ Restoring Versions:
- Navigate to entity's version history
- Select desired version from timeline
- Preview version content to verify
- Click Restore to create new version from selected point
- Current version becomes new historical entry
- Atomic operation - safe from corruption or data loss
🧹 Cleanup & Maintenance:
- Automatic cleanup removes old versions based on configurable retention policy
- Manual cleanup via storage statistics interface
- Backup entire directory before major changes
- Storage analytics show disk usage by entity type and version count
🔄 Automatic Detection: App detects old JSON files and offers migration wizard
📋 Migration Process:
- Backup Creation: Automatic backup of old format with timestamp
- Entity Conversion: Each JSON entry becomes properly versioned entity
- Timestamp Assignment: Proper creation/update timestamps assigned
- Validation: Complete verification that all data migrated successfully
- Cleanup: Option to archive old JSON files post-migration
⚠️ Migration Notes:
- One-time process per data directory
- Irreversible (but backup is created automatically)
- Maintains all data including relationships and metadata
- Preserves settings and configurations
- Zero data loss with complete validation
📂 Directory Structure:
Stories/
├── Fantasy-Series/
│ ├── Book-1/
│ └── Book-2/
├── Standalone-Novel/
└── Short-Stories/
💾 Backup Strategy:
- Cloud sync entire project directories for automatic backup
- Git repositories for version control across devices and team collaboration
- Scheduled backups of active projects to external storage
- Export functionality for sharing specific entities or projects
👥 Team Collaboration:
- Share project directories via cloud storage (Dropbox, Google Drive, etc.)
- Version conflicts resolved automatically through timestamp comparison
- Entity-level granularity minimizes merge conflicts between team members
- Complete audit trail shows who changed what and when
- Prompt Generation: The codebase supports easy addition of new selectors (for managing different types of story elements) and options. Modal components for editing these elements follow a consistent pattern. Data persistence is handled via versioned folder storage with atomic operations.
- Prose Improvement:
- New default improvement prompts can be added to the
DEFAULT_PROSE_IMPROVEMENT_PROMPTSarray insrc/utils/constants.ts. Remember to include clear JSON output examples in the prompt text. - The JSON parser in
src/hooks/useProseImprovement.tsis designed to be somewhat flexible with key names from LLM responses by checking for common variations (e.g.,original,initial,original_text). However, it benefits greatly from well-defined prompts that specify exact key names. - Support for new LLM providers can be added by extending the
LLMProvidertype insrc/types.tsand updating the logic insrc/hooks/useLLMProvider.tsandsrc/components/ProseImprovement/ProviderSettings.tsx.
- New default improvement prompts can be added to the
- Data Persistence: All data operations use the versioned folder storage system. New entity types can be added by extending the storage interfaces and implementing the corresponding handlers. All operations are atomic and maintain complete version history.
📋 Comprehensive Test Suite:
# Run all tests
./scripts/test.sh
# Frontend tests only
./scripts/test.sh --frontend-only
# Backend tests only
./scripts/test.sh --backend-only
# With coverage reports
./scripts/test.sh --coverage
# Test storage system specifically
cd cmd/test-storage
go run main.go🧪 Storage System Tests:
- Version Management: Create, update, restore operations
- Migration Testing: Old JSON to new folder format
- Atomic Operations: Data integrity under concurrent access
- Performance: Large dataset handling and cleanup
- Legacy Compatibility: All existing MCP tools work unchanged
- Styling: All components use Tailwind CSS. Customizations can be made by modifying utility classes or adding custom CSS to
src/index.css. - UI Components: Built with shadcn/ui. These components can be customized as per shadcn/ui documentation.
- Prompt Formatting (Main Tab): The logic for constructing prompts for ChatGPT and Claude in the "Prompt Generation" tab can be modified in
src/utils/promptGenerators.tsandsrc/utils/promptInstructions.ts. - Prose Improvement Prompts: These are primarily managed via the UI with complete version history. Default prompts are in
src/utils/constants.ts. - Storage System: The folder-based storage can be extended for new entity types by implementing the versioned storage interfaces.
- User registration and authentication
- Text creation and management
- Chapter creation and management
- Feedback submission and management
- Prompt generation based on traits
- Integration with a local ollama service
- Based on Berry template (https://codedthemes.gitbook.io/berry)
- Inspired on Jason Hamilton Youtube (https://www.youtube.com/@TheNerdyNovelist)
- Frontend:
- React
- TypeScript
- Axios
- React Router
- React Toastify
- Backend:
- Go
- Gin Web Framework
- GORM (Go ORM)
- PostgreSQL
Before running the application, make sure you have the following installed:
- Node.js (v18 or higher)
- Go (v1.18 or higher)
- PostgreSQL
- Docker
- Docker Compose
- Clone the repository:
git clone https://github.com/danielsobrado/ainovelprompter.git - Navigate to the project directory:
cd ainovelprompter - Set up the backend:
-
Navigate to the
serverdirectory:cd server -
Install the Go dependencies:
go mod download -
Update the
config.yamlfile with your database configuration. -
Run the database migrations:
go run cmd/main.go migrate -
Start the backend server:
go run cmd/main.go
- Set up the frontend:
-
Navigate to the
clientdirectory:cd ../client -
Install the frontend dependencies:
npm install -
Start the frontend development server:
npm start
- Open your web browser and visit
http://localhost:3000to access the application.
- Clone the repository:
git clone https://github.com/danielsobrado/ainovelprompter.git
- Navigate to the project directory:
cd ainovelprompter
-
Update the
docker-compose.ymlfile with your database configuration. -
Start the application using Docker Compose:
docker-compose up -d
- Open your web browser and visit
http://localhost:3000to access the application.
- Backend configuration can be modified in the
server/config.yamlfile. - Frontend configuration can be modified in the
client/src/config.tsfile.
To build the frontend for production, run the following command in the client directory:
npm run build
The production-ready files will be generated in the client/build directory.
This small guide provides instructions on how to install PostgreSQL on the Windows Subsystem for Linux (WSL), along with steps to manage user permissions and troubleshoot common issues.
- Windows 10 or higher with WSL enabled. (Or just Ubuntu)
- Basic familiarity with Linux command line and SQL.
-
Open WSL Terminal: Launch your WSL distribution (Ubuntu recommended).
-
Update Packages:
sudo apt update
-
Install PostgreSQL:
sudo apt install postgresql postgresql-contrib
-
Check Installation:
psql --version
-
Set PostgreSQL User Password:
sudo passwd postgres
-
Create Database:
createdb mydb
-
Access Database:
psql mydb
-
Import Tables from SQL File:
psql -U postgres -q mydb < /path/to/file.sql -
List Databases and Tables:
\l # List databases \dt # List tables in the current database
-
Switch Database:
\c dbname
-
Create New User:
CREATE USER your_db_user WITH PASSWORD 'your_db_password';
-
Grant Privileges:
ALTER USER your_db_user CREATEDB;
-
Role Does Not Exist Error: Switch to the 'postgres' user:
sudo -i -u postgres createdb your_db_name
-
Permission Denied to Create Extension: Login as 'postgres' and execute:
CREATE EXTENSION IF NOT EXISTS pg_trgm;
-
Unknown User Error: Ensure you are using a recognized system user or correctly refer to a PostgreSQL user within the SQL environment, not via
sudo.
To generate custom training data for fine-tuning a language model to emulate the writing style of George MacDonald, the process begins by obtaining the full text of one of his novels, "The Princess and the Goblin," from Project Gutenberg. The text is then broken down into individual story beats or key moments using a prompt that instructs the AI to generate a JSON object for each beat, capturing the author, emotional tone, type of writing, and the actual text excerpt.
Next, GPT-4 is used to rewrite each of these story beats in its own words, generating a parallel set of JSON data with unique identifiers linking each rewritten beat to its original counterpart. To simplify the data and make it more useful for training, the wide variety of emotional tones is mapped to a smaller set of core tones using a Python function. The two JSON files (original and rewritten beats) are then used to generate training prompts, where the model is asked to rephrase the GPT-4 generated text in the style of the original author. Finally, these prompts and their target outputs are formatted into JSONL and JSON files, ready to be used for fine-tuning the language model to capture MacDonald's distinctive writing style.
In the previous example, the process of generating paraphrased text using a language model involved some manual tasks. The user had to manually provide the input text, run the script, and then review the generated output to ensure its quality. If the output did not meet the desired criteria, the user would need to manually retry the generation process with different parameters or make adjustments to the input text.
However, with the updated version of the process_text_file function, the entire process has been fully automated. The function takes care of reading the input text file, splitting it into paragraphs, and automatically sending each paragraph to the language model for paraphrasing. It incorporates various checks and retry mechanisms to handle cases where the generated output does not meet the specified criteria, such as containing unwanted phrases, being too short or too long, or consisting of multiple paragraphs.
The automation process includes several key features:
-
Resuming from the last processed paragraph: If the script is interrupted or needs to be run multiple times, it automatically checks the output file and resumes processing from the last successfully paraphrased paragraph. This ensures that progress is not lost and the script can pick up where it left off.
-
Retry mechanism with random seed and temperature: If a generated paraphrase fails to meet the specified criteria, the script automatically retries the generation process up to a specified number of times. With each retry, it randomly changes the seed and temperature values to introduce variation in the generated responses, increasing the chances of obtaining a satisfactory output.
-
Progress saving: The script saves the progress to the output file every specified number of paragraphs (e.g., every 500 paragraphs). This safeguards against data loss in case of any interruptions or errors during the processing of a large text file.
-
Detailed logging and summary: The script provides detailed logging information, including the input paragraph, generated output, retry attempts, and reasons for failure. It also generates a summary at the end, displaying the total number of paragraphs, successfully paraphrased paragraphs, skipped paragraphs, and the total number of retries.
Generating Custom Training Data to Fine-Tune a Language Model with Local LLM and LM Studio using ORPO
To generate ORPO custom training data for fine-tuning a language model to emulate the writing style of George MacDonald.
The input data should be in JSONL format, with each line containing a JSON object that includes the prompt and chosen response. (From the previous fine tuning) To use the script, you need to set up the OpenAI client with your API key and specify the input and output file paths. Running the script will process the JSONL file and generate a CSV file with columns for the prompt, chosen response, and a generated rejected response. The script saves progress every 100 lines and can resume from where it left off if interrupted. Upon completion, it provides a summary of the total lines processed, written lines, skipped lines, and retry details.
-
Dataset Quality Matters: 95% of outcomes depend on dataset quality. A clean dataset is essential since even a little bad data can hurt the model.
-
Manual Data Review: Cleaning and evaluating the dataset can greatly improve the model. This is a time-consuming but necessary step because no amount of parameter adjusting can fix a defective dataset.
-
Training parameters should not improve but prevent model degradation. In robust datasets, the goal should be to avoid negative repercussions while directing the model. There is no optimal learning rate.
-
Model Scale and Hardware Limitations: Larger models (33b parameters) may enable better fine-tuning but require at least 48GB VRAM, making them impractical for majority of home setups.
-
Gradient Accumulation and Batch Size: Gradient accumulation helps reduce overfitting by enhancing generalisation across different datasets, but it may lower quality after a few batches.
-
The size of the dataset is more important for fine-tuning a base model than a well-tuned model. Overloading a well-tuned model with excessive data might degrade its previous fine-tuning.
-
An ideal learning rate schedule starts with a warmup phase, holds steady for an epoch, and then gradually decreases using a cosine schedule.
-
Model Rank and Generalisation: The amount of trainable parameters affects the model's detail and generalisation. Lower-rank models generalise better but lose detail.
-
LoRA's Applicability: Parameter-Efficient Fine-Tuning (PEFT) is applicable to large language models (LLMs) and systems like Stable Diffusion (SD), demonstrating its versatility.
The Unsloth community has helped resolve several issues with finetuning Llama3. Here are some key points to keep in mind:
-
Double BOS tokens: Double BOS tokens during finetuning can break things. Unsloth automatically fixes this issue.
-
GGUF conversion: GGUF conversion is broken. Be careful of double BOS and use CPU instead of GPU for conversion. Unsloth has built-in automatic GGUF conversions.
-
Buggy base weights: Some of Llama 3's base (not instruct) weights are "buggy" (untrained):
<|reserved_special_token_{0->250}|> <|eot_id|> <|start_header_id|> <|end_header_id|>. This can cause NaNs and buggy results. Unsloth automatically fixes this. -
System prompt: According to the Unsloth community, adding a system prompt makes finetuning of the Instruct version (and possibly the base version) much better.
-
Quantization issues: Quantization issues are common. See this comparison which shows that you can get good performance with Llama3, but using the wrong quantization can hurt performance. For finetuning, use bitsandbytes nf4 to boost accuracy. For GGUF, use the I versions as much as possible.
-
Long context models: Long context models are poorly trained. They simply extend the RoPE theta, sometimes without any training, and then train on a weird concatenated dataset to make it a long dataset. This approach does not work well. A smooth, continuous long context scaling would have been much better if scaling from 8K to 1M context length.
To resolve some of these issues, use Unsloth for finetuning Llama3.
When fine-tuning a language model for paraphrasing in an author's style, it's important to evaluate the quality and effectiveness of the generated paraphrases.
The following evaluation metrics can be used to assess the model's performance:
-
BLEU (Bilingual Evaluation Understudy):
- BLEU measures the n-gram overlap between the generated paraphrase and the reference text, providing a score between 0 and 1.
- To calculate BLEU scores, you can use the
sacrebleulibrary in Python. - Example usage:
from sacrebleu import corpus_bleu; bleu_score = corpus_bleu(generated_paraphrases, [original_paragraphs])
-
ROUGE (Recall-Oriented Understudy for Gisting Evaluation):
- ROUGE measures the overlap of n-grams between the generated paraphrase and the reference text, focusing on recall.
- To calculate ROUGE scores, you can use the
rougelibrary in Python. - Example usage:
from rouge import Rouge; rouge = Rouge(); scores = rouge.get_scores(generated_paraphrases, original_paragraphs)
-
Perplexity:
- Perplexity quantifies the uncertainty or confusion of the model when generating text.
- To calculate perplexity, you can use the fine-tuned language model itself.
- Example usage:
perplexity = model.perplexity(generated_paraphrases)
-
Stylometric Measures:
- Stylometric measures capture the writing style characteristics of the target author.
- To extract stylometric features, you can use the
stylometrylibrary in Python. - Example usage:
from stylometry import extract_features; features = extract_features(generated_paraphrases)
To integrate these evaluation metrics into your Axolotl pipeline, follow these steps:
-
Prepare your training data by creating a dataset of paragraphs from the target author's works and splitting it into training and validation sets.
-
Fine-tune your language model using the training set, following the approach discussed earlier.
-
Generate paraphrases for the paragraphs in the validation set using the fine-tuned model.
-
Implement the evaluation metrics using the respective libraries (
sacrebleu,rouge,stylometry) and calculate the scores for each generated paraphrase. -
Perform human evaluation by collecting ratings and feedback from human evaluators.
-
Analyze the evaluation results to assess the quality and style of the generated paraphrases and make informed decisions to improve your fine-tuning process.
Here's an example of how you can integrate these metrics into your pipeline:
from sacrebleu import corpus_bleu
from rouge import Rouge
from stylometry import extract_features
# Fine-tune the model using the training set
fine_tuned_model = train_model(training_data)
# Generate paraphrases for the validation set
generated_paraphrases = generate_paraphrases(fine_tuned_model, validation_data)
# Calculate evaluation metrics
bleu_score = corpus_bleu(generated_paraphrases, [original_paragraphs])
rouge = Rouge()
rouge_scores = rouge.get_scores(generated_paraphrases, original_paragraphs)
perplexity = fine_tuned_model.perplexity(generated_paraphrases)
stylometric_features = extract_features(generated_paraphrases)
# Perform human evaluation
human_scores = collect_human_evaluations(generated_paraphrases)
# Analyze and interpret the results
analyze_results(bleu_score, rouge_scores, perplexity, stylometric_features, human_scores)Remember to install the necessary libraries (sacrebleu, rouge, stylometry) and adapt the code to fit your implementation in Axolotl or similar.
In this experiment, I explored the capabilities and differences between various AI models in generating a 1500-word text based on a detailed prompt. I tested models from https://chat.lmsys.org/, ChatGPT4, Claude 3 Opus, and some local models in LM Studio. Each model generated the text three times to observe variability in their outputs. I also created a separate prompt for evaluating the writing of the first iteration from each model and asked ChatGPT 4 and Claude Opus 3 to provide feedback.
Through this process, I observed that some models exhibit higher variability between executions, while others tend to use similar wording. There were also significant differences in the number of words generated and the amount of dialogue, descriptions, and paragraphs produced by each model. The evaluation feedback revealed that ChatGPT suggests a more "refined" prose, while Claude recommends less purple prose. Based on these findings, I compiled a list of takeaways to incorporate into the next prompt, focusing on precision, varied sentence structures, strong verbs, unique twists on fantasy motifs, consistent tone, distinct narrator voice, and engaging pacing. Another technique to consider is asking for feedback and then rewriting the text based on that feedback.
I'm open to collaborating with others to further fine-tune prompts for each model and explore their capabilities in creative writing tasks.
- Direct Instructions:
- Use clean, specific, and direct commands.
- Avoid verbosity and unnecessary phrases.
- Adjective Management:
- Be cautious with adjectives; they may influence the model's response inappropriately.
- Delimiters and Markdown:
- Use backticks, brackets, or markdown to separate distinct parts of the text.
- Markdown helps structure and segregate sections effectively.
- Structured Formats:
- Utilize JSON, markdown, HTML, etc., for input and output.
- Constrain output using JSON schema when necessary.
- Few-shot Examples:
- Provide few-shot examples from various niches to avoid overfitting.
- Use these examples to "teach" the model steps in a process.
- Chain-of-Thought:
- Implement chain-of-thought prompts to improve reasoning and procedural understanding.
- Break down tasks into steps and guide the model through them.
- Description Before Completion:
- Prompt the model to describe entities before answering.
- Ensure that description doesn't bleed into completion unintentionally.
- Context Management:
- Provide essential context only, avoid unstructured paragraph dumps.
- Direct the model towards the desired answer with sufficient but concise context.
- Testing and Verification:
- Test prompts multiple times to catch unexpected outputs.
- Use completion ranking for relevance, clarity, and coherence.
- Use Stories:
- Control output with storytelling techniques.
- For example, write a narrative that includes the desired output format.
- GBNF Grammars:
- Explore GBNF grammars to constrain and control model output.
- Read and Refine:
- Review and refine generated prompts to remove unnecessary phrases and ensure clarity.
Models have inherent formatting biases. Some models prefer hyphens for lists, others asterisks. When using these models, it's helpful to mirror their preferences for consistent outputs.
-
Formatting Tendencies:
-
Llama 3 prefers lists with bolded headings and asterisks.
-
Example: Bolded Title Case Heading
-
List items with asterisks after two newlines
-
List items separated by one newline
Next List
-
More list items
-
Etc...
-
-
-
Few-shot Examples:
- Llama 3 follows both system prompts and few-shot examples.
- It is flexible with prompting methods but may quote few-shot examples verbatim.
-
System Prompt Adherence:
- Llama 3 responds well to system prompts with detailed instructions.
- Combining system prompts and few-shot examples yields better results.
-
Context Window:
- The current context window is small, limiting the use of extensive few-shot examples.
- This may be addressed in future updates.
-
Censorship:
- The instruct version has some censorship but is less restricted than previous versions.
-
Intelligence:
- Performs well in zero-shot chain-of-thought reasoning.
- Capable of understanding and adapting to varied inputs.
-
Consistency:
- Generally consistent but may directly quote examples.
- Performance can degrade with higher temperatures.
-
Lists and Formatting:
- Use the preferred list format for better accuracy.
- Explicitly instruct Llama 3 on desired output formats if different from its default.
-
Chat Settings:
- Suitable for tasks requiring intelligence and instruction following.
- Limited by context window for large tasks.
-
Pipeline Settings:
- Effective for GPT-4 style pipelines using system prompts.
- Context window limitations restrict some tasks.
Llama 3 is flexible and intelligent but has context and quoting limitations. Adjust prompting methods accordingly.
All comments are welcome. Open an issue or send a pull request if you find any bugs or have recommendations for improvement.
This project is licensed under: Attribution-NonCommercial-NoDerivatives (BY-NC-ND) license See: https://creativecommons.org/licenses/by-nc-nd/4.0/deed.en
AI Novel Prompter
AI Novel Prompter — это десктопное приложение для писателей, которое помогает создавать структурированные промпты для AI-ассистентов (ChatGPT, Claude) и улучшать уже написанный текст. Инструмент управляет элементами сюжета, персонажами, генерирует промпты для продолжения романа и итеративно дорабатывает прозу с помощью LLM.
Приложение построено на фреймворке Wails (Go + React) и работает локально, храня все данные с полной историей версий.
Возможности
1. Управление задачами и главами (вкладка «Prompt Generation»)
- Типы задач: настройка собственных типов (например, «Написать следующую главу», «Отредактировать главу»).
- Семплы глав: хранение и использование образцов глав для сохранения стиля.
- Вкладки содержания главы:
- Story Beats — ключевые сюжетные моменты.
- Previous Chapter — ссылка на предыдущую главу.
- Future Notes — заметки о планах.
2. Управление элементами истории (там же)
Каждая категория редактируется, сохраняется и переиспользуется:
- Rules — правила и стилистические указания.
- Characters — профили персонажей.
- Locations — локации с описаниями.
- Codex — элементы мира и лор.
3. Генерация промптов
- Оптимизация под ChatGPT и Claude: отдельные форматы (обычный и XML).
- Предпросмотр в реальном времени: промпт формируется по мере редактирования.
- Подсчёт токенов: контроль лимитов моделей.
- Пользовательские инструкции: добавление особых требований.
4. Улучшение прозы (вкладка «Prose Improvement»)
- Итеративная доработка: вставьте текст и примените последовательность AI-подсказок.
- Список улучшающих промптов: настраиваемые (например, «Усилить образность», «Проверить клише», «Грамматика»). Промпты можно добавлять, редактировать, удалять и менять порядок.
- Поддержка провайдеров LLM:
- Manual (копирование/вставка).
- LM Studio.
- OpenRouter.
- Настройка провайдера: URL, API-ключ, модель. Данные загружаются из
.env,server/config.yamlили сохраняются через UI (llm_provider_settings.json). - Пошаговая обработка: выполнение промптов один за другим.
- Система ревью изменений:
- AI-предложения парсятся из JSON-ответов.
- Показывается исходный текст, улучшенный и причина изменения.
- Можно принять или отклонить каждое изменение.
- Diff-просмотрщик (react-diff-viewer) показывает разницу между оригиналом и текущей версией.
5. Сохранение данных и версионирование
Файловая система с полной историей версий:
- Каждая сущность (персонаж, локация и т.д.) хранится как файл с меткой времени:
{имя}_{YYYYMMDD_HHMMSS}_{операция}.json. - Никакие данные не теряются — все create/update/delete сохраняются.
- Восстановление любой версии в один клик.
- Поддержка нескольких директорий для разных проектов.
Структура по умолчанию:
.ai-novel-prompter/
├── characters/
├── locations/
├── codex/
├── rules/
├── chapters/
├── story_beats/
├── future_notes/
├── sample_chapters/
├── task_types/
├── prose_prompts/
└── .metadata/
├── config.json
└── indexes.json
6. Командная строка
# Запуск с директорией по умолчанию (~/.ai-novel-prompter)
./ainovelprompter
# С указанием кастомной директории (изоляция проектов)
./ainovelprompter --data-dir /path/to/project
./ainovelprompter -d "./Фэнтези-роман"
# Справка
./ainovelprompter --help
Такой подход позволяет легко делать резервное копирование, совместную работу (через облако) и контроль версий через git.
Установка и запуск
Требования
- Go, Node.js, Wails CLI.
Шаги
git clone https://github.com/danielsobrado/ainovelprompter
cd ainovelprompter
# Установка зависимостей фронтенда
cd frontend
npm install
cd ..
# Генерация привязок Wails (после изменений Go-бэкенда)
wails generate bindings
# Запуск в режиме разработки
wails dev
# Или с указанием кастомной директории
wails dev --data-dir ./my-project-data
Сборка production-версии
wails build
# или
wails build -nsis # для создания Windows-установщика
Готовый исполняемый файл появится в build/bin/. Скачать готовую сборку можно здесь.
Использование
A. Генерация промпта
- Во вкладке «Prompt Generation» определите типы задач, добавьте образцы глав, настройте правила, персонажей, локации и кодекс.
- Выберите тип задачи, заполните Story Beats / Previous Chapter / Future Notes.
- Выберите нужные элементы (правила, персонажи и т.д.).
- Добавьте пользовательские инструкции.
- Выберите формат (ChatGPT или Claude) и скопируйте готовый промпт.
B. Улучшение прозы
- Во вкладке «Prose Improvement» настройте провайдера LLM через кнопку «Provider Settings».
- Управляйте списком улучшающих промптов (Prompts sub-tab).
- Вставьте текст во вкладку «Input Text» и нажмите «Start Improvement Session».
- Перейдите на вкладку «Process», выберите промпт и выполните его. При ручном режиме скопируйте промпт, получите ответ LLM и вставьте его обратно.
- Во вкладке «Review Changes» просмотрите предложения, примите или отклоните их.
Конфигурация
Параметры подключения к LLM (API URL, ключи, модели) загружаются в следующем приоритете:
- Сохранённые через UI (
llm_provider_settings.json). - Переменные окружения из файла
.env(префиксAPP_, напримерAPP_OPENROUTER_API_KEY). server/config.yaml.- Жёстко заданные значения по умолчанию.
Рекомендуется хранить чувствительные данные (API-ключи) в .env и добавить его в .gitignore.
Технический стек
- Фронтенд: React, TypeScript, Tailwind CSS, shadcn/ui, react-diff-viewer.
- Бэкенд: Go, Wails, атомарные файловые операции, JSON-хранилище с версионированием.
- Библиотеки:
godotenv(.env),viper(конфигурация).
Примечание
Данный README описывает только функциональность, присутствующую в исходном описании. Некоторые детали (например, полное описание работы с версиями в UI) могут быть сокращены для лаконичности.
С какими LLM-провайдерами интегрируется AI Novel Prompter?
AI Novel Prompter предлагает гибкую интеграцию с различными LLM-провайдерами, включая LM Studio, OpenRouter и Manual (копирование/вставка). Вы можете легко настроить URL API, ключи и модели, причем настройки отдают приоритет сохранениям через UI, файлам .env и конфигурационным файлам для удобства.
Как AI Novel Prompter обрабатывает мои данные и проекты?
Он использует революционную систему хранения на основе папок с полной историей версий для каждой сущности (персонажи, главы и т.д.), что гарантирует, что вы никогда не потеряете данные. Он также поддерживает несколько каталогов данных через CLI или UI, позволяя вам изолировать и организовывать различные писательские проекты.
Могу ли я улучшить свой существующий текст с помощью AI Novel Prompter?
Да, вкладка «Улучшение прозы» позволяет вставить текст и применить серию настраиваемых предложений на основе ИИ (например, «Улучшить образность», «Проверить клише»). Она включает надежную систему проверки изменений с просмотрщиком diff для принятия или отклонения улучшений.
Как AI Novel Prompter помогает в генерации промптов для романов?
Он предоставляет всесторонние инструменты для управления элементами истории, такими как персонажи, локации, правила и кодекс. Вы можете определять типы задач, ссылаться на предыдущие главы, планировать сюжетные повороты и генерировать промпты, оптимизированные для конкретных моделей ИИ, с предпросмотром в реальном времени и подсчетом токенов.
Что такое AI Novel Prompter и как он помогает писателям?
AI Novel Prompter — это десктопное приложение, предназначенное для помощи писателям в создании последовательных и хорошо структурированных писательских промптов для ИИ-ассистентов письма (таких как ChatGPT/Claude) и итеративном улучшении существующей прозы с использованием больших языковых моделей. Он оптимизирует творческий процесс от планирования до полировки.
Комментарии
Комментариев пока нет. Будьте первым.