mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2026-02-20 14:44:58 +01:00
280 lines
19 KiB
Python
280 lines
19 KiB
Python
from modules import shared
|
||
|
||
LANG_CHOICES = [
|
||
("en", "English"),
|
||
("zh_TW", "繁體中文"),
|
||
]
|
||
|
||
_ZH_TW = {
|
||
"Text Generation Web UI": "文字生成 Web UI",
|
||
"Chat": "聊天",
|
||
"Notebook": "筆記本",
|
||
"Parameters": "參數",
|
||
"Character": "角色",
|
||
"Model": "模型",
|
||
"Image generation": "圖像生成",
|
||
"Training": "訓練",
|
||
"Session": "工作階段",
|
||
"Settings": "設定",
|
||
"Extensions & flags": "擴充與旗標",
|
||
"Available extensions": "可用擴充",
|
||
"Boolean command-line flags": "布林命令列旗標",
|
||
"Toggle light/dark theme 💡": "切換亮/暗主題 💡",
|
||
"Show two columns in the Notebook tab": "Notebook 分頁顯示雙欄",
|
||
"Turn long pasted text into attachments in the Chat tab": "在聊天分頁將長貼上文字轉為附件",
|
||
"Include attachments/search results from previous messages in the chat prompt": "聊天提示包含前訊息的附件/搜尋結果",
|
||
"Save extensions settings to user_data/settings.yaml": "儲存擴充設定到 user_data/settings.yaml",
|
||
"Apply flags/extensions and restart": "套用旗標/擴充並重新啟動",
|
||
"Language": "語言",
|
||
"Input": "輸入",
|
||
"Output": "輸出",
|
||
"Continue": "繼續",
|
||
"Stop": "停止",
|
||
"Generate": "生成",
|
||
"Prompt": "提示",
|
||
"New": "新增",
|
||
"Rename": "重新命名",
|
||
"Delete": "刪除",
|
||
"Confirm": "確認",
|
||
"Cancel": "取消",
|
||
"Raw": "原始",
|
||
"Markdown": "Markdown",
|
||
"HTML": "HTML",
|
||
"Logits": "Logits",
|
||
"Tokens": "詞元",
|
||
"Get next token probabilities": "取得下一個詞元機率",
|
||
"Use samplers": "使用採樣器",
|
||
"Previous output": "前一次輸出",
|
||
"Get token IDs for the input": "取得輸入的詞元 ID",
|
||
"Render": "渲染",
|
||
"<|character|> and <|prompt|> get replaced with the bot name and the regular chat prompt respectively.": "<|character|> 與 <|prompt|> 會分別替換為機器人名稱與一般聊天提示。",
|
||
"dynatemp_low": "dynatemp_low 低溫",
|
||
"dynatemp_high": "dynatemp_high 高溫",
|
||
"dynatemp_exponent": "dynatemp_exponent 指數",
|
||
"dynamic_temperature": "dynamic_temperature 動態溫度",
|
||
"mirostat_tau": "mirostat_tau 目標熵",
|
||
"mirostat_eta": "mirostat_eta 學習率",
|
||
"Ban the eos_token": "Ban the eos_token 禁用結束詞元",
|
||
"threads": "threads 執行緒數",
|
||
"threads_batch": "threads_batch 每批執行緒",
|
||
"batch_size": "batch_size 批次大小",
|
||
"ubatch_size": "ubatch_size 微批次大小",
|
||
"extra-flags": "extra-flags 額外旗標",
|
||
"rope_freq_base": "rope_freq_base 頻率基準",
|
||
"mlock": "mlock 鎖定記憶體",
|
||
"numa": "numa NUMA",
|
||
"Send a message": "送出訊息",
|
||
"Send": "送出",
|
||
"no_kv_offload": "no_kv_offload 不卸載 K/V",
|
||
"Please enter a model path.": "請輸入模型路徑。",
|
||
"Undo": "復原",
|
||
"Regenerate": "重新生成",
|
||
"Generation": "生成",
|
||
"Preset": "預設",
|
||
"Restore preset": "還原預設",
|
||
"Neutralize samplers": "重置採樣器",
|
||
"Filter by loader": "依載入器篩選",
|
||
"## Curve shape": "## 曲線形狀",
|
||
"## Curve cutoff": "## 曲線截斷",
|
||
"## Repetition suppression": "## 重複抑制",
|
||
"## Alternative sampling methods": "## 替代採樣方法",
|
||
"## Other options": "## 其他選項",
|
||
"Truncate the prompt up to this length": "將提示截斷至此長度",
|
||
"Seed (-1 for random)": "隨機種子(-1 為隨機)",
|
||
"Custom system message": "自訂系統訊息",
|
||
"If not empty, will be used instead of the default one.": "若不為空,將取代預設內容。",
|
||
"Custom stopping strings": "自訂停止字串",
|
||
"Token bans": "禁用詞元",
|
||
"Negative prompt": "負面提示",
|
||
"Load grammar from file (.gbnf)": "從檔案載入文法(.gbnf)",
|
||
"Grammar": "文法",
|
||
"temperature": "temperature 溫度",
|
||
"Instruction template": "指令模板",
|
||
"Saved instruction templates": "已儲存的指令模板",
|
||
"Load": "載入",
|
||
"Send to notebook": "發送到筆記本",
|
||
"Send to Notebook": "發送到筆記本",
|
||
"Chat template": "聊天模板",
|
||
# duplicate key removed; keep single mapping for "Send"
|
||
"Regenerate (Ctrl + Enter)": "重新生成(Ctrl + Enter)",
|
||
"Continue (Alt + Enter)": "繼續(Alt + Enter)",
|
||
"Remove last reply (Ctrl + Shift + Backspace)": "移除上一則回覆(Ctrl + Shift + Backspace)",
|
||
"Impersonate (Ctrl + Shift + M)": "扮演(Ctrl + Shift + M)",
|
||
"Send dummy message": "送出範例訊息",
|
||
"Send dummy reply": "送出範例回覆",
|
||
"Show controls (Ctrl+S)": "顯示控制列(Ctrl+S)",
|
||
"Start reply with": "以此開頭回覆",
|
||
"Reasoning effort": "推理強度",
|
||
"Enable thinking": "啟用思考",
|
||
"Activate web search": "啟用網頁搜尋",
|
||
"Number of pages to download": "下載頁數",
|
||
"Mode": "模式",
|
||
"Chat style": "聊天風格",
|
||
"Command for chat-instruct mode": "chat-instruct 模式指令",
|
||
"Count tokens": "計算詞元數",
|
||
"New chat": "新聊天",
|
||
"Branch": "分支",
|
||
"Search chats...": "搜尋聊天…",
|
||
"Rename to:": "重新命名為:",
|
||
"New name": "新名稱",
|
||
"Restore character": "還原角色",
|
||
"Character's name": "角色名稱",
|
||
"Context": "情境",
|
||
"Greeting": "問候語",
|
||
"User": "使用者",
|
||
"Name": "名稱",
|
||
"Description": "描述",
|
||
"Here you can optionally write a description of yourself.": "此處可選擇性撰寫自我描述。",
|
||
"Chat history": "聊天記錄",
|
||
"Save history": "儲存記錄",
|
||
"Upload History JSON": "上傳記錄 JSON",
|
||
"Upload character": "上傳角色",
|
||
"YAML or JSON": "YAML 或 JSON",
|
||
"JSON or YAML File": "JSON 或 YAML 檔",
|
||
"Profile Picture (optional)": "大頭貼(可選)",
|
||
"Submit": "送出",
|
||
"TavernAI PNG File": "TavernAI PNG 檔",
|
||
"Character picture": "角色圖片",
|
||
"Your picture": "你的圖片",
|
||
"Save settings": "儲存設定",
|
||
"Unload": "卸載",
|
||
"Model loader": "模型載入器",
|
||
"## Main options": "## 主要選項",
|
||
"See more options": "查看更多選項",
|
||
"Multimodal (vision)": "多模態(視覺)",
|
||
"mmproj file": "mmproj 檔案",
|
||
"Speculative decoding": "投機解碼",
|
||
"gpu-layers": "GPU 層數",
|
||
"ctx-size": "上下文長度",
|
||
"cache-type": "快取類型",
|
||
"cpu-moe": "將專家移至 CPU(cpu-moe)",
|
||
"streaming-llm": "啟用 StreamingLLM",
|
||
"Download": "下載",
|
||
"Download model or LoRA": "下載模型或 LoRA",
|
||
"Get file list": "取得檔案清單",
|
||
"Customize instruction template": "自訂指令模板",
|
||
"Select the desired instruction template": "選擇想要的指令模板",
|
||
"No model is loaded": "尚未載入模型",
|
||
"Ready": "就緒",
|
||
"File name (for GGUF models)": "檔名(適用 GGUF 模型)",
|
||
"This allows you to set a customized template for the model currently selected in the \"Model loader\" menu. Whenever the model gets loaded, this template will be used in place of the template specified in the model's medatada, which sometimes is wrong.": "這可為「模型載入器」中目前選取的模型設定自訂模板。之後每次載入該模型時,都會使用此模板,取代模型中標註的模板(有時會標註錯誤)。",
|
||
"Enter the Hugging Face username/model path, for instance: facebook/galactica-125m. To specify a branch, add it at the end after a \":\" character like this: facebook/galactica-125m:main. To download a single file, enter its name in the second box.": "輸入 Hugging Face 的使用者/模型路徑,例如:facebook/galactica-125m。若要指定分支,請在最後加上冒號,例如:facebook/galactica-125m:main。若只下載單一檔案,請在第二個輸入框填入檔名。",
|
||
"Used by GPT-OSS.": "供 GPT-OSS 使用。",
|
||
"Used by Seed-OSS and pre-2507 Qwen3.": "供 Seed-OSS 與 2507 之前的 Qwen3 使用。",
|
||
"In instruct and chat-instruct modes, the template under Parameters > Instruction template is used.": "在 instruct 與 chat-instruct 模式下,會使用「參數 > 指令模板」中的模板。",
|
||
"After selecting the template, click on \"Load\" to load and apply it.": "選擇模板後,點擊「載入」以套用。",
|
||
"This gets autodetected; you usually don't need to change it. Used in instruct and chat-instruct modes.": "此值通常會自動偵測,通常不需更改。用於 instruct 與 chat-instruct 模式。",
|
||
"Defines how the chat prompt in chat/chat-instruct modes is generated.": "定義 chat 或 chat-instruct 模式下聊天提示的生成方式。",
|
||
"Must be greater than 0 for the GPU to be used. ⚠️ Lower this value if you can't load the model.": "必須大於 0 才會使用 GPU。⚠️ 如果無法載入模型,請降低此值。",
|
||
"Context length. Common values: 4096, 8192, 16384, 32768, 65536, 131072.": "上下文長度。常見值:4096、8192、16384、32768、65536、131072。",
|
||
"Comma-separated list of VRAM (in GB) to use per GPU. Example: 20,7,7": "每張 GPU 使用的 VRAM(GB)以逗號分隔。範例:20,7,7",
|
||
"Attention implementation.": "注意力實作。",
|
||
"Valid options: llama.cpp - fp16, q8_0, q4_0; ExLlamaV2 - fp16, fp8, q8, q6, q4; ExLlamaV3 - fp16, q2 to q8. For ExLlamaV3, you can type custom combinations for separate k/v bits (e.g. q4_q8).": "有效選項:llama.cpp - fp16、q8_0、q4_0;ExLlamaV2 - fp16、fp8、q8、q6、q4;ExLlamaV3 - fp16、q2 到 q8。對 ExLlamaV3,可為 k/v 分別輸入自訂組合(例如 q4_q8)。",
|
||
"The backend for tensor parallelism.": "張量並行的後端。",
|
||
"Move the experts to the CPU. Saves VRAM on MoE models.": "將 experts 移至 CPU,可在 MoE 模型節省 VRAM。",
|
||
"Activate StreamingLLM to avoid re-evaluating the entire prompt when old messages are removed.": "啟用 StreamingLLM,移除舊訊息時免重新評估整個提示。",
|
||
"Used by load-in-4bit.": "供 load-in-4bit 使用。",
|
||
"Automatically split the model tensors across the available GPUs.": "自動將模型張量分散至可用 GPU。",
|
||
"Enable tensor parallelism (TP).": "啟用張量並行(TP)。",
|
||
"Enable inference with ModelRunnerCpp, which is faster than the default ModelRunner.": "使用 ModelRunnerCpp 進行推論,通常比預設 ModelRunner 更快。",
|
||
"Select a file that matches your model. Must be placed in user_data/mmproj/": "選擇與模型相容的檔案,需放在 user_data/mmproj/。",
|
||
"Draft model. Speculative decoding only works with models sharing the same vocabulary (e.g., same model family).": "草稿模型。投機解碼僅適用於共享相同詞彙表的模型(例如相同家族)。",
|
||
"Number of layers to offload to the GPU for the draft model.": "草稿模型要卸載到 GPU 的層數。",
|
||
"Number of tokens to draft for speculative decoding. Recommended value: 4.": "投機解碼的草稿詞元數。建議值:4。",
|
||
"Comma-separated list of devices to use for offloading the draft model. Example: CUDA0,CUDA1": "卸載草稿模型的裝置列表(以逗號分隔)。範例:CUDA0,CUDA1",
|
||
"Size of the prompt context for the draft model. If 0, uses the same as the main model.": "草稿模型的提示上下文大小。若為 0,則與主模型相同。",
|
||
"* TensorRT-LLM has to be installed manually in a separate Python 3.10 environment at the moment. For a guide, consult the description of [this PR](https://github.com/oobabooga/text-generation-webui/pull/5715). \n\n* `ctx_size` is only used when `cpp-runner` is checked.\n\n* `cpp_runner` does not support streaming at the moment.": "* 目前需要在獨立的 Python 3.10 環境手動安裝 TensorRT-LLM。安裝指南請參考此 PR 的說明。\n\n* 僅在勾選 `cpp-runner` 時使用 `ctx_size`。\n\n* 目前 `cpp_runner` 不支援串流輸出。",
|
||
"Use PyTorch in CPU mode.": "以 CPU 模式使用 PyTorch。",
|
||
"Split the model by rows across GPUs. This may improve multi-gpu performance.": "將模型依列在多張 GPU 上切分,可能改善多 GPU 效能。",
|
||
"Do not offload the K, Q, V to the GPU. This saves VRAM but reduces the performance.": "不要將 K、Q、V 卸載至 GPU,可節省 VRAM,但會降低效能。",
|
||
"NUMA support can help on some systems with non-uniform memory access.": "在非一致性記憶體架構(NUMA)的系統上,啟用可改善效能。",
|
||
"Necessary to use CFG with this loader.": "使用此載入器啟用 CFG 時所必需。",
|
||
"Set use_fast=False while loading the tokenizer.": "在載入 tokenizer 時設定 use_fast=False。",
|
||
"Activates Quadratic Sampling.": "啟用二次取樣(Quadratic Sampling)。",
|
||
"Adjusts the dropoff curve of Quadratic Sampling.": "調整二次取樣的衰減曲線。",
|
||
"Probability that the removal will actually happen. 0 disables the sampler. 1 makes it always happen.": "實際執行移除的機率。0 代表停用此採樣器,1 代表必定執行。",
|
||
"For Contrastive Search. do_sample must be unchecked.": "用於對比式搜尋(Contrastive Search)。需取消勾選 do_sample。",
|
||
"For CFG. 1.5 is a good value.": "用於 CFG。建議值:1.5。",
|
||
"Parameter names separated by new lines or commas.": "以換行或逗號分隔參數名稱。",
|
||
"Tokens across which sequence matching is not continued. Specified as a comma-separated list of quoted strings.": "不進行序列比對延續的斷點詞元,以加引號的字串並以逗號分隔。",
|
||
"Activates Prompt Lookup Decoding.": "啟用提示查找解碼(Prompt Lookup Decoding)。",
|
||
"Expand max_new_tokens to the available context length.": "將 max_new_tokens 擴展至可用的上下文長度。",
|
||
"Forces the model to never end the generation prematurely.": "強制模型不要過早結束生成。",
|
||
"Only applies to text completion (notebook). In chat mode, templates control BOS tokens.": "僅適用於文字補全(Notebook)。聊天模式由模板控制 BOS。",
|
||
"Some specific models need this unset.": "部分模型需要取消此選項。",
|
||
"Activate text streaming": "啟用文字串流",
|
||
"Static KV cache": "靜態 KV 快取",
|
||
"Use a static cache for improved performance.": "使用靜態快取以提升效能。",
|
||
"List of proportions to split the model across multiple GPUs. Example: 60,40": "模型在多張 GPU 間的比例設定。範例:60,40",
|
||
"tensor_split": "張量切分比例",
|
||
"auto_max_new_tokens": "自動調整最大新詞元數",
|
||
"Add the bos_token to the beginning of prompts": "在提示開頭加入 BOS 詞元",
|
||
"Additional flags to pass to llama-server. Format: \"flag1=value1,flag2,flag3=value3\". Example: \"override-tensor=exps=CPU\"": "傳遞給 llama-server 的額外旗標。格式:「flag1=value1,flag2,flag3=value3」。範例:「override-tensor=exps=CPU」。",
|
||
"Maximum CPU memory in GiB. Use this for CPU offloading.": "最大 CPU 記憶體(GiB)。用於 CPU 卸載。",
|
||
"Positional embeddings alpha factor for NTK RoPE scaling. Recommended values (NTKv1): 1.75 for 1.5x context, 2.5 for 2x context. Use either this or compress_pos_emb, not both.": "NTK RoPE 縮放用的位置嵌入 alpha 因子。建議值(NTKv1):1.75 對應 1.5x 上下文、2.5 對應 2x 上下文。與 compress_pos_emb 擇一使用。",
|
||
"Positional embeddings frequency base for NTK RoPE scaling. Related to alpha_value by rope_freq_base = 10000 * alpha_value ^ (64 / 63). 0 = from model.": "NTK RoPE 縮放用的位置嵌入頻率基準。與 alpha_value 的關係:rope_freq_base = 10000 * alpha_value ^ (64 / 63)。0 表示使用模型內建值。",
|
||
"Positional embeddings compression factor. Should be set to (context length) / (model's original context length). Equal to 1/rope_freq_scale.": "位置嵌入壓縮係數。應設為(新上下文長度)/(模型原始上下文長度)。等同 1/rope_freq_scale。",
|
||
"compress_pos_emb": "位置嵌入壓縮係數",
|
||
"row_split": "列切分(row_split)",
|
||
"no-mmap": "停用 mmap(no-mmap)",
|
||
"Only applies to MoE models like Mixtral.": "僅適用於 Mixtral 等 MoE 模型。",
|
||
"Estimated VRAM to load the model:": "載入模型的預估 VRAM:",
|
||
"mirostat_mode": "mirostat 模式",
|
||
"mode=1 is for llama.cpp only.": "mode=1 只適用於 llama.cpp。",
|
||
"Note that some of these extensions may require manually installing Python requirements through the command: pip install -r extensions/extension_name/requirements.txt": "部分擴充可能需要手動安裝 Python 相依套件:pip install -r extensions/extension_name/requirements.txt",
|
||
"Used in chat and chat-instruct modes.": "用於 chat 與 chat-instruct 模式。",
|
||
"max_new_tokens": "最大新詞元數",
|
||
"⚠️ Setting this too high can cause prompt truncation.": "⚠️ 設定過高可能導致提示被截斷。",
|
||
"The leftmost tokens are removed if the prompt exceeds this length.": "若提示超過此長度,會移除最左側的詞元。",
|
||
"Sampler priority": "採樣器優先順序",
|
||
"Maximum tokens/second": "每秒最大詞元數",
|
||
"To make text readable in real time.": "讓文字即時可讀。",
|
||
"min_p": "min_p 最小機率",
|
||
"xtc_threshold": "xtc_threshold XTC 臨界值",
|
||
"xtc_probability": "xtc_probability XTC 機率",
|
||
"dry_base": "dry 基數",
|
||
"dry_allowed_length": "dry 允許重複長度",
|
||
"dry_sequence_breakers": "dry_sequence_breakers 斷序詞元",
|
||
"repetition_penalty": "repetition_penalty 重複懲罰",
|
||
"frequency_penalty": "frequency_penalty 頻率懲罰",
|
||
"presence_penalty": "presence_penalty 出現懲罰",
|
||
"repetition_penalty_range": "repetition_penalty_range 重複懲罰範圍",
|
||
"temperature_last": "temperature_last 溫度後置",
|
||
"If 2 or more tokens have probability above this threshold, consider removing all but the last one.": "若有 2 個以上詞元的機率高於此門檻,考慮只保留最後一個。",
|
||
"Set to greater than 0 to enable DRY. Recommended value: 0.8.": "設為大於 0 以啟用 DRY。建議值:0.8。",
|
||
"Longest sequence that can be repeated without being penalized.": "不受懲罰可重複的最長序列長度。",
|
||
"Controls how fast the penalty grows with increasing sequence length.": "控制懲罰隨序列長度增加的成長速度。",
|
||
"Moves temperature/dynamic temperature/quadratic sampling to the end of the sampler stack, ignoring their positions in \"Sampler priority\".": "將溫度/動態溫度/二次取樣移至採樣器堆疊末端,忽略其在「採樣器優先順序」中的位置。",
|
||
"top_n_sigma": "top_n_sigma Top-N 標準差",
|
||
"top_p": "top_p Top-p",
|
||
"top_k": "top_k Top-k",
|
||
"typical_p": "typical_p Typical-p",
|
||
"dry_multiplier": "dry 乘數",
|
||
# duplicate key removed; keep prefixed form above
|
||
"Good morning!": "早安!",
|
||
"Good afternoon!": "午安!",
|
||
"Good evening!": "晚安!",
|
||
"How can I help you today?": "今天我可以怎麼幫你?",
|
||
}
|
||
|
||
_MAP = {
|
||
"zh_TW": _ZH_TW,
|
||
}
|
||
|
||
|
||
def lang():
|
||
v = shared.settings.get("language", "en")
|
||
# Normalize legacy or mislabeled values
|
||
if v in ("English", "en_US", "en-GB"):
|
||
return "en"
|
||
if v in ("zh_TW", "zh-TW", "繁體中文"):
|
||
return "zh_TW"
|
||
return v
|
||
|
||
|
||
def t(s: str) -> str:
|
||
d = _MAP.get(lang())
|
||
if not d:
|
||
return s
|
||
return d.get(s, s)
|