From 9dfa69c7e58730a13082dae35a2e5086aade0150 Mon Sep 17 00:00:00 2001 From: fanlusky <1730976608@qq.com> Date: Thu, 24 Sep 2026 14:03:43 +0800 Subject: [PATCH] =?UTF-8?q?build(installer):=20=E6=89=93=E5=8C=85=E7=A5=9E?= =?UTF-8?q?=E7=BB=8F=E6=95=B4=E5=8F=A5=E6=A8=A1=E5=9E=8B=E5=B9=B6=E5=9C=A8?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E6=B5=81=E7=A8=8B=E4=B8=AD=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prepare-PackageFiles 断言并拷贝两个模型与授权声明;release workflow 在收集产物前 运行 fetch-neural-model.ps1。 --- .github/workflows/release.yml | 7 +++++++ installer/Prepare-PackageFiles.ps1 | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cfb45c44..ca5e8a75 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -478,6 +478,13 @@ jobs: shell: pwsh run: ./scripts/build-language-model.ps1 + # The neural sentence models are downloaded from the chinese-ime-lm release pinned in + # neural-model/lock.json and checked against the SHA256 recorded there. Prepare-PackageFiles.ps1 + # asserts they exist, so this has to run before the payload is collected. + - name: Download the neural sentence models + shell: pwsh + run: ./scripts/fetch-neural-model.ps1 + - name: Decide the signing mode id: signing shell: pwsh diff --git a/installer/Prepare-PackageFiles.ps1 b/installer/Prepare-PackageFiles.ps1 index 459edc7e..66a36106 100644 --- a/installer/Prepare-PackageFiles.ps1 +++ b/installer/Prepare-PackageFiles.ps1 @@ -16,6 +16,9 @@ param( # 词格打分用的语言模型不随词库发布下发,而是由 scripts/build-language-model.ps1 # 从钉住的上游语料现场转换到这个目录。 [string]$LanguageModelDirectory = 'language-model', + # 神经整句模型(chinese-ime-lm 的 safetensors)从这个目录下发,与 sc.lm 同为资源根下的 + # 只读文件。缺文件时引擎静默不出神经整句,但打包仍然必须带上,故这里断言存在。 + [string]$NeuralModelDirectory = 'neural-model', # THIRD_PARTY_NOTICES.txt used to sit next to the tip's sources. In the consolidated repository # the notice covers the whole product and lives at the root, one level above windows/, so where # to read it is no longer answered by where the tip is. @@ -76,6 +79,9 @@ $englishDb = Join-Path $RepoRoot (Join-Path $DictionaryDirectory 'out\english.db $othersDb = Join-Path $RepoRoot (Join-Path $DictionaryDirectory 'out\others.db') $languageModel = Join-Path $RepoRoot (Join-Path $LanguageModelDirectory 'sc.lm') $languageModelNotice = Join-Path $RepoRoot (Join-Path $LanguageModelDirectory 'NOTICE.md') +$neuralModelDesktop = Join-Path $RepoRoot (Join-Path $NeuralModelDirectory 'sentence-model-desktop.safetensors') +$neuralModelKeyboard = Join-Path $RepoRoot (Join-Path $NeuralModelDirectory 'sentence-model.safetensors') +$neuralModelNotice = Join-Path $RepoRoot (Join-Path $NeuralModelDirectory 'NOTICE.md') Assert-PathExists -LiteralPath $RepoRoot -Description '源码仓库根目录' Assert-PathExists -LiteralPath $serverRelease -Description 'Server Release 输出目录' @@ -134,6 +140,9 @@ if 'weight' not in names or pk != ['word', 'display']: Assert-PathExists -LiteralPath $languageModel ` -Description '词格整句语言模型 sc.lm(用 scripts\build-language-model.ps1 生成)' Assert-PathExists -LiteralPath $languageModelNotice -Description 'libime 语言模型授权声明 NOTICE.md' + Assert-PathExists -LiteralPath $neuralModelDesktop -Description '神经整句模型 sentence-model-desktop.safetensors' + Assert-PathExists -LiteralPath $neuralModelKeyboard -Description '神经整句模型 sentence-model.safetensors' + Assert-PathExists -LiteralPath $neuralModelNotice -Description 'chinese-ime-lm 授权声明 NOTICE.md' } $targetAppData = Join-Path $PSScriptRoot 'app_data' @@ -169,6 +178,12 @@ else { # 模型数据是 LGPL-2.1-or-later 的第三方作品,声明必须跟着二进制到用户磁盘上, # 理由同下面 rime-ice 那段。 Copy-Item -LiteralPath $languageModelNotice -Destination (Join-Path $targetAppData 'libime-lm-NOTICE.md') -Force + # 神经整句模型与 sc.lm 一样落在资源目录根下,文件名由 engine/contracts/assets 清单声明。 + # 缺文件时引擎静默不出神经整句候选(shared_sentence_model 返回 nullptr),不影响其它候选。 + Copy-Item -LiteralPath $neuralModelDesktop -Destination (Join-Path $targetAppData 'sentence-model-desktop.safetensors') -Force + Copy-Item -LiteralPath $neuralModelKeyboard -Destination (Join-Path $targetAppData 'sentence-model.safetensors') -Force + # 权重是 Apache-2.0 的第三方作品,授权声明必须随二进制到用户磁盘上。 + Copy-Item -LiteralPath $neuralModelNotice -Destination (Join-Path $targetAppData 'chinese-ime-lm-NOTICE.md') -Force $defaultConfigPath = Join-Path $targetAppData 'config.default.toml' # 出厂配置来自本仓库的 default_config,不依赖本机是否已安装输入法。