> For the complete documentation index, see [llms.txt](https://docs.wproofreader.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wproofreader.com/v6.12.0/deployment/configuration/spell-check-engine/configure-n-gram-models.md).

# Configure n-gram models

N-gram models improve spell checking suggestion quality.

N-gram models use language-specific model files stored in the AppServer resources directory.

The default location is `<WebSpellChecker_installation_path>/AppServer/Resources/`. The actual path is controlled by `ResourcesDir` in `AppServerX.xml`. See [AppServer parameters](/v6.12.0/deployment/configuration/application-server/appserver-parameters.md).

N-gram models are configured via the `NgramPrioritization` tag in `AppServerX.xml`. It is nested under the Hunspell spell engine options for a CheckKit.

All supported n-gram models are enabled by default.

{% hint style="info" %}
Each n-gram model uses roughly the **same amount of RAM** as its **file size on disk**. Model sizes are listed in the table below.
{% endhint %}

### Installation

Model files are downloaded during installation.

After download, the installer places the models into the AppServer resources directory. The spell engine loads them from the path configured in `NgramPrioritization` (for example, `en/en_ngram_model.bin`).

If your server has no Internet access, see [Manually downloading resources (offline installation)](/v6.12.0/deployment/installation/manually-downloading-resources-offline-installation.md).

### Available n-gram models

| **Language** | **Supported language IDs**                     | **Model file**       | **Size** |
| ------------ | ---------------------------------------------- | -------------------- | -------- |
| English      | en\_US, en\_GB, en\_CA, en\_AU, en\_NZ, en\_ZA | `en_ngram_model.dat` | 80 MB    |
| German       | de\_DE, de\_CH, de\_AT                         | `de_ngram_model.dat` | 78 MB    |
| Spanish      | es\_ES                                         | `es_ngram_model.dat` | 100 MB   |

### Change n-gram settings (enable/disable)

1. Open `<WebSpellChecker_installation_path>/AppServer/AppServerX.xml`.
2. Find the `NgramPrioritization` tag for the language you need.
3. Change the `Enabled` attribute:
   * Set `Enabled="true"` to enable n-gram prioritization.
   * Set `Enabled="false"` to disable n-gram prioritization.

Example:

```xml
<NgramPrioritization Enabled="true" Path="en/en_ngram_model.bin"/>
```

4. Save the file.

Restart AppServer to apply changes in `AppServerX.xml`.

To restart: [stop](https://docs.wproofreader.com/v6.12.0/deployment/configuration/spell-check-engine/pages/IA2KNQLXDh85TwDivL4y#mainappservercommands-stopappserverwindowslinux2.stopappserver) the application, then [start](https://docs.wproofreader.com/v6.12.0/deployment/configuration/spell-check-engine/pages/IA2KNQLXDh85TwDivL4y#mainappservercommands-startappserverwindowslinux1.startappserver) it again.

Use [Main AppServer commands](/v6.12.0/deployment/configuration/application-server/main-appserver-commands.md).

### Error: failed to load n-gram model

If n-gram prioritization is enabled but the model file is missing, AppServer logs an error. Example:

```
04/03/26:16:27:16.510	#21452:0	Subsystem_General	Error	Failed to load n-gram model: 'en/en_ngram_model.dat'. Reason: File doesn't exist.
```

{% hint style="warning" %}
This error usually means the model file is missing in the AppServer resources directory.

If the installation was done without downloading resources, re-run the installation with internet connection, or use the offline download procedure.
{% endhint %}
