LLamaTemplate
Namespace: LLama
Converts a sequence of messages into text according to a model template
1 |
|
Inheritance Object → LLamaTemplate
Attributes NullableContextAttribute, NullableAttribute, DefaultMemberAttribute
Fields
Encoding
The encoding algorithm to use
1 |
|
Properties
Count
Number of messages added to this template
1 |
|
Property Value
Item
1 |
|
Property Value
AddAssistant
Whether to end the prompt with the token(s) that indicate the start of an assistant message.
1 |
|
Property Value
Constructors
LLamaTemplate(SafeLlamaModelHandle, String, Boolean)
Construct a new template, using the default model template
1 |
|
Parameters
model
SafeLlamaModelHandle
The native handle of the loaded model.
name
String
The name of the template, in case there are many or differently named. Set to 'null' for the default behaviour of finding an appropriate match.
strict
Boolean
Setting this to true will cause the call to throw if no valid templates are found.
LLamaTemplate(LLamaWeights, Boolean)
Construct a new template, using the default model template
1 |
|
Parameters
weights
LLamaWeights
The handle of the loaded model's weights.
strict
Boolean
Setting this to true will cause the call to throw if no valid templates are found.
LLamaTemplate(String)
Construct a new template, using a custom template.
1 |
|
Parameters
customTemplate
String
Remarks:
Only support a pre-defined list of templates. See more: https://github.com/ggerganov/llama.cpp/wiki/Templates-supported-by-llama_chat_apply_template
Methods
Add(String, String)
Add a new message to the end of this template
1 |
|
Parameters
role
String
content
String
Returns
LLamaTemplate
This template, for chaining calls.
Add(TextMessage)
Add a new message to the end of this template
1 |
|
Parameters
message
TextMessage
Returns
LLamaTemplate
This template, for chaining calls.
RemoveAt(Int32)
Remove a message at the given index
1 |
|
Parameters
index
Int32
Returns
LLamaTemplate
This template, for chaining calls.
Clear()
Remove all messages from the template and resets internal state to accept/generate new messages
1 |
|
Apply()
Apply the template to the messages and return a span containing the results
1 |
|
Returns
ReadOnlySpan<Byte>
A span over the buffer that holds the applied template