語言模型
8 個節點
本頁內容 8
提問
函數Asks a chat model one question and answers with its reply: a one-message conversation, rendered through the model's chat template.
提問 -> 文字
模型: Language Model
問題: 文字
系統提示: 文字
設定: Generation Settingsstring Ask(
LanguageModel model,
string question,
string system,
GenerationSettings settings)參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 模型 | Language Model | — | A model that can chat (one with a chat template, usually named Instruct or Chat). |
| 問題 | 文字 | — | What to ask. |
| 系統提示 | 文字 | — | What the model is told about its part first; empty for none. |
| 設定 | Generation Settings | — | How it chooses its words; empty for the model's own defaults. |
返回
| 回覆 | 文字 |
- 所屬發行版
- 元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 語言模型
- 所屬包
- 機器學習
對話
函數Says a message in a conversation and answers with the model's reply, and the conversation with both added, to continue from.
對話 -> (回覆: 文字, 續接的對話: Conversation)
模型: Language Model
訊息: 文字
對話: Conversation
設定: Generation Settingsstring Chat(
LanguageModel model,
string message,
Conversation conversation,
GenerationSettings settings,
out Conversation continued)參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 模型 | Language Model | — | A model that can chat. |
| 訊息 | 文字 | — | What the user says. |
| 對話 | Conversation | — | The conversation so far, from Start Conversation or an earlier Chat; empty to start one. |
| 設定 | Generation Settings | — | How it chooses its words; empty for the model's own defaults. |
返回
| 回覆 | 文字 |
| 續接的對話 | Conversation |
- 所屬發行版
- 元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 語言模型
- 所屬包
- 機器學習
繼續對話
函數The model's next reply to a conversation that ends with the user's message.
繼續對話 -> 文字
模型: Language Model
對話: Conversation
設定: Generation Settingsstring ContinueConversation(
LanguageModel model,
Conversation conversation,
GenerationSettings settings)參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 模型 | Language Model | — | A model that can chat. |
| 對話 | Conversation | — | The conversation, ending with what the user said. |
| 設定 | Generation Settings | — | How it chooses its words; empty for the model's own defaults. |
返回
| 回覆 | 文字 |
- 所屬發行版
- 元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 語言模型
- 所屬包
- 機器學習
計算詞元數
函數How many tokens a text is to a model, which is what its length limits and Generation Settings count.
計算詞元數(模型: Language Model, 文字: 文字) -> 整數
int CountTokens(LanguageModel model, string text)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 模型 | Language Model | — | The model whose tokenizer counts. |
| 文字 | 文字 | — | The text. |
返回
| 詞元數 | 整數 |
- 所屬發行版
- 元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 語言模型
- 所屬包
- 機器學習
生成文字
函數Continues a text as the model would write it, without a chat template: the model's continuation alone, not the prompt.
生成文字 -> 文字
模型: Language Model
提示詞: 文字
設定: Generation Settingsstring GenerateText(
LanguageModel model,
string prompt,
GenerationSettings settings)參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 模型 | Language Model | — | Any language model, base or chat. |
| 提示詞 | 文字 | — | The text to continue. |
| 設定 | Generation Settings | — | How it chooses its words; empty for the model's own defaults. |
返回
| 續寫 | 文字 |
- 所屬發行版
- 元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 語言模型
- 所屬包
- 機器學習
載入語言模型
函數Loads a language model and its tokenizer from a Hugging Face Hub repository or a folder, downloading what is missing.
載入語言模型 -> Language Model
模型: 文字
裝置: Compute Device
精度: Precision
適配器: 文字
四位量化: 真否LanguageModel LoadLanguageModel(
string model,
ComputeDevice device = ComputeDevice.Auto,
Precision precision = Precision.Auto,
string adapter,
bool fourBit = false)參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 模型 | 文字 | — | A repository id such as HuggingFaceTB/SmolLM2-135M-Instruct, or a folder holding config.json, the weights and the tokenizer. |
| 裝置 | Compute Device | 自動 | Where it runs. |
| 精度 | Precision | 自動 | The number format of its weights; Auto is Float32 on the CPU and the model's own on the GPU. |
| 適配器 | 文字 | — | A LoRA adapter to apply, as Fine-Tune Language Model saves one: its folder or a repository id; empty for none. |
| 四位量化 | 真否 | False | Quantize the weights to 4-bit NF4 as they load, as QLoRA does: a quarter of the memory, a little less accuracy. |
返回
| 模型 | Language Model |
- 所屬發行版
- 元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 語言模型
- 所屬包
- 機器學習
載入 ONNX 語言模型
函數Loads a language model to run on the ONNX backend: the repository's own ONNX file when it has one, such as one Export Language Model to ONNX wrote, otherwise a graph built from its checkpoint. Runs on the CPU, fully managed.
載入 ONNX 語言模型(模型: 文字) -> Language Model
LanguageModel LoadOnnxLanguageModel(string model)
參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 模型 | 文字 | — | A repository id, or a folder with config.json, the tokenizer and onnx/model.onnx. |
返回
| 模型 | Language Model |
- 所屬發行版
- 元編程(專業版)
- 可用的圖種類
- 資料流 函數 事件 例程 藍圖 狀態機狀態
- 宣告於
- 語言模型
- 所屬包
- 機器學習
流式對話
函數Chat, with the reply handed to a function piece by piece as it is written - whole words, line by line - so it can be shown before it is finished.
流式對話 -> (回覆: 文字, 續接的對話: Conversation)
模型: Language Model
訊息: 文字
對話: Conversation
設定: Generation Settings
文字回撥: Action<文字>string StreamChat(
LanguageModel model,
string message,
Conversation conversation,
GenerationSettings settings,
Action<string> onText,
out Conversation continued)參數
| 名稱 | 型別 | 預設值 | 說明 |
|---|---|---|---|
| 模型 | Language Model | — | A model that can chat. |
| 訊息 | 文字 | — | What the user says. |
| 對話 | Conversation | — | The conversation so far; empty to start one. |
| 設定 | Generation Settings | — | How it chooses its words; empty for the model's own defaults. |
| 文字回撥 | Action<文字> | — | Called with each new piece of the reply, in order. |
返回
| 回覆 | 文字 |
| 續接的對話 | Conversation |
- 所屬發行版
- 元編程(專業版)
- 可用的圖種類
- 事件 例程 狀態機狀態
- 宣告於
- 語言模型
- 所屬包
- 機器學習