Skip to content

Commit 0808979

Browse files
committed
Change multimodal projector type to BF16 and F32
1 parent 2e3b07b commit 0808979

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

quantize_weights_for_llama.cpp.ps1

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,32 +52,36 @@ ForEach ($repositoryName in $repositoryDirectories) {
5252
$unquantizedModelPath = $unquantizedModelPathFromSource
5353
}
5454

55-
ForEach ($type in $quantizationTypes) {
55+
# We are computing a multimodal projector model in BF16 format
56+
# for current hardware and F32 format as a fallback for older
57+
# hardware for each model to enable vision capabilities.
58+
ForEach ($multimodalProjectorType in @('BF16', 'F32')) {
5659

57-
$quantizedModelPath = Join-Path -Path $targetDirectoryPath -ChildPath "${repositoryName}.${type}.gguf"
60+
$multimodalProjectorPath = Join-Path -Path $targetDirectoryPath -ChildPath "${repositoryName}.mmproj.${multimodalProjectorType}.gguf"
5861

59-
if (!(Test-Path -Path $quantizedModelPath) -and !(Test-Path -Path $unquantizedModelPath)) {
62+
if (!(Test-Path -Path $multimodalProjectorPath)) {
6063

61-
Write-Host "Converting ${sourceDirectoryPath} to ${unquantizedModelPath}..." -ForegroundColor "DarkYellow"
64+
Write-Host "Creating multimodal projector model from ${unquantizedModelPath} to ${multimodalProjectorPath}..." -ForegroundColor "DarkYellow"
6265

6366
Invoke-Expression "python ${llamaCppDirectory}\convert_hf_to_gguf.py ``
64-
--outfile '${unquantizedModelPath}' ``
65-
'${sourceDirectoryPath}'"
67+
--outfile '${multimodalProjectorPath}' ``
68+
--outtype '${multimodalProjectorType}'.ToLower() ``
69+
'${sourceDirectoryPath}' ``
70+
--mmproj"
6671
}
72+
}
6773

68-
$multimodalProjectorPath = Join-Path -Path $targetDirectoryPath -ChildPath "${repositoryName}.mmproj.F16.gguf"
74+
ForEach ($type in $quantizationTypes) {
6975

70-
# We are computing a multimodal projector model in F16
71-
# format for each model to enable vision capabilities.
72-
if (!(Test-Path -Path $multimodalProjectorPath)) {
76+
$quantizedModelPath = Join-Path -Path $targetDirectoryPath -ChildPath "${repositoryName}.${type}.gguf"
7377

74-
Write-Host "Creating multimodal projector model from ${unquantizedModelPath} to ${multimodalProjectorPath}..." -ForegroundColor "DarkYellow"
78+
if (!(Test-Path -Path $quantizedModelPath) -and !(Test-Path -Path $unquantizedModelPath)) {
79+
80+
Write-Host "Converting ${sourceDirectoryPath} to ${unquantizedModelPath}..." -ForegroundColor "DarkYellow"
7581

7682
Invoke-Expression "python ${llamaCppDirectory}\convert_hf_to_gguf.py ``
77-
--outfile '${multimodalProjectorPath}' ``
78-
--outtype 'f16' ``
79-
'${sourceDirectoryPath}' ``
80-
--mmproj"
83+
--outfile '${unquantizedModelPath}' ``
84+
'${sourceDirectoryPath}'"
8185
}
8286

8387
# We are computing an importance matrix to enhance the quality of the models.

0 commit comments

Comments
 (0)