This guide covers the configuration options for the LLM-based scanno detection system in Codexis.
Configuration Files
Main Configuration
config :codexis, :scanno_detection,
enabled: true,
default_model: "qwen3.0:8b",
math_model: "deepseek-r1:8b",
parallel_processing: true,
confidence_threshold: 0.7,
auto_accept_threshold: 0.9,
ollama_url: "http://localhost:11434",
cache_directory: "priv/scanno_cache",
max_corrections_per_file: 1000
Environment-Specific Configuration
config :codexis, :scanno_detection,
interactive: true,
verbose_logging: true,
save_intermediate_results: true
config :codexis, :scanno_detection,
enabled: false,
mock_llm: true,
config :codexis, :scanno_detection,
interactive: false,
auto_accept_threshold: 0.95,
model: "qwen2.5:14b"
Configuration Options
Core Settings
| Option |
Type |
Default |
Description |
enabled |
boolean |
true |
Enable/disable scanno detection |
default_model |
string |
"qwen3.0:8b" |
Default LLM model for text analysis |
math_model |
string |
"deepseek-r1:8b" |
Model for mathematical content |
parallel_processing |
boolean |
true |
Enable parallel processing of text blocks |
max_concurrency |
integer |
System.schedulers_online() |
Maximum concurrent operations |
Confidence Thresholds
| Option |
Type |
Default |
Description |
confidence_threshold |
float |
0.7 |
Minimum confidence to report correction |
auto_accept_threshold |
float |
0.9 |
Auto-accept corrections above this confidence |
interactive_threshold |
float |
0.7 |
Show corrections in interactive mode above this |
low_confidence_threshold |
float |
0.5 |
Threshold for low confidence corrections |
Processing Options
| Option |
Type |
Default |
Description |
batch_size |
integer |
100 |
Number of text blocks to process in batch |
chunk_size |
integer |
5000 |
Size of text chunks for processing |
max_corrections_per_file |
integer |
1000 |
Maximum corrections per file |
timeout |
integer |
30000 |
Timeout for LLM calls (ms) |
Caching
| Option |
Type |
Default |
Description |
cache_results |
boolean |
true |
Enable result caching |
cache_directory |
string |
"priv/scanno_cache" |
Directory for cache files |
cache_ttl |
integer |
86400 |
Cache TTL in seconds |
cache_max_size |
integer |
100_000_000 |
Maximum cache size in bytes |
UI and Review
| Option |
Type |
Default |
Description |
interactive |
boolean |
true |
Enable interactive review mode |
auto_accept_high_confidence |
boolean |
true |
Auto-accept high confidence corrections |
show_context_radius |
integer |
50 |
Characters of context to show |
batch_review_size |
integer |
5 |
Number of corrections in batch review |
Logging and Monitoring
| Option |
Type |
Default |
Description |
verbose_logging |
boolean |
false |
Enable verbose logging |
save_intermediate_results |
boolean |
false |
Save intermediate processing results |
metrics_enabled |
boolean |
true |
Enable metrics collection |
report_format |
string |
"html" |
Format for reports (html, json, csv) |
Model Configuration
Available Models
config :codexis, :scanno_models,
general: [
{"qwen2.5:3b", "Fast general text processing"},
{"qwen3.0:8b", "Balanced accuracy and speed"},
{"qwen2.5:14b", "High accuracy for complex text"}
],
mathematical: [
{"deepseek-r1:8b", "Mathematical reasoning"},
{"qwen2.5:14b", "Alternative math model"}
],
specialized: [
{"codellama:7b", "Code and technical content"},
{"llama3.1:8b", "General purpose alternative"}
]
Model Selection Strategy
defmodule Codexis.ModelSelector do
def select_model(content_type, opts \\ []) do
case content_type do
:text -> Keyword.get(opts, :general_model, "qwen3.0:8b")
:math -> Keyword.get(opts, :math_model, "deepseek-r1:8b")
:code -> Keyword.get(opts, :code_model, "codellama:7b")
:latex -> Keyword.get(opts, :latex_model, "qwen3.0:8b")
_ -> Keyword.get(opts, :default_model, "qwen3.0:8b")
end
end
end
Pattern Configuration
Custom Pattern Files
character_substitutions:
- pattern: '\brn'
replacement: 'm'
description: 'Common OCR error: rn→m'
- pattern: '\bcl'
replacement: 'd'
description: 'Common OCR error: cl→d'
word_errors:
- pattern: '\btlie\b'
replacement: 'the'
description: 'Common word error'
Loading Custom Patterns
config :codexis, :scanno_patterns,
pattern_files: [
"config/patterns/common_scannos.yml",
"config/patterns/domain_specific.yml"
],
auto_reload: true,
reload_interval: 300
Memory Configuration
config :codexis, :scanno_memory,
max_heap_size: 2_000_000,
max_binary_vheap_size: 1_000_000,
fullsweep_after: 20
Concurrency Tuning
schedulers = System.schedulers_online()
config :codexis, :scanno_concurrency,
max_llm_connections: min(4, schedulers),
max_file_processors: schedulers,
task_supervisor_max_children: schedulers * 2
CI/CD Configuration
config :codexis, :scanno_detection,
enabled: true,
interactive: false,
model: "qwen2.5:3b",
auto_accept_threshold: 0.98,
fail_on_low_confidence: true,
max_corrections_for_success: 50
Security Configuration
config :codexis, :scanno_security,
ollama_api_auth: false,
ollama_api_key: System.get_env("OLLAMA_API_KEY"),
allowed_models: [
"qwen2.5:3b",
"qwen3.0:8b",
"deepseek-r1:8b"
],
sanitize_prompts: true,
log_prompts: false
Advanced Configuration
Custom Prompt Templates
config :codexis, :scanno_prompts,
templates_dir: "priv/prompts",
custom_prompts: %{
general_text: "priv/prompts/general_scanno.txt",
mathematical: "priv/prompts/math_scanno.txt",
bibliography: "priv/prompts/bib_scanno.txt"
}
Plugin System
config :codexis, :scanno_plugins,
enabled: true,
plugin_dir: "priv/plugins",
active_plugins: [
Codexis.Plugins.CustomPatterns,
Codexis.Plugins.DomainSpecific,
Codexis.Plugins.LanguageDetection
]
Runtime Configuration
Environment Variables
export CODEXIS_SCANNO_MODEL="qwen2.5:14b"
export CODEXIS_SCANNO_INTERACTIVE="false"
export CODEXIS_SCANNO_CACHE_DIR="/tmp/scanno_cache"
export OLLAMA_HOST="http://gpu-server:11434"
Runtime Configuration Module
defmodule Codexis.RuntimeConfig do
def scanno_config do
%{
model: System.get_env("CODEXIS_SCANNO_MODEL", "qwen3.0:8b"),
interactive: System.get_env("CODEXIS_SCANNO_INTERACTIVE", "true") == "true",
cache_dir: System.get_env("CODEXIS_SCANNO_CACHE_DIR", "priv/scanno_cache")
}
end
end
Configuration Validation
defmodule Codexis.ConfigValidator do
def validate_scanno_config(config) do
with :ok <- validate_required_keys(config),
:ok <- validate_model_availability(config),
:ok <- validate_thresholds(config),
:ok <- validate_paths(config) do
{:ok, config}
end
end
defp validate_required_keys(config) do
required = [:enabled, :default_model, :confidence_threshold]
missing = Enum.filter(required, fn key ->
not Map.has_key?(config, key)
end)
if Enum.empty?(missing) do
:ok
else
{:error, "Missing required config keys: #{inspect(missing)}"}
end
end
defp validate_model_availability(config) do
:ok
end
defp validate_thresholds(config) do
if config.confidence_threshold <= config.auto_accept_threshold do
:ok
else
{:error, "confidence_threshold must be <= auto_accept_threshold"}
end
end
defp validate_paths(config) do
if File.dir?(config.cache_directory) do
:ok
else
{:error, "Cache directory does not exist: #{config.cache_directory}"}
end
end
end
Best Practices
- Start with defaults: Begin with default configuration and adjust as needed
- Model selection: Choose models based on accuracy vs. speed requirements
- Threshold tuning: Adjust confidence thresholds based on your content type
- Caching strategy: Enable caching for better performance
- Environment-specific: Use different configs for dev, test, and production
- Monitor performance: Track metrics to optimize settings
- Gradual rollout: Test new configurations on small datasets first
Configuration Examples
High-Accuracy Setup
config :codexis, :scanno_detection,
default_model: "qwen2.5:14b",
math_model: "deepseek-r1:8b",
confidence_threshold: 0.6,
auto_accept_threshold: 0.98,
parallel_processing: true,
max_concurrency: 2,
timeout: 60_000
Fast Processing Setup
config :codexis, :scanno_detection,
default_model: "qwen2.5:3b",
confidence_threshold: 0.8,
auto_accept_threshold: 0.95,
parallel_processing: true,
max_concurrency: System.schedulers_online(),
timeout: 15_000
Conservative Setup
config :codexis, :scanno_detection,
confidence_threshold: 0.85,
auto_accept_threshold: 0.99,
interactive: true,
auto_accept_high_confidence: false,
max_corrections_per_file: 100
Troubleshooting Configuration
Common Issues
-
Slow processing:
- Reduce
max_concurrency
- Use smaller models
- Increase
chunk_size
-
Too many false positives:
- Increase
confidence_threshold
- Adjust prompt templates
- Use domain-specific patterns
-
Memory issues:
- Reduce
batch_size
- Limit
max_concurrency
- Adjust memory settings
-
Cache problems:
- Clear cache directory
- Verify permissions
- Check disk space
Debug Configuration
config :codexis, :scanno_debug,
log_level: :debug,
save_all_prompts: true,
save_all_responses: true,
trace_execution: true,
benchmark_mode: true
Migration Guide
From Previous Versions
config :codexis,
scanno_model: "qwen3.0:8b",
scanno_threshold: 0.7
config :codexis, :scanno_detection,
default_model: "qwen3.0:8b",
confidence_threshold: 0.7
Migration Script
defmodule Codexis.ConfigMigration do
def migrate_config(old_config) do
%{
scanno_detection: %{
default_model: old_config[:scanno_model] || "qwen3.0:8b",
confidence_threshold: old_config[:scanno_threshold] || 0.7,
enabled: old_config[:scanno_enabled] || true
}
}
end
end
Configuration Schema
defmodule Codexis.ConfigSchema do
use Ecto.Schema
embedded_schema do
field :enabled, :boolean, default: true
field :default_model, :string, default: "qwen3.0:8b"
field :math_model, :string, default: "deepseek-r1:8b"
field :confidence_threshold, :float, default: 0.7
field :auto_accept_threshold, :float, default: 0.9
field :parallel_processing, :boolean, default: true
field :max_concurrency, :integer
field :cache_directory, :string
embeds_one :ui, UI do
field :interactive, :boolean, default: true
field :show_context_radius, :integer, default: 50
field :batch_review_size, :integer, default: 5
end
embeds_one :performance, Performance do
field :batch_size, :integer, default: 100
field :chunk_size, :integer, default: 5000
field :timeout, :integer, default: 30_000
end
end
def changeset(config, attrs) do
config
|> cast(attrs, [:enabled, :default_model, :confidence_threshold])
|> validate_required([:enabled, :default_model])
|> validate_number(:confidence_threshold, greater_than: 0, less_than_or_equal_to: 1)
end
end