Language Models
8 nodes
On this page 8
Ask
FunctionAsks a chat model one question and answers with its reply: a one-message conversation, rendered through the model's chat template.
Ask -> Text
model: Language Model
question: Text
system: Text
settings: Generation Settingsstring Ask(
LanguageModel model,
string question,
string system,
GenerationSettings settings)Parameters
| name | type | default | description |
|---|---|---|---|
| model | Language Model | — | A model that can chat (one with a chat template, usually named Instruct or Chat). |
| question | Text | — | What to ask. |
| system | Text | — | What the model is told about its part first; empty for none. |
| settings | Generation Settings | — | How it chooses its words; empty for the model's own defaults. |
Returns
| Reply | Text |
- Ships with
- Divooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Language Models
- Package
- Machine Learning
Chat
FunctionSays a message in a conversation and answers with the model's reply, and the conversation with both added, to continue from.
Chat -> (Reply: Text, continued: Conversation)
model: Language Model
message: Text
conversation: Conversation
settings: Generation Settingsstring Chat(
LanguageModel model,
string message,
Conversation conversation,
GenerationSettings settings,
out Conversation continued)Parameters
| name | type | default | description |
|---|---|---|---|
| model | Language Model | — | A model that can chat. |
| message | Text | — | What the user says. |
| conversation | Conversation | — | The conversation so far, from Start Conversation or an earlier Chat; empty to start one. |
| settings | Generation Settings | — | How it chooses its words; empty for the model's own defaults. |
Returns
| Reply | Text |
| continued | Conversation |
- Ships with
- Divooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Language Models
- Package
- Machine Learning
Continue Conversation
FunctionThe model's next reply to a conversation that ends with the user's message.
ContinueConversation -> Text
model: Language Model
conversation: Conversation
settings: Generation Settingsstring ContinueConversation(
LanguageModel model,
Conversation conversation,
GenerationSettings settings)Parameters
| name | type | default | description |
|---|---|---|---|
| model | Language Model | — | A model that can chat. |
| conversation | Conversation | — | The conversation, ending with what the user said. |
| settings | Generation Settings | — | How it chooses its words; empty for the model's own defaults. |
Returns
| Reply | Text |
- Ships with
- Divooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Language Models
- Package
- Machine Learning
Count Tokens
FunctionHow many tokens a text is to a model, which is what its length limits and Generation Settings count.
CountTokens(model: Language Model, text: Text) -> Integer
int CountTokens(LanguageModel model, string text)
Parameters
| name | type | default | description |
|---|---|---|---|
| model | Language Model | — | The model whose tokenizer counts. |
| text | Text | — | The text. |
Returns
| Tokens | Integer |
- Ships with
- Divooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Language Models
- Package
- Machine Learning
Generate Text
FunctionContinues a text as the model would write it, without a chat template: the model's continuation alone, not the prompt.
GenerateText -> Text
model: Language Model
prompt: Text
settings: Generation Settingsstring GenerateText(
LanguageModel model,
string prompt,
GenerationSettings settings)Parameters
| name | type | default | description |
|---|---|---|---|
| model | Language Model | — | Any language model, base or chat. |
| prompt | Text | — | The text to continue. |
| settings | Generation Settings | — | How it chooses its words; empty for the model's own defaults. |
Returns
| Continuation | Text |
- Ships with
- Divooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Language Models
- Package
- Machine Learning
Load Language Model
FunctionLoads a language model and its tokenizer from a Hugging Face Hub repository or a folder, downloading what is missing.
LoadLanguageModel -> Language Model
model: Text
device: Compute Device
precision: Precision
adapter: Text
fourBit: TruthLanguageModel LoadLanguageModel(
string model,
ComputeDevice device = ComputeDevice.Auto,
Precision precision = Precision.Auto,
string adapter,
bool fourBit = false)Parameters
| name | type | default | description |
|---|---|---|---|
| model | Text | — | A repository id such as HuggingFaceTB/SmolLM2-135M-Instruct, or a folder holding config.json, the weights and the tokenizer. |
| device | Compute Device | Auto | Where it runs. |
| precision | Precision | Auto | The number format of its weights; Auto is Float32 on the CPU and the model's own on the GPU. |
| adapter | Text | — | A LoRA adapter to apply, as Fine-Tune Language Model saves one: its folder or a repository id; empty for none. |
| fourBit | Truth | False | Quantize the weights to 4-bit NF4 as they load, as QLoRA does: a quarter of the memory, a little less accuracy. |
Returns
| Model | Language Model |
- Ships with
- Divooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Language Models
- Package
- Machine Learning
Load ONNX Language Model
FunctionLoads 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.
LoadOnnxLanguageModel(model: Text) -> Language Model
LanguageModel LoadOnnxLanguageModel(string model)
Parameters
| name | type | default | description |
|---|---|---|---|
| model | Text | — | A repository id, or a folder with config.json, the tokenizer and onnx/model.onnx. |
Returns
| Model | Language Model |
- Ships with
- Divooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Language Models
- Package
- Machine Learning
Stream Chat
FunctionChat, 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.
StreamChat -> (Reply: Text, continued: Conversation)
model: Language Model
message: Text
conversation: Conversation
settings: Generation Settings
onText: Action<Text>string StreamChat(
LanguageModel model,
string message,
Conversation conversation,
GenerationSettings settings,
Action<string> onText,
out Conversation continued)Parameters
| name | type | default | description |
|---|---|---|---|
| model | Language Model | — | A model that can chat. |
| message | Text | — | What the user says. |
| conversation | Conversation | — | The conversation so far; empty to start one. |
| settings | Generation Settings | — | How it chooses its words; empty for the model's own defaults. |
| onText | Action<Text> | — | Called with each new piece of the reply, in order. |
Returns
| Reply | Text |
| continued | Conversation |
- Ships with
- Divooka Compute
- Graph kinds
- Events Routine StateMachineState
- Declared by
- Language Models
- Package
- Machine Learning