语言模型
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 |
- 所属发行版
- 元编程(专业版)
- 可用的图种类
- 事件 例程 状态机状态
- 声明于
- 语言模型
- 所属包
- 机器学习