Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
readme for llama.cpp sentencepiece changed.
innosetup script is added
  • Loading branch information
net-haus committed Nov 26, 2025
commit a198b5120d7873a1dceb49f0c77cb7224cd8187a
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,52 @@
# llama.cpp with sentencepiece

This fork aims to enhance llama.cpp by integrating the SentencePiece library as a tokenizer, enabling more flexible and language-agnostic tokenization for LLM inference. By using SentencePiece, this project supports advanced tokenization strategies, improves compatibility with a wider range of models, and simplifies workflows for users who require custom or multilingual tokenization. The scope of the fork includes adding a new tokenizer option, supporting SentencePiece model blobs, and implementing chat templates for specific models such as "Teuken 7B".

It introduces a new tokenizer named `sentencepiece` for the key `tokenizer.ggml.model`. In this case, the key `tokenizer.ggml.sentencepiece` must contain the binary blob with the SentencePiece model. Tokenization is performed by the SentencePiece library instead of the built-in algorithms in `llama.cpp`.

Additionally, this fork implements the chat template used by the LLM "Teuken 7B".

## Using llama.cpp with sentencepiece

### Setup for Windows

In the release section, you will find a setup for Windows containing `llama.cpp` with SentencePiece support and "Teuken 7B".
After install browser opens with the chat ui of `llama.cpp` and "Teuken 7B" as the llm.

### Installing from the source

First install sentencepiece static library with headers for your OS and compiler (see sentencepice documentation).

Clone the llama.cpp with sentencepiece repository:

```sh
git clone https://github.com/awenzel67/llama.cpp.git
cd llama.cpp
git switch teuken
```

Configure the build (see sentencepiece for details):
```sh
cmake -B buildFullCuda -DCURL_INCLUDE_DIR=C:/Del/vcpkg/installed/x64-windows/include -DCURL_LIBRARY=C:/Del/vcpkg/installed/x64-windows/lib/libcurl.lib -DSPIE_INCLUDE_DIR=C:\NHKI\llama\sentencepiece\src -DSPIE_LIBRARY=C:\NHKI\llama\sentencepiece\build\src\Release\sentencepiece.lib -DGGML_CUDA=ON
```

The cmake commands contains a variable to specify the include directory for sentencepiece library:
```sh
-DSPIE_INCLUDE_DIR=C:\NHKI\llama\sentencepiece\src
```

The cmake commands contains a variable to specify the path to the static sentencepiece library:
```sh
-DSPIE_LIBRARY=C:\NHKI\llama\sentencepiece\build\src\Release\sentencepiece.lib
```
Now you can use the common llama.cpp tools like llama-cli or llama-server.

You can use all models for llama.cpp. Additional the following Teuken 7B ggufs can be used:

- Teuken-7.5B-BF16-CM.gguf
- Teuken-7.5B-Q4_K_M.gguf


# llama.cpp

![llama](https://user-images.githubusercontent.com/1991296/230134379-7181e485-c521-4d23-a0d6-f7b3b61ba524.png)
Expand Down
77 changes: 77 additions & 0 deletions innosetup.iss
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
; Non-commercial use only

#define MyAppName "llama.cpp-teuken"
#define MyAppVersion "1.5"
#define MyAppPublisher "awenzel67"
#define MyAppURL "https://github.com/awenzel67/llama.cpp"
#define MyAppExeName "runteuken.bat"
#define MyAppAssocName MyAppName + " File"
#define MyAppAssocExt ".myp"
#define MyAppAssocKey StringChange(MyAppAssocName, " ", "") + MyAppAssocExt

[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{56F7611F-2A10-49B9-B3A8-B627CA731E2B}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
UninstallDisplayIcon={app}\{#MyAppExeName}
; "ArchitecturesAllowed=x64compatible" specifies that Setup cannot run
; on anything but x64 and Windows 11 on Arm.
ArchitecturesAllowed=x64compatible
; "ArchitecturesInstallIn64BitMode=x64compatible" requests that the
; install be done in "64-bit mode" on x64 or Windows 11 on Arm,
; meaning it should use the native 64-bit Program Files directory and
; the 64-bit view of the registry.
ArchitecturesInstallIn64BitMode=x64compatible
ChangesAssociations=yes
DisableProgramGroupPage=yes
; Uncomment the following line to run in non administrative install mode (install for current user only).
;PrivilegesRequired=lowest
OutputDir=C:\Del\tk
OutputBaseFilename=llama.cpp-teuken
;SolidCompression=yes
WizardStyle=modern dynamic
DiskSpanning=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "german"; MessagesFile: "compiler:Languages\German.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "C:\NHKI\mymodell\kilocal\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\NHKI\llama\llama.cpp\buildFullCuda\bin\Release\llama-server.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\NHKI\llama\llama.cpp\buildFullCuda\bin\Release\ggml.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\NHKI\llama\llama.cpp\buildFullCuda\bin\Release\ggml-base.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\NHKI\llama\llama.cpp\buildFullCuda\bin\Release\ggml-cpu.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\NHKI\llama\llama.cpp\buildFullCuda\bin\Release\ggml-cuda.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\NHKI\llama\llama.cpp\buildFullCuda\bin\Release\libcurl.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\NHKI\llama\llama.cpp\buildFullCuda\bin\Release\llama.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\NHKI\llama\llama.cpp\buildFullCuda\bin\Release\mtmd.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\NHKI\llama\llama.cpp\buildFullCuda\bin\Release\zlib1.dll"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\NHKI\mymodell\kilocal\Teuken-7.5B-Q4_K_M.gguf"; DestDir: "{app}"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Registry]
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocExt}\OpenWithProgids"; ValueType: string; ValueName: "{#MyAppAssocKey}"; ValueData: ""; Flags: uninsdeletevalue
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}"; ValueType: string; ValueName: ""; ValueData: "{#MyAppAssocName}"; Flags: uninsdeletekey
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0"
Root: HKA; Subkey: "Software\Classes\{#MyAppAssocKey}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}"" ""%1"""

[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

;[Run]
;Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: postinstall skipifsilent