From db176010e72e2d6ffbdc19fb66eb7e7c4c42bc0d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 5 Oct 2026 15:29:48 +0000 Subject: [PATCH] chore(docs): update API references in the github action. --- docs/xmldocs/index.md | 68 ++- .../llama.abstractions.icontextparams.md | 161 ++++-- .../llama.abstractions.ihistorytransform.md | 6 +- .../llama.abstractions.iinferenceparams.md | 48 +- .../llama.abstractions.illamaexecutor.md | 30 +- .../llama.abstractions.imodelparams.md | 87 +-- .../llama.abstractions.inativelibrary.md | 10 +- ...tractions.inativelibraryselectingpolicy.md | 8 +- ...llama.abstractions.itextstreamtransform.md | 6 +- .../llama.abstractions.itexttransform.md | 6 +- ...ma.abstractions.llamaexecutorextensions.md | 33 +- .../llama.abstractions.metadataoverride.md | 86 +-- ....abstractions.metadataoverrideconverter.md | 28 +- ...llama.abstractions.tensorbufferoverride.md | 12 +- ...ama.abstractions.tensorsplitscollection.md | 28 +- ...actions.tensorsplitscollectionconverter.md | 28 +- docs/xmldocs/llama.antipromptprocessor.md | 16 +- ...ed.alreadypromptedconversationexception.md | 36 +- docs/xmldocs/llama.batched.batchedexecutor.md | 43 +- ...otmodifywhilerequiresinferenceexception.md | 36 +- ....cannotsamplerequiresinferenceexception.md | 36 +- ...hed.cannotsamplerequirespromptexception.md | 36 +- ...nnotsavewhilerequiresinferenceexception.md | 36 +- .../llama.batched.conversation.kvaccessor.md | 102 ++++ docs/xmldocs/llama.batched.conversation.md | 104 ++-- .../llama.batched.conversation.state.md | 55 ++ .../llama.batched.conversationextensions.md | 20 +- ...ed.experimentalbatchedexecutorexception.md | 36 +- docs/xmldocs/llama.chatsession.md | 129 +++-- docs/xmldocs/llama.common.authorrole.md | 4 +- docs/xmldocs/llama.common.chathistory.md | 16 +- .../llama.common.chathistory.message.md | 64 +++ .../llama.common.contextoverflowstrategy.md | 28 + docs/xmldocs/llama.common.fixedsizequeue-1.md | 51 +- docs/xmldocs/llama.common.inferenceparams.md | 117 ++-- docs/xmldocs/llama.common.mirostattype.md | 4 +- docs/xmldocs/llama.common.modelparams.md | 332 +++++++----- ...ama.exceptions.contextoverflowexception.md | 159 ++++++ ...ceptions.getlogitsinvalidindexexception.md | 40 +- .../llama.exceptions.llamadecodeerror.md | 36 +- ...a.exceptions.loadweightsfailedexception.md | 44 +- ...ama.exceptions.missingtemplateexception.md | 40 +- docs/xmldocs/llama.exceptions.runtimeerror.md | 38 +- ...ma.exceptions.templatenotfoundexception.md | 40 +- ...llama.exceptions.unknowndeviceexception.md | 159 ++++++ ...ama.extensions.icontextparamsextensions.md | 14 +- ...llama.extensions.imodelparamsextensions.md | 19 +- .../llama.extensions.intptrextensions.md | 59 ++ ....extensions.spannormalizationextensions.md | 44 +- ....instructexecutor.instructexecutorstate.md | 176 ++++++ docs/xmldocs/llama.instructexecutor.md | 151 ++++-- ...activeexecutor.interactiveexecutorstate.md | 152 ++++++ docs/xmldocs/llama.interactiveexecutor.md | 159 +++--- docs/xmldocs/llama.llamacontext.md | 88 ++- .../llama.llamacontext.sequencestate.md | 99 ++++ docs/xmldocs/llama.llamacontext.state.md | 135 +++++ docs/xmldocs/llama.llamaembedder.md | 102 ---- docs/xmldocs/llama.llamaquantizer.md | 38 +- docs/xmldocs/llama.llamareranker.md | 52 +- docs/xmldocs/llama.llamatemplate.md | 48 +- .../llama.llamatemplate.textmessage.md | 62 +++ ...llamatransforms.defaulthistorytransform.md | 167 ++++++ ...ansforms.emptytextoutputstreamtransform.md | 58 ++ ...sforms.keywordtextoutputstreamtransform.md | 133 +++++ docs/xmldocs/llama.llamatransforms.md | 2 +- ...llamatransforms.naivetextinputtransform.md | 58 ++ docs/xmldocs/llama.llamaweights.md | 52 +- docs/xmldocs/llama.llavaweights.md | 204 ------- docs/xmldocs/llama.mtmdweights.md | 316 +++++++++++ docs/xmldocs/llama.native.avxlevel.md | 6 +- docs/xmldocs/llama.native.decoderesult.md | 6 +- ...ive.defaultnativelibraryselectingpolicy.md | 15 +- docs/xmldocs/llama.native.encoderesult.md | 4 +- docs/xmldocs/llama.native.ggmltype.md | 4 +- docs/xmldocs/llama.native.gpusplitmode.md | 5 +- docs/xmldocs/llama.native.icustomsampler.md | 14 +- .../llama.native.llamaattentiontype.md | 4 +- docs/xmldocs/llama.native.llamabatch.md | 30 +- .../llama.native.llamabatchembeddings.md | 36 +- docs/xmldocs/llama.native.llamachatmessage.md | 2 +- .../llama.native.llamacontextparams.md | 112 +++- docs/xmldocs/llama.native.llamacontexttype.md | 31 ++ .../llama.native.llamaflashattentiontype.md | 28 + docs/xmldocs/llama.native.llamaftype.md | 8 +- ...llama.native.llamakvcacheviewsafehandle.md | 215 -------- docs/xmldocs/llama.native.llamaloadmode.md | 34 ++ docs/xmldocs/llama.native.llamalogitbias.md | 56 +- docs/xmldocs/llama.native.llamaloglevel.md | 4 +- .../llama.native.llamamodelkvoverridetype.md | 4 +- ...llama.native.llamamodelmetadataoverride.md | 14 +- docs/xmldocs/llama.native.llamamodelparams.md | 73 ++- .../llama.native.llamamodelquantizeparams.md | 34 +- ...a.native.llamamodeltensorbufferoverride.md | 2 +- docs/xmldocs/llama.native.llamanativebatch.md | 13 +- .../llama.native.llamaperfcontexttimings.md | 14 +- docs/xmldocs/llama.native.llamapoolingtype.md | 4 +- docs/xmldocs/llama.native.llamapos.md | 52 +- docs/xmldocs/llama.native.llamaropetype.md | 4 +- .../llama.native.llamasamplerchainparams.md | 6 +- .../llama.native.llamasamplingtimings.md | 2 +- docs/xmldocs/llama.native.llamaseqid.md | 46 +- docs/xmldocs/llama.native.llamatoken.md | 70 +-- docs/xmldocs/llama.native.llamatokenattr.md | 6 +- docs/xmldocs/llama.native.llamatokendata.md | 8 +- .../llama.native.llamatokendataarray.md | 26 +- .../llama.native.llamatokendataarraynative.md | 18 +- docs/xmldocs/llama.native.llamavocabtype.md | 5 +- docs/xmldocs/llama.native.llavaimageembed.md | 41 -- docs/xmldocs/llama.native.loraadapter.md | 6 +- .../xmldocs/llama.native.mtmdcontextparams.md | 164 ++++++ docs/xmldocs/llama.native.nativeapi.md | 507 ++++++++++-------- ....native.nativelibraryconfig.description.md | 157 ++++++ .../llama.native.nativelibraryconfig.md | 90 ++-- ...ama.native.nativelibraryconfigcontainer.md | 84 ++- .../llama.native.nativelibraryfrompath.md | 22 +- .../llama.native.nativelibrarymetadata.md | 124 +---- .../xmldocs/llama.native.nativelibraryname.md | 6 +- .../llama.native.nativelibrarywithavx.md | 22 +- .../llama.native.nativelibrarywithcuda.md | 24 +- ...a.native.nativelibrarywithmacorfallback.md | 18 +- .../llama.native.nativelibrarywithvulkan.md | 26 +- docs/xmldocs/llama.native.nativelogconfig.md | 20 +- docs/xmldocs/llama.native.ropescalingtype.md | 4 +- .../llama.native.safellamacontexthandle.md | 314 ++++++----- .../llama.native.safellamahandlebase.md | 14 +- .../llama.native.safellamamodelhandle.md | 152 ++++-- ....native.safellamamodelhandle.vocabulary.md | 259 +++++++++ ...lama.native.safellamasamplerchainhandle.md | 167 +++--- .../llama.native.safellavaimageembedhandle.md | 233 -------- .../llama.native.safellavamodelhandle.md | 229 -------- .../llama.native.safemtmdembed.iembeddata.md | 50 ++ docs/xmldocs/llama.native.safemtmdembed.md | 251 +++++++++ .../llama.native.safemtmdinputchunk.md | 180 +++++++ ...femtmdinputchunk.safemtmdinputchunktype.md | 28 + .../llama.native.safemtmdinputchunks.md | 149 +++++ .../llama.native.safemtmdmodelhandle.md | 417 ++++++++++++++ docs/xmldocs/llama.native.systeminfo.md | 126 +---- .../llama.native.unknownnativelibrary.md | 20 +- .../llama.sampling.basesamplingpipeline.md | 36 +- ...amplingpipeline.grammaroptimizationmode.md | 29 + .../llama.sampling.defaultsamplingpipeline.md | 84 +-- docs/xmldocs/llama.sampling.grammar.md | 116 +--- .../llama.sampling.greedysamplingpipeline.md | 12 +- .../llama.sampling.isamplingpipeline.md | 6 +- ...ma.sampling.isamplingpipelineextensions.md | 6 +- docs/xmldocs/llama.sessionstate.md | 106 +--- ....statefulexecutorbase.executorbasestate.md | 140 +++++ docs/xmldocs/llama.statefulexecutorbase.md | 343 +++++++++--- docs/xmldocs/llama.statelessexecutor.md | 59 +- docs/xmldocs/llama.streamingtokendecoder.md | 24 +- ....transformers.prompttemplatetransformer.md | 24 +- 151 files changed, 6975 insertions(+), 3819 deletions(-) create mode 100644 docs/xmldocs/llama.batched.conversation.kvaccessor.md create mode 100644 docs/xmldocs/llama.batched.conversation.state.md create mode 100644 docs/xmldocs/llama.common.chathistory.message.md create mode 100644 docs/xmldocs/llama.common.contextoverflowstrategy.md create mode 100644 docs/xmldocs/llama.exceptions.contextoverflowexception.md create mode 100644 docs/xmldocs/llama.exceptions.unknowndeviceexception.md create mode 100644 docs/xmldocs/llama.extensions.intptrextensions.md create mode 100644 docs/xmldocs/llama.instructexecutor.instructexecutorstate.md create mode 100644 docs/xmldocs/llama.interactiveexecutor.interactiveexecutorstate.md create mode 100644 docs/xmldocs/llama.llamacontext.sequencestate.md create mode 100644 docs/xmldocs/llama.llamacontext.state.md delete mode 100644 docs/xmldocs/llama.llamaembedder.md create mode 100644 docs/xmldocs/llama.llamatemplate.textmessage.md create mode 100644 docs/xmldocs/llama.llamatransforms.defaulthistorytransform.md create mode 100644 docs/xmldocs/llama.llamatransforms.emptytextoutputstreamtransform.md create mode 100644 docs/xmldocs/llama.llamatransforms.keywordtextoutputstreamtransform.md create mode 100644 docs/xmldocs/llama.llamatransforms.naivetextinputtransform.md delete mode 100644 docs/xmldocs/llama.llavaweights.md create mode 100644 docs/xmldocs/llama.mtmdweights.md create mode 100644 docs/xmldocs/llama.native.llamacontexttype.md create mode 100644 docs/xmldocs/llama.native.llamaflashattentiontype.md delete mode 100644 docs/xmldocs/llama.native.llamakvcacheviewsafehandle.md create mode 100644 docs/xmldocs/llama.native.llamaloadmode.md delete mode 100644 docs/xmldocs/llama.native.llavaimageembed.md create mode 100644 docs/xmldocs/llama.native.mtmdcontextparams.md create mode 100644 docs/xmldocs/llama.native.nativelibraryconfig.description.md create mode 100644 docs/xmldocs/llama.native.safellamamodelhandle.vocabulary.md delete mode 100644 docs/xmldocs/llama.native.safellavaimageembedhandle.md delete mode 100644 docs/xmldocs/llama.native.safellavamodelhandle.md create mode 100644 docs/xmldocs/llama.native.safemtmdembed.iembeddata.md create mode 100644 docs/xmldocs/llama.native.safemtmdembed.md create mode 100644 docs/xmldocs/llama.native.safemtmdinputchunk.md create mode 100644 docs/xmldocs/llama.native.safemtmdinputchunk.safemtmdinputchunktype.md create mode 100644 docs/xmldocs/llama.native.safemtmdinputchunks.md create mode 100644 docs/xmldocs/llama.native.safemtmdmodelhandle.md create mode 100644 docs/xmldocs/llama.sampling.defaultsamplingpipeline.grammaroptimizationmode.md create mode 100644 docs/xmldocs/llama.statefulexecutorbase.executorbasestate.md diff --git a/docs/xmldocs/index.md b/docs/xmldocs/index.md index 3c3af0e90..6533f5778 100644 --- a/docs/xmldocs/index.md +++ b/docs/xmldocs/index.md @@ -6,13 +6,23 @@ [ChatSession](./llama.chatsession.md) +[DefaultHistoryTransform](./llama.llamatransforms.defaulthistorytransform.md) + +[EmptyTextOutputStreamTransform](./llama.llamatransforms.emptytextoutputstreamtransform.md) + +[ExecutorBaseState](./llama.statefulexecutorbase.executorbasestate.md) + [InstructExecutor](./llama.instructexecutor.md) +[InstructExecutorState](./llama.instructexecutor.instructexecutorstate.md) + [InteractiveExecutor](./llama.interactiveexecutor.md) -[LLamaContext](./llama.llamacontext.md) +[InteractiveExecutorState](./llama.interactiveexecutor.interactiveexecutorstate.md) + +[KeywordTextOutputStreamTransform](./llama.llamatransforms.keywordtextoutputstreamtransform.md) -[LLamaEmbedder](./llama.llamaembedder.md) +[LLamaContext](./llama.llamacontext.md) [LLamaQuantizer](./llama.llamaquantizer.md) @@ -24,16 +34,24 @@ [LLamaWeights](./llama.llamaweights.md) -[LLavaWeights](./llama.llavaweights.md) +[MtmdWeights](./llama.mtmdweights.md) + +[NaiveTextInputTransform](./llama.llamatransforms.naivetextinputtransform.md) + +[SequenceState](./llama.llamacontext.sequencestate.md) [SessionState](./llama.sessionstate.md) +[State](./llama.llamacontext.state.md) + [StatefulExecutorBase](./llama.statefulexecutorbase.md) [StatelessExecutor](./llama.statelessexecutor.md) [StreamingTokenDecoder](./llama.streamingtokendecoder.md) +[TextMessage](./llama.llamatemplate.textmessage.md) + ## LLama.Abstractions [IContextParams](./llama.abstractions.icontextparams.md) @@ -88,22 +106,32 @@ [ExperimentalBatchedExecutorException](./llama.batched.experimentalbatchedexecutorexception.md) +[KvAccessor](./llama.batched.conversation.kvaccessor.md) + +[State](./llama.batched.conversation.state.md) + ## LLama.Common [AuthorRole](./llama.common.authorrole.md) [ChatHistory](./llama.common.chathistory.md) +[ContextOverflowStrategy](./llama.common.contextoverflowstrategy.md) + [FixedSizeQueue<T>](./llama.common.fixedsizequeue-1.md) [InferenceParams](./llama.common.inferenceparams.md) +[Message](./llama.common.chathistory.message.md) + [MirostatType](./llama.common.mirostattype.md) [ModelParams](./llama.common.modelparams.md) ## LLama.Exceptions +[ContextOverflowException](./llama.exceptions.contextoverflowexception.md) + [GetLogitsInvalidIndexException](./llama.exceptions.getlogitsinvalidindexexception.md) [LLamaDecodeError](./llama.exceptions.llamadecodeerror.md) @@ -116,22 +144,30 @@ [TemplateNotFoundException](./llama.exceptions.templatenotfoundexception.md) +[UnknownDeviceException](./llama.exceptions.unknowndeviceexception.md) + ## LLama.Extensions [IContextParamsExtensions](./llama.extensions.icontextparamsextensions.md) [IModelParamsExtensions](./llama.extensions.imodelparamsextensions.md) +[IntPtrExtensions](./llama.extensions.intptrextensions.md) + [SpanNormalizationExtensions](./llama.extensions.spannormalizationextensions.md) ## LLama.Native + + [AvxLevel](./llama.native.avxlevel.md) [DecodeResult](./llama.native.decoderesult.md) [DefaultNativeLibrarySelectingPolicy](./llama.native.defaultnativelibraryselectingpolicy.md) +[Description](./llama.native.nativelibraryconfig.description.md) + [EncodeResult](./llama.native.encoderesult.md) [GGMLType](./llama.native.ggmltype.md) @@ -140,6 +176,8 @@ [ICustomSampler](./llama.native.icustomsampler.md) +[IEmbedData](./llama.native.safemtmdembed.iembeddata.md) + [LLamaAttentionType](./llama.native.llamaattentiontype.md) [LLamaBatch](./llama.native.llamabatch.md) @@ -150,9 +188,13 @@ [LLamaContextParams](./llama.native.llamacontextparams.md) +[LLamaContextType](./llama.native.llamacontexttype.md) + +[LLamaFlashAttentionType](./llama.native.llamaflashattentiontype.md) + [LLamaFtype](./llama.native.llamaftype.md) -[LLamaKvCacheViewSafeHandle](./llama.native.llamakvcacheviewsafehandle.md) +[LLamaLoadMode](./llama.native.llamaloadmode.md) [LLamaLogitBias](./llama.native.llamalogitbias.md) @@ -196,10 +238,10 @@ [LLamaVocabType](./llama.native.llamavocabtype.md) -[LLavaImageEmbed](./llama.native.llavaimageembed.md) - [LoraAdapter](./llama.native.loraadapter.md) +[MtmdContextParams](./llama.native.mtmdcontextparams.md) + [NativeApi](./llama.native.nativeapi.md) [NativeLibraryConfig](./llama.native.nativelibraryconfig.md) @@ -232,14 +274,22 @@ [SafeLLamaSamplerChainHandle](./llama.native.safellamasamplerchainhandle.md) -[SafeLlavaImageEmbedHandle](./llama.native.safellavaimageembedhandle.md) +[SafeMtmdEmbed](./llama.native.safemtmdembed.md) + +[SafeMtmdInputChunk](./llama.native.safemtmdinputchunk.md) + +[SafeMtmdInputChunks](./llama.native.safemtmdinputchunks.md) -[SafeLlavaModelHandle](./llama.native.safellavamodelhandle.md) +[SafeMtmdInputChunkType](./llama.native.safemtmdinputchunk.safemtmdinputchunktype.md) + +[SafeMtmdModelHandle](./llama.native.safemtmdmodelhandle.md) [SystemInfo](./llama.native.systeminfo.md) [UnknownNativeLibrary](./llama.native.unknownnativelibrary.md) +[Vocabulary](./llama.native.safellamamodelhandle.vocabulary.md) + ## LLama.Sampling [BaseSamplingPipeline](./llama.sampling.basesamplingpipeline.md) @@ -248,6 +298,8 @@ [Grammar](./llama.sampling.grammar.md) +[GrammarOptimizationMode](./llama.sampling.defaultsamplingpipeline.grammaroptimizationmode.md) + [GreedySamplingPipeline](./llama.sampling.greedysamplingpipeline.md) [ISamplingPipeline](./llama.sampling.isamplingpipeline.md) diff --git a/docs/xmldocs/llama.abstractions.icontextparams.md b/docs/xmldocs/llama.abstractions.icontextparams.md index 5252e4804..0b75112df 100644 --- a/docs/xmldocs/llama.abstractions.icontextparams.md +++ b/docs/xmldocs/llama.abstractions.icontextparams.md @@ -12,7 +12,7 @@ The parameters for initializing a LLama context from a model. public interface IContextParams ``` -Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute) +Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute) ## Properties @@ -21,260 +21,283 @@ Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/ap Model context size (n_ctx) ```csharp -public abstract Nullable ContextSize { get; } +uint? ContextSize { get; } ``` #### Property Value -[Nullable<UInt32>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[UInt32?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
+ +### **ContextType** + +The type of context + +```csharp +LLamaContextType ContextType { get; } +``` + +#### Property Value + +[LLamaContextType](./llama.native.llamacontexttype.md)
### **BatchSize** maximum batch size that can be submitted at once (must be >=32 to use BLAS) (n_batch) ```csharp -public abstract uint BatchSize { get; } +uint BatchSize { get; } ``` #### Property Value -[UInt32](https://docs.microsoft.com/en-us/dotnet/api/system.uint32)
+[UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
### **UBatchSize** Physical batch size ```csharp -public abstract uint UBatchSize { get; } +uint UBatchSize { get; } ``` #### Property Value -[UInt32](https://docs.microsoft.com/en-us/dotnet/api/system.uint32)
+[UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
### **SeqMax** max number of sequences (i.e. distinct states for recurrent models) ```csharp -public abstract uint SeqMax { get; } +uint SeqMax { get; } ``` #### Property Value -[UInt32](https://docs.microsoft.com/en-us/dotnet/api/system.uint32)
+[UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
+ +### **RecurrentRollbackSnapshots** + +The number of recurrent-state snapshots per seq for rollback + +```csharp +uint RecurrentRollbackSnapshots { get; } +``` + +#### Property Value + +[UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
### **Embeddings** If true, extract embeddings (together with logits). ```csharp -public abstract bool Embeddings { get; } +bool Embeddings { get; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **RopeFrequencyBase** RoPE base frequency (null to fetch from the model) ```csharp -public abstract Nullable RopeFrequencyBase { get; } +float? RopeFrequencyBase { get; } ``` #### Property Value -[Nullable<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[Single?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **RopeFrequencyScale** RoPE frequency scaling factor (null to fetch from the model) ```csharp -public abstract Nullable RopeFrequencyScale { get; } +float? RopeFrequencyScale { get; } ``` #### Property Value -[Nullable<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[Single?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **Encoding** The encoding to use for models ```csharp -public abstract Encoding Encoding { get; } +Encoding Encoding { get; } ``` #### Property Value -[Encoding](https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding)
+[Encoding](https://learn.microsoft.com/en-us/dotnet/api/system.text.encoding)
### **Threads** Number of threads (null = autodetect) (n_threads) ```csharp -public abstract Nullable Threads { get; } +int? Threads { get; } ``` #### Property Value -[Nullable<Int32>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[Int32?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **BatchThreads** Number of threads to use for batch processing (null = autodetect) (n_threads) ```csharp -public abstract Nullable BatchThreads { get; } +int? BatchThreads { get; } ``` #### Property Value -[Nullable<Int32>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[Int32?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **YarnExtrapolationFactor** YaRN extrapolation mix factor (null = from model) ```csharp -public abstract Nullable YarnExtrapolationFactor { get; } +float? YarnExtrapolationFactor { get; } ``` #### Property Value -[Nullable<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[Single?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **YarnAttentionFactor** YaRN magnitude scaling factor (null = from model) ```csharp -public abstract Nullable YarnAttentionFactor { get; } +float? YarnAttentionFactor { get; } ``` #### Property Value -[Nullable<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[Single?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **YarnBetaFast** YaRN low correction dim (null = from model) ```csharp -public abstract Nullable YarnBetaFast { get; } +float? YarnBetaFast { get; } ``` #### Property Value -[Nullable<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[Single?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **YarnBetaSlow** YaRN high correction dim (null = from model) ```csharp -public abstract Nullable YarnBetaSlow { get; } +float? YarnBetaSlow { get; } ``` #### Property Value -[Nullable<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[Single?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **YarnOriginalContext** YaRN original context length (null = from model) ```csharp -public abstract Nullable YarnOriginalContext { get; } +uint? YarnOriginalContext { get; } ``` #### Property Value -[Nullable<UInt32>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[UInt32?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **YarnScalingType** YaRN scaling method to use. ```csharp -public abstract Nullable YarnScalingType { get; } +RopeScalingType? YarnScalingType { get; } ``` #### Property Value -[Nullable<RopeScalingType>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[RopeScalingType?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **TypeK** Override the type of the K cache ```csharp -public abstract Nullable TypeK { get; } +GGMLType? TypeK { get; } ``` #### Property Value -[Nullable<GGMLType>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[GGMLType?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **TypeV** Override the type of the V cache ```csharp -public abstract Nullable TypeV { get; } +GGMLType? TypeV { get; } ``` #### Property Value -[Nullable<GGMLType>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[GGMLType?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **NoKqvOffload** Whether to disable offloading the KQV cache to the GPU ```csharp -public abstract bool NoKqvOffload { get; } +bool NoKqvOffload { get; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **FlashAttention** Whether to use flash attention ```csharp -public abstract bool FlashAttention { get; } +bool? FlashAttention { get; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **DefragThreshold** -defragment the KV cache if holes/size > defrag_threshold, Set to < 0 to disable (default) - defragment the KV cache if holes/size > defrag_threshold, Set to or < 0 to disable (default) +defragment the KV cache if holes/size > defrag_threshold, Set to <= 0 to disable (default) ```csharp -public abstract Nullable DefragThreshold { get; } +float? DefragThreshold { get; } ``` #### Property Value -[Nullable<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[Single?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **PoolingType** How to pool (sum) embedding results by sequence id (ignored if no pooling layer) ```csharp -public abstract LLamaPoolingType PoolingType { get; } +LLamaPoolingType PoolingType { get; } ``` #### Property Value @@ -286,13 +309,57 @@ public abstract LLamaPoolingType PoolingType { get; } Attention type to use for embeddings ```csharp -public abstract LLamaAttentionType AttentionType { get; } +LLamaAttentionType AttentionType { get; } ``` #### Property Value [LLamaAttentionType](./llama.native.llamaattentiontype.md)
+### **OpOffload** + +Offload host tensor operations to device + +```csharp +bool? OpOffload { get; } +``` + +#### Property Value + +[Boolean?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
+ +### **KVUnified** + +use a unified buffer across the input sequences when computing the attention. + try to disable when n_seq_max > 1 for improved performance when the sequences do not share a large prefix +
+ ref: https://github.com/ggml-org/llama.cpp/pull/14363 + +```csharp +bool? KVUnified { get; } +``` + +#### Property Value + +[Boolean?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
+ +### **SwaFull** + +Use full-size SWA cache (https://github.com/ggml-org/llama.cpp/pull/13194#issuecomment-2868343055) + +```csharp +bool? SwaFull { get; } +``` + +#### Property Value + +[Boolean?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
+ +**Remarks:** + +Setting to false when n_seq_max > 1 can cause bad performance in some cases + ref: https://github.com/ggml-org/llama.cpp/pull/13845#issuecomment-2924800573 + --- [`< Back`](./) diff --git a/docs/xmldocs/llama.abstractions.ihistorytransform.md b/docs/xmldocs/llama.abstractions.ihistorytransform.md index 4f9475b9f..e2c2d87ca 100644 --- a/docs/xmldocs/llama.abstractions.ihistorytransform.md +++ b/docs/xmldocs/llama.abstractions.ihistorytransform.md @@ -12,7 +12,7 @@ Transform history to plain text and vice versa. public interface IHistoryTransform ``` -Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), JsonConverterAttribute +Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [JsonConverterAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.serialization.jsonconverterattribute) ## Methods @@ -31,7 +31,7 @@ The ChatHistory instance #### Returns -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **TextToHistory(AuthorRole, String)** @@ -46,7 +46,7 @@ ChatHistory TextToHistory(AuthorRole role, string text) `role` [AuthorRole](./llama.common.authorrole.md)
The role for the author. -`text` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`text` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
The chat history as plain text. #### Returns diff --git a/docs/xmldocs/llama.abstractions.iinferenceparams.md b/docs/xmldocs/llama.abstractions.iinferenceparams.md index 7cba75d32..651d1de68 100644 --- a/docs/xmldocs/llama.abstractions.iinferenceparams.md +++ b/docs/xmldocs/llama.abstractions.iinferenceparams.md @@ -12,7 +12,7 @@ The parameters used for inference. public interface IInferenceParams ``` -Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute) +Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute) ## Properties @@ -21,12 +21,12 @@ Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/ap number of tokens to keep from initial prompt ```csharp -public abstract int TokensKeep { get; set; } +int TokensKeep { get; set; } ``` #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **MaxTokens** @@ -34,31 +34,31 @@ how many new tokens to predict (n_predict), set to -1 to infinitely generate res until it complete. ```csharp -public abstract int MaxTokens { get; set; } +int MaxTokens { get; set; } ``` #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **AntiPrompts** Sequences where the model will stop generating further tokens. ```csharp -public abstract IReadOnlyList AntiPrompts { get; set; } +IReadOnlyList AntiPrompts { get; set; } ``` #### Property Value -[IReadOnlyList<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ireadonlylist-1)
+[IReadOnlyList<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ireadonlylist-1)
### **SamplingPipeline** Set a custom sampling pipeline to use. ```csharp -public abstract ISamplingPipeline SamplingPipeline { get; set; } +ISamplingPipeline SamplingPipeline { get; set; } ``` #### Property Value @@ -70,12 +70,40 @@ public abstract ISamplingPipeline SamplingPipeline { get; set; } If true, special characters will be converted to text. If false they will be invisible. ```csharp -public abstract bool DecodeSpecialTokens { get; set; } +bool DecodeSpecialTokens { get; set; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **OverflowStrategy** + +Defines the strategy the executor should use when the context window is full + and the model architecture (e.g., models with 2D RoPE embeddings) does not + support native memory shifting. + +```csharp +ContextOverflowStrategy OverflowStrategy { get; set; } +``` + +#### Property Value + +[ContextOverflowStrategy](./llama.common.contextoverflowstrategy.md)
+ +### **ContextTruncationPercentage** + +The percentage of past tokens to discard when [IInferenceParams.OverflowStrategy](./llama.abstractions.iinferenceparams.md#overflowstrategy) + is set to [ContextOverflowStrategy.TruncateAndReprefill](./llama.common.contextoverflowstrategy.md#truncateandreprefill). + For example, 0.1f represents dropping the oldest 10% of the conversational context. + +```csharp +float ContextTruncationPercentage { get; set; } +``` + +#### Property Value + +[Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
--- diff --git a/docs/xmldocs/llama.abstractions.illamaexecutor.md b/docs/xmldocs/llama.abstractions.illamaexecutor.md index d00a478de..6350e0ace 100644 --- a/docs/xmldocs/llama.abstractions.illamaexecutor.md +++ b/docs/xmldocs/llama.abstractions.illamaexecutor.md @@ -12,7 +12,7 @@ A high level interface for LLama models. public interface ILLamaExecutor ``` -Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute) +Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute) ## Properties @@ -21,7 +21,7 @@ Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/ap The loaded context for this executor. ```csharp -public abstract LLamaContext Context { get; } +LLamaContext Context { get; } ``` #### Property Value @@ -33,36 +33,36 @@ public abstract LLamaContext Context { get; } Identify if it's a multi-modal model and there is a image to process. ```csharp -public abstract bool IsMultiModal { get; } +bool IsMultiModal { get; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **ClipModel** Multi-Modal Projections / Clip Model weights ```csharp -public abstract LLavaWeights ClipModel { get; } +MtmdWeights? ClipModel { get; } ``` #### Property Value -[LLavaWeights](./llama.llavaweights.md)
+[MtmdWeights](./llama.mtmdweights.md)
-### **Images** +### **Embeds** -List of images: List of images in byte array format. +List of media: List of media for Multi-Modal models. ```csharp -public abstract List Images { get; } +List Embeds { get; } ``` #### Property Value -[List<Byte[]>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
+[List<SafeMtmdEmbed>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
## Methods @@ -71,23 +71,23 @@ public abstract List Images { get; } Asynchronously infers a response from the model. ```csharp -IAsyncEnumerable InferAsync(string text, IInferenceParams inferenceParams, CancellationToken token) +IAsyncEnumerable InferAsync(string text, IInferenceParams? inferenceParams = null, CancellationToken token = null) ``` #### Parameters -`text` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`text` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
Your prompt -`inferenceParams` [IInferenceParams](./llama.abstractions.iinferenceparams.md)
+`inferenceParams` [IInferenceParams](./llama.abstractions.iinferenceparams.md)?
Any additional parameters -`token` [CancellationToken](https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
+`token` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
A cancellation token. #### Returns -[IAsyncEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)
+[IAsyncEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)
--- diff --git a/docs/xmldocs/llama.abstractions.imodelparams.md b/docs/xmldocs/llama.abstractions.imodelparams.md index 87cd8ff32..546d2fe60 100644 --- a/docs/xmldocs/llama.abstractions.imodelparams.md +++ b/docs/xmldocs/llama.abstractions.imodelparams.md @@ -12,7 +12,7 @@ The parameters for initializing a LLama model. public interface IModelParams ``` -Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute) +Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute) ## Properties @@ -25,24 +25,24 @@ main_gpu interpretation depends on split_mode: - **Layer** - Ignored. ```csharp -public abstract int MainGpu { get; set; } +int MainGpu { get; set; } ``` #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **SplitMode** How to split the model across multiple GPUs ```csharp -public abstract Nullable SplitMode { get; } +GPUSplitMode? SplitMode { get; } ``` #### Property Value -[Nullable<GPUSplitMode>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[GPUSplitMode?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **TensorBufferOverrides** @@ -50,67 +50,62 @@ Buffer type overrides for specific tensor patterns, allowing you to specify hard Equivalent to --override-tensor or -ot on the llama.cpp command line or tensor_buft_overrides internally. ```csharp -public abstract List TensorBufferOverrides { get; } +List TensorBufferOverrides { get; } ``` #### Property Value -[List<TensorBufferOverride>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
+[List<TensorBufferOverride>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
-### **GpuLayerCount** +### **Devices** -Number of layers to run in VRAM / GPU memory (n_gpu_layers) +Names of the backend devices the model may use, in priority order, e.g. "Vulkan1" or "CUDA0" (see [NativeApi.ggml_backend_dev_name(IntPtr)](./llama.native.nativeapi.md#ggml_backend_dev_nameintptr)). + Equivalent to --device on the llama.cpp command line or `devices` in `llama_model_params`. ```csharp -public abstract int GpuLayerCount { get; } +List Devices { get; } ``` #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[List<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
-### **UseMemorymap** +**Remarks:** -Use mmap for faster loads (use_mmap) - -```csharp -public abstract bool UseMemorymap { get; } -``` - -#### Property Value +When empty, llama.cpp picks the devices itself: all discrete GPUs, or the first integrated GPU when there is no discrete GPU. + Setting this list explicitly bypasses that selection, which is the only way to run on an integrated GPU in a machine that also has a discrete GPU. + [IModelParams.MainGpu](./llama.abstractions.imodelparams.md#maingpu) is an index into this list when it is non-empty. Names are matched case insensitively; a name that does not match any available device throws [UnknownDeviceException](./llama.exceptions.unknowndeviceexception.md) when the model is loaded. -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -### **UseMemoryLock** +### **GpuLayerCount** -Use mlock to keep model in memory (use_mlock) +Number of layers to run in VRAM / GPU memory (n_gpu_layers) ```csharp -public abstract bool UseMemoryLock { get; } +int GpuLayerCount { get; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **ModelPath** Model path (model) ```csharp -public abstract string ModelPath { get; } +string ModelPath { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **TensorSplits** how split tensors should be distributed across GPUs ```csharp -public abstract TensorSplitsCollection TensorSplits { get; } +TensorSplitsCollection TensorSplits { get; } ``` #### Property Value @@ -122,36 +117,60 @@ public abstract TensorSplitsCollection TensorSplits { get; } Load vocab only (no weights) ```csharp -public abstract bool VocabOnly { get; } +bool VocabOnly { get; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **CheckTensors** Validate model tensor data before loading ```csharp -public abstract bool CheckTensors { get; } +bool CheckTensors { get; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **MetadataOverrides** Override specific metadata items in the model ```csharp -public abstract List MetadataOverrides { get; } +List MetadataOverrides { get; } +``` + +#### Property Value + +[List<MetadataOverride>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
+ +### **LoadMode** + +How the load this model + +```csharp +LLamaLoadMode LoadMode { get; } +``` + +#### Property Value + +[LLamaLoadMode](./llama.native.llamaloadmode.md)
+ +### **LoadMTP** + +Whether to load MTP layers + +```csharp +bool LoadMTP { get; } ``` #### Property Value -[List<MetadataOverride>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
--- diff --git a/docs/xmldocs/llama.abstractions.inativelibrary.md b/docs/xmldocs/llama.abstractions.inativelibrary.md index 934f494d1..1eb05abe5 100644 --- a/docs/xmldocs/llama.abstractions.inativelibrary.md +++ b/docs/xmldocs/llama.abstractions.inativelibrary.md @@ -12,7 +12,7 @@ Descriptor of a native library. public interface INativeLibrary ``` -Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute) +Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute) ## Properties @@ -21,7 +21,7 @@ Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/ap Metadata of this library. ```csharp -public abstract NativeLibraryMetadata Metadata { get; } +NativeLibraryMetadata? Metadata { get; } ``` #### Property Value @@ -36,7 +36,7 @@ Prepare the native library file and returns the local path of it. If it's a relative path, LLamaSharp will search the path in the search directies you set. ```csharp -IEnumerable Prepare(SystemInfo systemInfo, LLamaLogCallback logCallback) +IEnumerable Prepare(SystemInfo systemInfo, LLamaLogCallback? logCallback = null) ``` #### Parameters @@ -44,12 +44,12 @@ IEnumerable Prepare(SystemInfo systemInfo, LLamaLogCallback logCallback) `systemInfo` [SystemInfo](./llama.native.systeminfo.md)
The system information of the current machine. -`logCallback` [LLamaLogCallback](./llama.native.nativelogconfig.llamalogcallback.md)
+`logCallback` [LLamaLogCallback](./llama.native.nativelogconfig.llamalogcallback.md)?
The log callback. #### Returns -[IEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
+[IEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
The relative paths of the library. You could return multiple paths to try them one by one. If no file is available, please return an empty array. --- diff --git a/docs/xmldocs/llama.abstractions.inativelibraryselectingpolicy.md b/docs/xmldocs/llama.abstractions.inativelibraryselectingpolicy.md index 18649e1d2..cd92f05ad 100644 --- a/docs/xmldocs/llama.abstractions.inativelibraryselectingpolicy.md +++ b/docs/xmldocs/llama.abstractions.inativelibraryselectingpolicy.md @@ -12,7 +12,7 @@ Decides the selected native library that should be loaded according to the confi public interface INativeLibrarySelectingPolicy ``` -Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute) +Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute) ## Methods @@ -21,7 +21,7 @@ Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/ap Select the native library. ```csharp -IEnumerable Apply(Description description, SystemInfo systemInfo, LLamaLogCallback logCallback) +IEnumerable Apply(Description description, SystemInfo systemInfo, LLamaLogCallback? logCallback = null) ``` #### Parameters @@ -31,12 +31,12 @@ IEnumerable Apply(Description description, SystemInfo systemInfo `systemInfo` [SystemInfo](./llama.native.systeminfo.md)
The system information of the current machine. -`logCallback` [LLamaLogCallback](./llama.native.nativelogconfig.llamalogcallback.md)
+`logCallback` [LLamaLogCallback](./llama.native.nativelogconfig.llamalogcallback.md)?
The log callback. #### Returns -[IEnumerable<INativeLibrary>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
+[IEnumerable<INativeLibrary>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
The information of the selected native library files, in order by priority from the beginning to the end. --- diff --git a/docs/xmldocs/llama.abstractions.itextstreamtransform.md b/docs/xmldocs/llama.abstractions.itextstreamtransform.md index 223646712..edd5f26aa 100644 --- a/docs/xmldocs/llama.abstractions.itextstreamtransform.md +++ b/docs/xmldocs/llama.abstractions.itextstreamtransform.md @@ -12,7 +12,7 @@ Takes a stream of tokens and transforms them. public interface ITextStreamTransform ``` -Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), JsonConverterAttribute +Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [JsonConverterAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.serialization.jsonconverterattribute) ## Methods @@ -26,11 +26,11 @@ IAsyncEnumerable TransformAsync(IAsyncEnumerable tokens) #### Parameters -`tokens` [IAsyncEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)
+`tokens` [IAsyncEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)
#### Returns -[IAsyncEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)
+[IAsyncEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)
### **Clone()** diff --git a/docs/xmldocs/llama.abstractions.itexttransform.md b/docs/xmldocs/llama.abstractions.itexttransform.md index 4f9c2d907..b93da8cc9 100644 --- a/docs/xmldocs/llama.abstractions.itexttransform.md +++ b/docs/xmldocs/llama.abstractions.itexttransform.md @@ -18,7 +18,7 @@ An interface for text transformations. public interface ITextTransform ``` -Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), JsonConverterAttribute +Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [JsonConverterAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.serialization.jsonconverterattribute) ## Methods @@ -32,11 +32,11 @@ string Transform(string text) #### Parameters -`text` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`text` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
#### Returns -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Clone()** diff --git a/docs/xmldocs/llama.abstractions.llamaexecutorextensions.md b/docs/xmldocs/llama.abstractions.llamaexecutorextensions.md index 686b1f746..952fce2a1 100644 --- a/docs/xmldocs/llama.abstractions.llamaexecutorextensions.md +++ b/docs/xmldocs/llama.abstractions.llamaexecutorextensions.md @@ -12,39 +12,12 @@ Extension methods to the [LLamaExecutorExtensions](./llama.abstractions.llamaexe public static class LLamaExecutorExtensions ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [LLamaExecutorExtensions](./llama.abstractions.llamaexecutorextensions.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute), [ExtensionAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.extensionattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [LLamaExecutorExtensions](./llama.abstractions.llamaexecutorextensions.md)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute), [ExtensionAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.extensionattribute) ## Methods -### **AsChatClient(ILLamaExecutor, IHistoryTransform, ITextStreamTransform)** - -Gets an instance for the specified [ILLamaExecutor](./llama.abstractions.illamaexecutor.md). - -```csharp -public static IChatClient AsChatClient(ILLamaExecutor executor, IHistoryTransform historyTransform, ITextStreamTransform outputTransform) -``` - -#### Parameters - -`executor` [ILLamaExecutor](./llama.abstractions.illamaexecutor.md)
-The executor. - -`historyTransform` [IHistoryTransform](./llama.abstractions.ihistorytransform.md)
-The [IHistoryTransform](./llama.abstractions.ihistorytransform.md) to use to transform an input list messages into a prompt. - -`outputTransform` [ITextStreamTransform](./llama.abstractions.itextstreamtransform.md)
-The [ITextStreamTransform](./llama.abstractions.itextstreamtransform.md) to use to transform the output into text. - -#### Returns - -IChatClient
-An instance for the provided [ILLamaExecutor](./llama.abstractions.illamaexecutor.md). - -#### Exceptions - -[ArgumentNullException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentnullexception)
-`executor` is null. +### **AsChatClient** --- diff --git a/docs/xmldocs/llama.abstractions.metadataoverride.md b/docs/xmldocs/llama.abstractions.metadataoverride.md index d3edf67df..43e73ab67 100644 --- a/docs/xmldocs/llama.abstractions.metadataoverride.md +++ b/docs/xmldocs/llama.abstractions.metadataoverride.md @@ -9,12 +9,12 @@ Namespace: LLama.Abstractions An override for a single key/value pair in model metadata ```csharp -public sealed class MetadataOverride : System.IEquatable`1[[LLama.Abstractions.MetadataOverride, LLamaSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] +public sealed record class MetadataOverride : System.IEquatable`1[[LLama.Abstractions.MetadataOverride, LLamaSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [MetadataOverride](./llama.abstractions.metadataoverride.md)
-Implements [IEquatable<MetadataOverride>](https://docs.microsoft.com/en-us/dotnet/api/system.iequatable-1)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute), JsonConverterAttribute +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [MetadataOverride](./llama.abstractions.metadataoverride.md)
+Implements [IEquatable<MetadataOverride>](https://learn.microsoft.com/en-us/dotnet/api/system.iequatable-1)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute), [JsonConverterAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.serialization.jsonconverterattribute) ## Properties @@ -28,7 +28,7 @@ public string Key { get; } #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
## Constructors @@ -42,9 +42,9 @@ public MetadataOverride(string key, int value) #### Parameters -`key` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`key` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
-`value` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`value` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **MetadataOverride(String, Single)** @@ -56,9 +56,9 @@ public MetadataOverride(string key, float value) #### Parameters -`key` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`key` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
-`value` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`value` [Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
### **MetadataOverride(String, Boolean)** @@ -70,9 +70,9 @@ public MetadataOverride(string key, bool value) #### Parameters -`key` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`key` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
-`value` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`value` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **MetadataOverride(String, String)** @@ -84,69 +84,9 @@ public MetadataOverride(string key, string value) #### Parameters -`key` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`key` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
-`value` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
- -## Methods - -### **ToString()** - -```csharp -public string ToString() -``` - -#### Returns - -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
- -### **GetHashCode()** - -```csharp -public int GetHashCode() -``` - -#### Returns - -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -### **Equals(Object)** - -```csharp -public bool Equals(object obj) -``` - -#### Parameters - -`obj` [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object)
- -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -### **Equals(MetadataOverride)** - -```csharp -public bool Equals(MetadataOverride other) -``` - -#### Parameters - -`other` [MetadataOverride](./llama.abstractions.metadataoverride.md)
- -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -### **<Clone>$()** - -```csharp -public MetadataOverride $() -``` - -#### Returns - -[MetadataOverride](./llama.abstractions.metadataoverride.md)
+`value` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
--- diff --git a/docs/xmldocs/llama.abstractions.metadataoverrideconverter.md b/docs/xmldocs/llama.abstractions.metadataoverrideconverter.md index 9c78883b7..668cad3ed 100644 --- a/docs/xmldocs/llama.abstractions.metadataoverrideconverter.md +++ b/docs/xmldocs/llama.abstractions.metadataoverrideconverter.md @@ -12,30 +12,30 @@ A JSON converter for [MetadataOverride](./llama.abstractions.metadataoverride.md public class MetadataOverrideConverter : System.Text.Json.Serialization.JsonConverter`1[[LLama.Abstractions.MetadataOverride, LLamaSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → JsonConverter → JsonConverter<MetadataOverride> → [MetadataOverrideConverter](./llama.abstractions.metadataoverrideconverter.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [JsonConverter](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.serialization.jsonconverter) → [JsonConverter<MetadataOverride>](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.serialization.jsonconverter-1) → [MetadataOverrideConverter](./llama.abstractions.metadataoverrideconverter.md)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties ### **HandleNull** ```csharp -public bool HandleNull { get; } +public virtual bool HandleNull { get; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **Type** ```csharp -public Type Type { get; } +public sealed override Type Type { get; } ``` #### Property Value -[Type](https://docs.microsoft.com/en-us/dotnet/api/system.type)
+[Type](https://learn.microsoft.com/en-us/dotnet/api/system.type)
## Constructors @@ -47,19 +47,19 @@ public MetadataOverrideConverter() ## Methods -### **Read(Utf8JsonReader&, Type, JsonSerializerOptions)** +### **Read(ref Utf8JsonReader, Type, JsonSerializerOptions)** ```csharp -public MetadataOverride Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) +public override MetadataOverride Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) ``` #### Parameters -`reader` Utf8JsonReader&
+`ref` `reader` [Utf8JsonReader](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.utf8jsonreader)
-`typeToConvert` [Type](https://docs.microsoft.com/en-us/dotnet/api/system.type)
+`typeToConvert` [Type](https://learn.microsoft.com/en-us/dotnet/api/system.type)
-`options` JsonSerializerOptions
+`options` [JsonSerializerOptions](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.jsonserializeroptions)
#### Returns @@ -68,16 +68,16 @@ public MetadataOverride Read(Utf8JsonReader& reader, Type typeToConvert, JsonSer ### **Write(Utf8JsonWriter, MetadataOverride, JsonSerializerOptions)** ```csharp -public void Write(Utf8JsonWriter writer, MetadataOverride value, JsonSerializerOptions options) +public override void Write(Utf8JsonWriter writer, MetadataOverride value, JsonSerializerOptions options) ``` #### Parameters -`writer` Utf8JsonWriter
+`writer` [Utf8JsonWriter](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.utf8jsonwriter)
`value` [MetadataOverride](./llama.abstractions.metadataoverride.md)
-`options` JsonSerializerOptions
+`options` [JsonSerializerOptions](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.jsonserializeroptions)
--- diff --git a/docs/xmldocs/llama.abstractions.tensorbufferoverride.md b/docs/xmldocs/llama.abstractions.tensorbufferoverride.md index 0d8ed0671..0fe7da070 100644 --- a/docs/xmldocs/llama.abstractions.tensorbufferoverride.md +++ b/docs/xmldocs/llama.abstractions.tensorbufferoverride.md @@ -12,8 +12,8 @@ Represents a mapping between a tensor name pattern and a specific buffer type public class TensorBufferOverride ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [TensorBufferOverride](./llama.abstractions.tensorbufferoverride.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [TensorBufferOverride](./llama.abstractions.tensorbufferoverride.md)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties @@ -27,7 +27,7 @@ public string Pattern { get; set; } #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **BufferType** @@ -39,7 +39,7 @@ public string BufferType { get; set; } #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
## Constructors @@ -53,10 +53,10 @@ public TensorBufferOverride(string pattern, string bufferType) #### Parameters -`pattern` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`pattern` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
Pattern to match tensor names -`bufferType` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`bufferType` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
Buffer type to use for matching tensors --- diff --git a/docs/xmldocs/llama.abstractions.tensorsplitscollection.md b/docs/xmldocs/llama.abstractions.tensorsplitscollection.md index dff87538f..88ff5ebd8 100644 --- a/docs/xmldocs/llama.abstractions.tensorsplitscollection.md +++ b/docs/xmldocs/llama.abstractions.tensorsplitscollection.md @@ -9,12 +9,12 @@ Namespace: LLama.Abstractions A fixed size array to set the tensor splits across multiple GPUs ```csharp -public sealed class TensorSplitsCollection : System.Collections.Generic.IEnumerable`1[[System.Single, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Collections.IEnumerable +public sealed class TensorSplitsCollection : System.Collections.Generic.IEnumerable`1[[System.Single, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Collections.IEnumerable ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [TensorSplitsCollection](./llama.abstractions.tensorsplitscollection.md)
-Implements [IEnumerable<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1), [IEnumerable](https://docs.microsoft.com/en-us/dotnet/api/system.collections.ienumerable)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute), [DefaultMemberAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.reflection.defaultmemberattribute), JsonConverterAttribute +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [TensorSplitsCollection](./llama.abstractions.tensorsplitscollection.md)
+Implements [IEnumerable<Single>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1), [IEnumerable](https://learn.microsoft.com/en-us/dotnet/api/system.collections.ienumerable)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute), [DefaultMemberAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.defaultmemberattribute), [JsonConverterAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.serialization.jsonconverterattribute) ## Properties @@ -28,17 +28,23 @@ public int Length { get; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
-### **Item** +## Indexers + +### **this[Int32]** ```csharp -public float Item { get; set; } +public float this[int index] { get; set; } ``` +#### Parameters + +`index` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ #### Property Value -[Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+[Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
## Constructors @@ -52,11 +58,11 @@ public TensorSplitsCollection(Single[] splits) #### Parameters -`splits` [Single[]](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`splits` [Single[]](https://learn.microsoft.com/en-us/dotnet/api/system.single)
#### Exceptions -[ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentexception)
+[ArgumentException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentexception)
### **TensorSplitsCollection()** @@ -84,7 +90,7 @@ public IEnumerator GetEnumerator() #### Returns -[IEnumerator<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerator-1)
+[IEnumerator<Single>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerator-1)
--- diff --git a/docs/xmldocs/llama.abstractions.tensorsplitscollectionconverter.md b/docs/xmldocs/llama.abstractions.tensorsplitscollectionconverter.md index 7d3a0dc01..088af13e4 100644 --- a/docs/xmldocs/llama.abstractions.tensorsplitscollectionconverter.md +++ b/docs/xmldocs/llama.abstractions.tensorsplitscollectionconverter.md @@ -12,30 +12,30 @@ A JSON converter for [TensorSplitsCollection](./llama.abstractions.tensorsplitsc public class TensorSplitsCollectionConverter : System.Text.Json.Serialization.JsonConverter`1[[LLama.Abstractions.TensorSplitsCollection, LLamaSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → JsonConverter → JsonConverter<TensorSplitsCollection> → [TensorSplitsCollectionConverter](./llama.abstractions.tensorsplitscollectionconverter.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [JsonConverter](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.serialization.jsonconverter) → [JsonConverter<TensorSplitsCollection>](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.serialization.jsonconverter-1) → [TensorSplitsCollectionConverter](./llama.abstractions.tensorsplitscollectionconverter.md)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties ### **HandleNull** ```csharp -public bool HandleNull { get; } +public virtual bool HandleNull { get; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **Type** ```csharp -public Type Type { get; } +public sealed override Type Type { get; } ``` #### Property Value -[Type](https://docs.microsoft.com/en-us/dotnet/api/system.type)
+[Type](https://learn.microsoft.com/en-us/dotnet/api/system.type)
## Constructors @@ -47,19 +47,19 @@ public TensorSplitsCollectionConverter() ## Methods -### **Read(Utf8JsonReader&, Type, JsonSerializerOptions)** +### **Read(ref Utf8JsonReader, Type, JsonSerializerOptions)** ```csharp -public TensorSplitsCollection Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) +public override TensorSplitsCollection Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) ``` #### Parameters -`reader` Utf8JsonReader&
+`ref` `reader` [Utf8JsonReader](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.utf8jsonreader)
-`typeToConvert` [Type](https://docs.microsoft.com/en-us/dotnet/api/system.type)
+`typeToConvert` [Type](https://learn.microsoft.com/en-us/dotnet/api/system.type)
-`options` JsonSerializerOptions
+`options` [JsonSerializerOptions](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.jsonserializeroptions)
#### Returns @@ -68,16 +68,16 @@ public TensorSplitsCollection Read(Utf8JsonReader& reader, Type typeToConvert, J ### **Write(Utf8JsonWriter, TensorSplitsCollection, JsonSerializerOptions)** ```csharp -public void Write(Utf8JsonWriter writer, TensorSplitsCollection value, JsonSerializerOptions options) +public override void Write(Utf8JsonWriter writer, TensorSplitsCollection value, JsonSerializerOptions options) ``` #### Parameters -`writer` Utf8JsonWriter
+`writer` [Utf8JsonWriter](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.utf8jsonwriter)
`value` [TensorSplitsCollection](./llama.abstractions.tensorsplitscollection.md)
-`options` JsonSerializerOptions
+`options` [JsonSerializerOptions](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.jsonserializeroptions)
--- diff --git a/docs/xmldocs/llama.antipromptprocessor.md b/docs/xmldocs/llama.antipromptprocessor.md index cab384a83..84e097db3 100644 --- a/docs/xmldocs/llama.antipromptprocessor.md +++ b/docs/xmldocs/llama.antipromptprocessor.md @@ -12,8 +12,8 @@ AntipromptProcessor keeps track of past tokens looking for any set Anti-Prompts public sealed class AntipromptProcessor ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [AntipromptProcessor](./llama.antipromptprocessor.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [AntipromptProcessor](./llama.antipromptprocessor.md)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Constructors @@ -22,12 +22,12 @@ Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/ap Initializes a new instance of the [AntipromptProcessor](./llama.antipromptprocessor.md) class. ```csharp -public AntipromptProcessor(IEnumerable antiprompts) +public AntipromptProcessor(IEnumerable? antiprompts = null) ``` #### Parameters -`antiprompts` [IEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
+`antiprompts` [IEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)?
The antiprompts. ## Methods @@ -42,7 +42,7 @@ public void AddAntiprompt(string antiprompt) #### Parameters -`antiprompt` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`antiprompt` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **SetAntiprompts(IEnumerable<String>)** @@ -54,7 +54,7 @@ public void SetAntiprompts(IEnumerable antiprompts) #### Parameters -`antiprompts` [IEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
+`antiprompts` [IEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
### **Add(String)** @@ -66,11 +66,11 @@ public bool Add(string text) #### Parameters -`text` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`text` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
#### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
true if the text buffer ends with any antiprompt --- diff --git a/docs/xmldocs/llama.batched.alreadypromptedconversationexception.md b/docs/xmldocs/llama.batched.alreadypromptedconversationexception.md index 7dc933556..30508ae2c 100644 --- a/docs/xmldocs/llama.batched.alreadypromptedconversationexception.md +++ b/docs/xmldocs/llama.batched.alreadypromptedconversationexception.md @@ -14,70 +14,70 @@ This exception is thrown when "Prompt()" is called on a [Conversation](./llama.b public class AlreadyPromptedConversationException : ExperimentalBatchedExecutorException, System.Runtime.Serialization.ISerializable ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://docs.microsoft.com/en-us/dotnet/api/system.exception) → [ExperimentalBatchedExecutorException](./llama.batched.experimentalbatchedexecutorexception.md) → [AlreadyPromptedConversationException](./llama.batched.alreadypromptedconversationexception.md)
-Implements [ISerializable](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception) → [ExperimentalBatchedExecutorException](./llama.batched.experimentalbatchedexecutorexception.md) → [AlreadyPromptedConversationException](./llama.batched.alreadypromptedconversationexception.md)
+Implements [ISerializable](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable) ## Properties ### **TargetSite** ```csharp -public MethodBase TargetSite { get; } +public MethodBase? TargetSite { get; } ``` #### Property Value -[MethodBase](https://docs.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
+[MethodBase](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
### **Message** ```csharp -public string Message { get; } +public virtual string Message { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Data** ```csharp -public IDictionary Data { get; } +public virtual IDictionary Data { get; } ``` #### Property Value -[IDictionary](https://docs.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
+[IDictionary](https://learn.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
### **InnerException** ```csharp -public Exception InnerException { get; } +public Exception? InnerException { get; } ``` #### Property Value -[Exception](https://docs.microsoft.com/en-us/dotnet/api/system.exception)
+[Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception)
### **HelpLink** ```csharp -public string HelpLink { get; set; } +public virtual string? HelpLink { get; set; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Source** ```csharp -public string Source { get; set; } +public virtual string? Source { get; set; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **HResult** @@ -87,17 +87,17 @@ public int HResult { get; set; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **StackTrace** ```csharp -public string StackTrace { get; } +public virtual string? StackTrace { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
## Events @@ -110,7 +110,7 @@ BinaryFormatter serialization is obsolete and should not be used. See https://ak --- ```csharp -protected event EventHandler SerializeObjectState; +protected event EventHandler? SerializeObjectState; ``` --- diff --git a/docs/xmldocs/llama.batched.batchedexecutor.md b/docs/xmldocs/llama.batched.batchedexecutor.md index 2a90b6691..e304dd1db 100644 --- a/docs/xmldocs/llama.batched.batchedexecutor.md +++ b/docs/xmldocs/llama.batched.batchedexecutor.md @@ -12,9 +12,9 @@ A batched executor that can infer multiple separate "conversations" simultaneous public sealed class BatchedExecutor : System.IDisposable ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [BatchedExecutor](./llama.batched.batchedexecutor.md)
-Implements [IDisposable](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [BatchedExecutor](./llama.batched.batchedexecutor.md)
+Implements [IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties @@ -42,6 +42,18 @@ public LLamaWeights Model { get; } [LLamaWeights](./llama.llamaweights.md)
+### **ClipModel** + +The optional [MtmdWeights](./llama.mtmdweights.md) this executor is using + +```csharp +public MtmdWeights? ClipModel { get; } +``` + +#### Property Value + +[MtmdWeights](./llama.mtmdweights.md)
+ ### **BatchedTokenCount** Get the number of tokens in the batch, waiting for [BatchedExecutor.Infer(CancellationToken)](./llama.batched.batchedexecutor.md#infercancellationtoken) to be called @@ -52,7 +64,7 @@ public int BatchedTokenCount { get; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **BatchQueueCount** @@ -64,7 +76,7 @@ public int BatchQueueCount { get; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **IsDisposed** @@ -76,16 +88,16 @@ public bool IsDisposed { get; private set; } #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
## Constructors -### **BatchedExecutor(LLamaWeights, IContextParams)** +### **BatchedExecutor(LLamaWeights, IContextParams, MtmdWeights)** Create a new batched executor ```csharp -public BatchedExecutor(LLamaWeights model, IContextParams contextParams) +public BatchedExecutor(LLamaWeights model, IContextParams contextParams, MtmdWeights? clipModel = null) ``` #### Parameters @@ -96,6 +108,9 @@ The model to use `contextParams` [IContextParams](./llama.abstractions.icontextparams.md)
Parameters to create a new context +`clipModel` [MtmdWeights](./llama.mtmdweights.md)?
+Clip model to use for multimodal capabilities + ## Methods ### **Create()** @@ -121,7 +136,7 @@ public Conversation Load(string filepath) #### Parameters -`filepath` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`filepath` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
#### Returns @@ -129,7 +144,7 @@ public Conversation Load(string filepath) #### Exceptions -[ObjectDisposedException](https://docs.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
+[ObjectDisposedException](https://learn.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
### **Load(State)** @@ -149,7 +164,7 @@ public Conversation Load(State state) #### Exceptions -[ObjectDisposedException](https://docs.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
+[ObjectDisposedException](https://learn.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
### **Infer(CancellationToken)** @@ -159,16 +174,16 @@ Run inference for all conversations in the batch which have pending tokens. threads and running inference again. ```csharp -public Task Infer(CancellationToken cancellation) +public async Task Infer(CancellationToken cancellation = null) ``` #### Parameters -`cancellation` [CancellationToken](https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
+`cancellation` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task<DecodeResult>](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+[Task<DecodeResult>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
### **Dispose()** diff --git a/docs/xmldocs/llama.batched.cannotmodifywhilerequiresinferenceexception.md b/docs/xmldocs/llama.batched.cannotmodifywhilerequiresinferenceexception.md index e630a8791..15da6b6d1 100644 --- a/docs/xmldocs/llama.batched.cannotmodifywhilerequiresinferenceexception.md +++ b/docs/xmldocs/llama.batched.cannotmodifywhilerequiresinferenceexception.md @@ -12,70 +12,70 @@ This exception is thrown when [Conversation.Modify(ModifyKvCache)](./llama.batch public class CannotModifyWhileRequiresInferenceException : ExperimentalBatchedExecutorException, System.Runtime.Serialization.ISerializable ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://docs.microsoft.com/en-us/dotnet/api/system.exception) → [ExperimentalBatchedExecutorException](./llama.batched.experimentalbatchedexecutorexception.md) → [CannotModifyWhileRequiresInferenceException](./llama.batched.cannotmodifywhilerequiresinferenceexception.md)
-Implements [ISerializable](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception) → [ExperimentalBatchedExecutorException](./llama.batched.experimentalbatchedexecutorexception.md) → [CannotModifyWhileRequiresInferenceException](./llama.batched.cannotmodifywhilerequiresinferenceexception.md)
+Implements [ISerializable](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable) ## Properties ### **TargetSite** ```csharp -public MethodBase TargetSite { get; } +public MethodBase? TargetSite { get; } ``` #### Property Value -[MethodBase](https://docs.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
+[MethodBase](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
### **Message** ```csharp -public string Message { get; } +public virtual string Message { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Data** ```csharp -public IDictionary Data { get; } +public virtual IDictionary Data { get; } ``` #### Property Value -[IDictionary](https://docs.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
+[IDictionary](https://learn.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
### **InnerException** ```csharp -public Exception InnerException { get; } +public Exception? InnerException { get; } ``` #### Property Value -[Exception](https://docs.microsoft.com/en-us/dotnet/api/system.exception)
+[Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception)
### **HelpLink** ```csharp -public string HelpLink { get; set; } +public virtual string? HelpLink { get; set; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Source** ```csharp -public string Source { get; set; } +public virtual string? Source { get; set; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **HResult** @@ -85,17 +85,17 @@ public int HResult { get; set; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **StackTrace** ```csharp -public string StackTrace { get; } +public virtual string? StackTrace { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
## Events @@ -108,7 +108,7 @@ BinaryFormatter serialization is obsolete and should not be used. See https://ak --- ```csharp -protected event EventHandler SerializeObjectState; +protected event EventHandler? SerializeObjectState; ``` --- diff --git a/docs/xmldocs/llama.batched.cannotsamplerequiresinferenceexception.md b/docs/xmldocs/llama.batched.cannotsamplerequiresinferenceexception.md index 4fe0a87bc..698e37664 100644 --- a/docs/xmldocs/llama.batched.cannotsamplerequiresinferenceexception.md +++ b/docs/xmldocs/llama.batched.cannotsamplerequiresinferenceexception.md @@ -14,70 +14,70 @@ This exception is thrown when "Sample()" is called on a [Conversation](./llama.b public class CannotSampleRequiresInferenceException : ExperimentalBatchedExecutorException, System.Runtime.Serialization.ISerializable ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://docs.microsoft.com/en-us/dotnet/api/system.exception) → [ExperimentalBatchedExecutorException](./llama.batched.experimentalbatchedexecutorexception.md) → [CannotSampleRequiresInferenceException](./llama.batched.cannotsamplerequiresinferenceexception.md)
-Implements [ISerializable](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception) → [ExperimentalBatchedExecutorException](./llama.batched.experimentalbatchedexecutorexception.md) → [CannotSampleRequiresInferenceException](./llama.batched.cannotsamplerequiresinferenceexception.md)
+Implements [ISerializable](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable) ## Properties ### **TargetSite** ```csharp -public MethodBase TargetSite { get; } +public MethodBase? TargetSite { get; } ``` #### Property Value -[MethodBase](https://docs.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
+[MethodBase](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
### **Message** ```csharp -public string Message { get; } +public virtual string Message { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Data** ```csharp -public IDictionary Data { get; } +public virtual IDictionary Data { get; } ``` #### Property Value -[IDictionary](https://docs.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
+[IDictionary](https://learn.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
### **InnerException** ```csharp -public Exception InnerException { get; } +public Exception? InnerException { get; } ``` #### Property Value -[Exception](https://docs.microsoft.com/en-us/dotnet/api/system.exception)
+[Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception)
### **HelpLink** ```csharp -public string HelpLink { get; set; } +public virtual string? HelpLink { get; set; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Source** ```csharp -public string Source { get; set; } +public virtual string? Source { get; set; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **HResult** @@ -87,17 +87,17 @@ public int HResult { get; set; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **StackTrace** ```csharp -public string StackTrace { get; } +public virtual string? StackTrace { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
## Events @@ -110,7 +110,7 @@ BinaryFormatter serialization is obsolete and should not be used. See https://ak --- ```csharp -protected event EventHandler SerializeObjectState; +protected event EventHandler? SerializeObjectState; ``` --- diff --git a/docs/xmldocs/llama.batched.cannotsamplerequirespromptexception.md b/docs/xmldocs/llama.batched.cannotsamplerequirespromptexception.md index 5f1474ad3..297ae7e15 100644 --- a/docs/xmldocs/llama.batched.cannotsamplerequirespromptexception.md +++ b/docs/xmldocs/llama.batched.cannotsamplerequirespromptexception.md @@ -14,70 +14,70 @@ This exception is thrown when "Sample()" is called on a [Conversation](./llama.b public class CannotSampleRequiresPromptException : ExperimentalBatchedExecutorException, System.Runtime.Serialization.ISerializable ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://docs.microsoft.com/en-us/dotnet/api/system.exception) → [ExperimentalBatchedExecutorException](./llama.batched.experimentalbatchedexecutorexception.md) → [CannotSampleRequiresPromptException](./llama.batched.cannotsamplerequirespromptexception.md)
-Implements [ISerializable](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception) → [ExperimentalBatchedExecutorException](./llama.batched.experimentalbatchedexecutorexception.md) → [CannotSampleRequiresPromptException](./llama.batched.cannotsamplerequirespromptexception.md)
+Implements [ISerializable](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable) ## Properties ### **TargetSite** ```csharp -public MethodBase TargetSite { get; } +public MethodBase? TargetSite { get; } ``` #### Property Value -[MethodBase](https://docs.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
+[MethodBase](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
### **Message** ```csharp -public string Message { get; } +public virtual string Message { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Data** ```csharp -public IDictionary Data { get; } +public virtual IDictionary Data { get; } ``` #### Property Value -[IDictionary](https://docs.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
+[IDictionary](https://learn.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
### **InnerException** ```csharp -public Exception InnerException { get; } +public Exception? InnerException { get; } ``` #### Property Value -[Exception](https://docs.microsoft.com/en-us/dotnet/api/system.exception)
+[Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception)
### **HelpLink** ```csharp -public string HelpLink { get; set; } +public virtual string? HelpLink { get; set; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Source** ```csharp -public string Source { get; set; } +public virtual string? Source { get; set; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **HResult** @@ -87,17 +87,17 @@ public int HResult { get; set; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **StackTrace** ```csharp -public string StackTrace { get; } +public virtual string? StackTrace { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
## Events @@ -110,7 +110,7 @@ BinaryFormatter serialization is obsolete and should not be used. See https://ak --- ```csharp -protected event EventHandler SerializeObjectState; +protected event EventHandler? SerializeObjectState; ``` --- diff --git a/docs/xmldocs/llama.batched.cannotsavewhilerequiresinferenceexception.md b/docs/xmldocs/llama.batched.cannotsavewhilerequiresinferenceexception.md index 71ecdb379..2697c00a4 100644 --- a/docs/xmldocs/llama.batched.cannotsavewhilerequiresinferenceexception.md +++ b/docs/xmldocs/llama.batched.cannotsavewhilerequiresinferenceexception.md @@ -14,70 +14,70 @@ This exception is thrown when "Save()" is called on a [Conversation](./llama.bat public class CannotSaveWhileRequiresInferenceException : ExperimentalBatchedExecutorException, System.Runtime.Serialization.ISerializable ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://docs.microsoft.com/en-us/dotnet/api/system.exception) → [ExperimentalBatchedExecutorException](./llama.batched.experimentalbatchedexecutorexception.md) → [CannotSaveWhileRequiresInferenceException](./llama.batched.cannotsavewhilerequiresinferenceexception.md)
-Implements [ISerializable](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception) → [ExperimentalBatchedExecutorException](./llama.batched.experimentalbatchedexecutorexception.md) → [CannotSaveWhileRequiresInferenceException](./llama.batched.cannotsavewhilerequiresinferenceexception.md)
+Implements [ISerializable](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable) ## Properties ### **TargetSite** ```csharp -public MethodBase TargetSite { get; } +public MethodBase? TargetSite { get; } ``` #### Property Value -[MethodBase](https://docs.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
+[MethodBase](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
### **Message** ```csharp -public string Message { get; } +public virtual string Message { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Data** ```csharp -public IDictionary Data { get; } +public virtual IDictionary Data { get; } ``` #### Property Value -[IDictionary](https://docs.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
+[IDictionary](https://learn.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
### **InnerException** ```csharp -public Exception InnerException { get; } +public Exception? InnerException { get; } ``` #### Property Value -[Exception](https://docs.microsoft.com/en-us/dotnet/api/system.exception)
+[Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception)
### **HelpLink** ```csharp -public string HelpLink { get; set; } +public virtual string? HelpLink { get; set; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Source** ```csharp -public string Source { get; set; } +public virtual string? Source { get; set; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **HResult** @@ -87,17 +87,17 @@ public int HResult { get; set; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **StackTrace** ```csharp -public string StackTrace { get; } +public virtual string? StackTrace { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
## Events @@ -110,7 +110,7 @@ BinaryFormatter serialization is obsolete and should not be used. See https://ak --- ```csharp -protected event EventHandler SerializeObjectState; +protected event EventHandler? SerializeObjectState; ``` --- diff --git a/docs/xmldocs/llama.batched.conversation.kvaccessor.md b/docs/xmldocs/llama.batched.conversation.kvaccessor.md new file mode 100644 index 000000000..96bf8d1c6 --- /dev/null +++ b/docs/xmldocs/llama.batched.conversation.kvaccessor.md @@ -0,0 +1,102 @@ +[`< Back`](./) + +--- + +# KvAccessor + +Namespace: LLama.Batched + +#### Caution + +Types with embedded references are not supported in this version of your compiler. + +--- + +Provides direct access to the KV cache of a [Conversation](./llama.batched.conversation.md). + See [Conversation.Modify(ModifyKvCache)](./llama.batched.conversation.md#modifymodifykvcache) for how to use this. + +```csharp +internal readonly ref struct KvAccessor +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [KvAccessor](./llama.batched.conversation.kvaccessor.md)
+Attributes [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute), [IsByRefLikeAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.isbyreflikeattribute), [ObsoleteAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.obsoleteattribute), [CompilerFeatureRequiredAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.compilerfeaturerequiredattribute), [IsReadOnlyAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.isreadonlyattribute) + +## Methods + +### **Remove(LLamaPos, LLamaPos)** + +Removes all tokens that have positions in [start, end) + +```csharp +public void Remove(LLamaPos start, LLamaPos end) +``` + +#### Parameters + +`start` [LLamaPos](./llama.native.llamapos.md)
+Start position (inclusive) + +`end` [LLamaPos](./llama.native.llamapos.md)
+End position (exclusive) + +### **Remove(LLamaPos, Int32)** + +Removes `count` tokens starting from `start` + +```csharp +public void Remove(LLamaPos start, int count) +``` + +#### Parameters + +`start` [LLamaPos](./llama.native.llamapos.md)
+Start position (inclusive) + +`count` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Number of tokens + +### **Add(LLamaPos, LLamaPos, Int32)** + +Adds relative position "delta" to all tokens that have positions in [p0, p1). + If the KV cache is RoPEd, the KV data is updated + accordingly + +```csharp +public void Add(LLamaPos start, LLamaPos end, int delta) +``` + +#### Parameters + +`start` [LLamaPos](./llama.native.llamapos.md)
+Start position (inclusive) + +`end` [LLamaPos](./llama.native.llamapos.md)
+End position (exclusive) + +`delta` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Amount to add on to each token position + +### **Divide(LLamaPos, LLamaPos, Int32)** + +Integer division of the positions by factor of `d > 1`. + If the KV cache is RoPEd, the KV data is updated accordingly. + +```csharp +public void Divide(LLamaPos start, LLamaPos end, int divisor) +``` + +#### Parameters + +`start` [LLamaPos](./llama.native.llamapos.md)
+Start position (inclusive). If less than zero, it is clamped to zero. + +`end` [LLamaPos](./llama.native.llamapos.md)
+End position (exclusive). If less than zero, it is treated as "infinity". + +`divisor` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Amount to divide each position by. + +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.batched.conversation.md b/docs/xmldocs/llama.batched.conversation.md index 597cba0f2..18e9f2dd8 100644 --- a/docs/xmldocs/llama.batched.conversation.md +++ b/docs/xmldocs/llama.batched.conversation.md @@ -12,9 +12,9 @@ A single conversation thread that can be prompted (adding tokens from the user) public sealed class Conversation : System.IDisposable ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [Conversation](./llama.batched.conversation.md)
-Implements [IDisposable](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [Conversation](./llama.batched.conversation.md)
+Implements [IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties @@ -52,7 +52,7 @@ public int TokenCount { get; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **IsDisposed** @@ -64,7 +64,7 @@ public bool IsDisposed { get; } #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **RequiresInference** @@ -76,7 +76,7 @@ public bool RequiresInference { get; } #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **RequiresSampling** @@ -88,7 +88,7 @@ public bool RequiresSampling { get; } #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
## Methods @@ -97,7 +97,7 @@ public bool RequiresSampling { get; } Finalizer for Conversation ```csharp -protected void Finalize() +protected override void Finalize() ``` ### **Dispose()** @@ -110,7 +110,7 @@ public void Dispose() #### Exceptions -[ObjectDisposedException](https://docs.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
+[ObjectDisposedException](https://learn.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
### **Fork()** @@ -126,7 +126,7 @@ public Conversation Fork() #### Exceptions -[ObjectDisposedException](https://docs.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
+[ObjectDisposedException](https://learn.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
**Remarks:** @@ -138,12 +138,12 @@ Get the index in the context which each token can be sampled from, the return va ([SafeLLamaContextHandle.GetLogitsIth(Int32)](./llama.native.safellamacontexthandle.md#getlogitsithint32)) or to sample a token ([SafeLLamaSamplerChainHandle.Sample(SafeLLamaContextHandle, Int32)](./llama.native.safellamasamplerchainhandle.md#samplesafellamacontexthandle-int32). ```csharp -public int GetSampleIndex(int offset) +public int GetSampleIndex(int offset = 0) ``` #### Parameters -`offset` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`offset` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
How far from the end of the previous prompt should logits be sampled. Any value other than 0 requires allLogits to have been set during prompting.
For example if 5 tokens were supplied in the last prompt call: @@ -156,11 +156,11 @@ How far from the end of the previous prompt should logits be sampled. Any value #### Returns -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
#### Exceptions -[ObjectDisposedException](https://docs.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
+[ObjectDisposedException](https://learn.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
[CannotSampleRequiresPromptException](./llama.batched.cannotsamplerequirespromptexception.md)
Thrown if this conversation was not prompted before the previous call to infer @@ -173,21 +173,21 @@ Thrown if Infer() must be called on the executor Get the logits from this conversation, ready for sampling ```csharp -public Span Sample(int offset) +public Span Sample(int offset = 0) ``` #### Parameters -`offset` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`offset` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
How far from the end of the previous prompt should logits be sampled. Any value other than 0 requires allLogits to have been set during prompting #### Returns -[Span<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1)
+[Span<Single>](https://learn.microsoft.com/en-us/dotnet/api/system.span-1)
#### Exceptions -[ObjectDisposedException](https://docs.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
+[ObjectDisposedException](https://learn.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
[CannotSampleRequiresPromptException](./llama.batched.cannotsamplerequirespromptexception.md)
Thrown if this conversation was not prompted before the previous call to infer @@ -195,24 +195,58 @@ Thrown if this conversation was not prompted before the previous call to infer [CannotSampleRequiresInferenceException](./llama.batched.cannotsamplerequiresinferenceexception.md)
Thrown if Infer() must be called on the executor +### **Prompt(String, Boolean, Boolean)** + +```csharp +public void Prompt(string promptText, bool addBos = true, bool special = true) +``` + +#### Parameters + +`promptText` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +`addBos` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +`special` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **Prompt(String, ReadOnlySpan<SafeMtmdEmbed>, Boolean)** + +Prompt this conversation with explicit multimodal embeddings. + The caller retains ownership of `embeds`. + +```csharp +public void Prompt(string promptText, ReadOnlySpan embeds, bool addBos = true) +``` + +#### Parameters + +`promptText` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+Prompt text for the model. + +`embeds` [ReadOnlySpan<SafeMtmdEmbed>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+Media embeddings to include in the multimodal prompt. + +`addBos` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+Whether to add the BOS token. + ### **Prompt(List<LLamaToken>, Boolean)** Add tokens to this conversation ```csharp -public void Prompt(List tokens, bool allLogits) +public void Prompt(List tokens, bool allLogits = false) ``` #### Parameters -`tokens` [List<LLamaToken>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
+`tokens` [List<LLamaToken>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
-`allLogits` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`allLogits` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
If true, generate logits for all tokens. If false, only generate logits for the last token. #### Exceptions -[ObjectDisposedException](https://docs.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
+[ObjectDisposedException](https://learn.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
[AlreadyPromptedConversationException](./llama.batched.alreadypromptedconversationexception.md)
@@ -221,19 +255,19 @@ If true, generate logits for all tokens. If false, only generate logits for the Add tokens to this conversation ```csharp -public void Prompt(ReadOnlySpan tokens, bool allLogits) +public void Prompt(ReadOnlySpan tokens, bool allLogits = false) ``` #### Parameters -`tokens` [ReadOnlySpan<LLamaToken>](https://docs.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+`tokens` [ReadOnlySpan<LLamaToken>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
-`allLogits` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`allLogits` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
If true, generate logits for all tokens. If false, only generate logits for the last token. #### Exceptions -[ObjectDisposedException](https://docs.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
+[ObjectDisposedException](https://learn.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
[AlreadyPromptedConversationException](./llama.batched.alreadypromptedconversationexception.md)
@@ -251,22 +285,10 @@ public void Prompt(LLamaToken token) #### Exceptions -[ObjectDisposedException](https://docs.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
+[ObjectDisposedException](https://learn.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
[AlreadyPromptedConversationException](./llama.batched.alreadypromptedconversationexception.md)
-### **Prompt(SafeLlavaImageEmbedHandle)** - -Prompt this conversation with an image embedding - -```csharp -public void Prompt(SafeLlavaImageEmbedHandle embedding) -``` - -#### Parameters - -`embedding` [SafeLlavaImageEmbedHandle](./llama.native.safellavaimageembedhandle.md)
- ### **Prompt(ReadOnlySpan<Single>)** Prompt this conversation with embeddings @@ -277,7 +299,7 @@ public void Prompt(ReadOnlySpan embeddings) #### Parameters -`embeddings` [ReadOnlySpan<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+`embeddings` [ReadOnlySpan<Single>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
The raw values of the embeddings. This span must divide equally by the embedding size of this model. ### **Modify(ModifyKvCache)** @@ -307,7 +329,7 @@ public void Save(string filepath) #### Parameters -`filepath` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`filepath` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
#### Exceptions diff --git a/docs/xmldocs/llama.batched.conversation.state.md b/docs/xmldocs/llama.batched.conversation.state.md new file mode 100644 index 000000000..f026885d7 --- /dev/null +++ b/docs/xmldocs/llama.batched.conversation.state.md @@ -0,0 +1,55 @@ +[`< Back`](./) + +--- + +# State + +Namespace: LLama.Batched + +In memory saved state of a [Conversation](./llama.batched.conversation.md) + +```csharp +internal abstract class State : System.IDisposable +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [State](./llama.batched.conversation.state.md)
+Implements [IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute) + +## Properties + +### **IsDisposed** + +Indicates if this state has been disposed + +```csharp +public bool IsDisposed { get; protected set; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **Size** + +Get the size in bytes of this state object + +```csharp +public abstract ulong Size { get; } +``` + +#### Property Value + +[UInt64](https://learn.microsoft.com/en-us/dotnet/api/system.uint64)
+ +## Methods + +### **Dispose()** + +```csharp +public abstract void Dispose() +``` + +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.batched.conversationextensions.md b/docs/xmldocs/llama.batched.conversationextensions.md index c59b6e73d..3cc56b1cd 100644 --- a/docs/xmldocs/llama.batched.conversationextensions.md +++ b/docs/xmldocs/llama.batched.conversationextensions.md @@ -12,8 +12,8 @@ Extension method for [Conversation](./llama.batched.conversation.md) public static class ConversationExtensions ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ConversationExtensions](./llama.batched.conversationextensions.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute), [ExtensionAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.extensionattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ConversationExtensions](./llama.batched.conversationextensions.md)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute), [ExtensionAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.extensionattribute) ## Methods @@ -22,7 +22,7 @@ Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/ap Sample a token from this conversation using the given sampler chain ```csharp -public static LLamaToken Sample(Conversation conversation, SafeLLamaSamplerChainHandle sampler, int offset) +public static LLamaToken Sample(Conversation conversation, SafeLLamaSamplerChainHandle sampler, int offset = 0) ``` #### Parameters @@ -32,7 +32,7 @@ public static LLamaToken Sample(Conversation conversation, SafeLLamaSamplerChain `sampler` [SafeLLamaSamplerChainHandle](./llama.native.safellamasamplerchainhandle.md)
-`offset` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`offset` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
Offset from the end of the conversation to the logits to sample, see [Conversation.GetSampleIndex(Int32)](./llama.batched.conversation.md#getsampleindexint32) for more details #### Returns @@ -44,7 +44,7 @@ Offset from the end of the conversation to the logits to sample, see [Conversati Sample a token from this conversation using the given sampling pipeline ```csharp -public static LLamaToken Sample(Conversation conversation, ISamplingPipeline sampler, int offset) +public static LLamaToken Sample(Conversation conversation, ISamplingPipeline sampler, int offset = 0) ``` #### Parameters @@ -54,7 +54,7 @@ public static LLamaToken Sample(Conversation conversation, ISamplingPipeline sam `sampler` [ISamplingPipeline](./llama.sampling.isamplingpipeline.md)
-`offset` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`offset` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
Offset from the end of the conversation to the logits to sample, see [Conversation.GetSampleIndex(Int32)](./llama.batched.conversation.md#getsampleindexint32) for more details #### Returns @@ -74,12 +74,12 @@ public static void Rewind(Conversation conversation, int tokens) `conversation` [Conversation](./llama.batched.conversation.md)
The conversation to rewind -`tokens` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`tokens` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
The number of tokens to rewind #### Exceptions -[ArgumentOutOfRangeException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentoutofrangeexception)
+[ArgumentOutOfRangeException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentoutofrangeexception)
Thrown if `tokens` parameter is larger than TokenCount ### **ShiftLeft(Conversation, Int32, Int32)** @@ -97,10 +97,10 @@ public static void ShiftLeft(Conversation conversation, int count, int keep) `conversation` [Conversation](./llama.batched.conversation.md)
The conversation to rewind -`count` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`count` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
How much to shift tokens over by -`keep` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`keep` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
The number of tokens at the start which should not be shifted --- diff --git a/docs/xmldocs/llama.batched.experimentalbatchedexecutorexception.md b/docs/xmldocs/llama.batched.experimentalbatchedexecutorexception.md index 54d2eed24..57de86e84 100644 --- a/docs/xmldocs/llama.batched.experimentalbatchedexecutorexception.md +++ b/docs/xmldocs/llama.batched.experimentalbatchedexecutorexception.md @@ -12,70 +12,70 @@ Base class for exceptions thrown from [BatchedExecutor](./llama.batched.batchede public class ExperimentalBatchedExecutorException : System.Exception, System.Runtime.Serialization.ISerializable ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://docs.microsoft.com/en-us/dotnet/api/system.exception) → [ExperimentalBatchedExecutorException](./llama.batched.experimentalbatchedexecutorexception.md)
-Implements [ISerializable](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception) → [ExperimentalBatchedExecutorException](./llama.batched.experimentalbatchedexecutorexception.md)
+Implements [ISerializable](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable) ## Properties ### **TargetSite** ```csharp -public MethodBase TargetSite { get; } +public MethodBase? TargetSite { get; } ``` #### Property Value -[MethodBase](https://docs.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
+[MethodBase](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
### **Message** ```csharp -public string Message { get; } +public virtual string Message { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Data** ```csharp -public IDictionary Data { get; } +public virtual IDictionary Data { get; } ``` #### Property Value -[IDictionary](https://docs.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
+[IDictionary](https://learn.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
### **InnerException** ```csharp -public Exception InnerException { get; } +public Exception? InnerException { get; } ``` #### Property Value -[Exception](https://docs.microsoft.com/en-us/dotnet/api/system.exception)
+[Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception)
### **HelpLink** ```csharp -public string HelpLink { get; set; } +public virtual string? HelpLink { get; set; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Source** ```csharp -public string Source { get; set; } +public virtual string? Source { get; set; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **HResult** @@ -85,17 +85,17 @@ public int HResult { get; set; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **StackTrace** ```csharp -public string StackTrace { get; } +public virtual string? StackTrace { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
## Events @@ -108,7 +108,7 @@ BinaryFormatter serialization is obsolete and should not be used. See https://ak --- ```csharp -protected event EventHandler SerializeObjectState; +protected event EventHandler? SerializeObjectState; ``` --- diff --git a/docs/xmldocs/llama.chatsession.md b/docs/xmldocs/llama.chatsession.md index ba0c626fe..71f195022 100644 --- a/docs/xmldocs/llama.chatsession.md +++ b/docs/xmldocs/llama.chatsession.md @@ -12,8 +12,8 @@ The main chat session class. public class ChatSession ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ChatSession](./llama.chatsession.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ChatSession](./llama.chatsession.md)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Fields @@ -121,7 +121,7 @@ public List InputTransformPipeline { get; set; } #### Property Value -[List<ITextTransform>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
+[List<ITextTransform>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
## Constructors @@ -154,12 +154,12 @@ public ChatSession(ILLamaExecutor executor, ChatHistory history) ## Methods -### **InitializeSessionFromHistoryAsync(ILLamaExecutor, ChatHistory, IHistoryTransform)** +### **InitializeSessionFromHistoryAsync(ILLamaExecutor, ChatHistory, IHistoryTransform, CancellationToken)** Create a new chat session and preprocess history. ```csharp -public static Task InitializeSessionFromHistoryAsync(ILLamaExecutor executor, ChatHistory history, IHistoryTransform transform) +public static async Task InitializeSessionFromHistoryAsync(ILLamaExecutor executor, ChatHistory history, IHistoryTransform? transform = null, CancellationToken cancellationToken = null) ``` #### Parameters @@ -170,12 +170,15 @@ The executor for this session `history` [ChatHistory](./llama.common.chathistory.md)
History for this session -`transform` [IHistoryTransform](./llama.abstractions.ihistorytransform.md)
+`transform` [IHistoryTransform](./llama.abstractions.ihistorytransform.md)?
History Transform for this session +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
+A token that cancels the operation + #### Returns -[Task<ChatSession>](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+[Task<ChatSession>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
A new chat session. ### **WithHistoryTransform(IHistoryTransform)** @@ -236,11 +239,11 @@ public void SaveSession(string path) #### Parameters -`path` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`path` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
#### Exceptions -[ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentexception)
+[ArgumentException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentexception)
### **GetSessionState()** @@ -260,38 +263,38 @@ SessionState object representing session state in-memory Load a session from a session state. ```csharp -public void LoadSession(SessionState state, bool loadTransforms) +public void LoadSession(SessionState state, bool loadTransforms = true) ``` #### Parameters `state` [SessionState](./llama.sessionstate.md)
-`loadTransforms` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`loadTransforms` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
If true loads transforms saved in the session state. #### Exceptions -[ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentexception)
+[ArgumentException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentexception)
### **LoadSession(String, Boolean)** Load a session from a directory. ```csharp -public void LoadSession(string path, bool loadTransforms) +public void LoadSession(string path, bool loadTransforms = true) ``` #### Parameters -`path` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`path` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
-`loadTransforms` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`loadTransforms` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
If true loads transforms saved in the session state. #### Exceptions -[ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentexception)
+[ArgumentException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentexception)
### **AddMessage(Message)** @@ -319,7 +322,7 @@ public ChatSession AddSystemMessage(string content) #### Parameters -`content` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`content` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
#### Returns @@ -335,7 +338,7 @@ public ChatSession AddAssistantMessage(string content) #### Parameters -`content` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`content` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
#### Returns @@ -351,7 +354,7 @@ public ChatSession AddUserMessage(string content) #### Parameters -`content` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`content` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
#### Returns @@ -369,69 +372,77 @@ public ChatSession RemoveLastMessage() [ChatSession](./llama.chatsession.md)
-### **AddAndProcessMessage(Message)** +### **AddAndProcessMessage(Message, CancellationToken)** Compute KV cache for the message and add it to the chat history. ```csharp -public Task AddAndProcessMessage(Message message) +public async Task AddAndProcessMessage(Message message, CancellationToken cancellationToken = null) ``` #### Parameters `message` [Message](./llama.common.chathistory.message.md)
+`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
+ #### Returns -[Task<ChatSession>](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+[Task<ChatSession>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
-### **AddAndProcessSystemMessage(String)** +### **AddAndProcessSystemMessage(String, CancellationToken)** Compute KV cache for the system message and add it to the chat history. ```csharp -public Task AddAndProcessSystemMessage(string content) +public Task AddAndProcessSystemMessage(string content, CancellationToken cancellationToken = null) ``` #### Parameters -`content` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`content` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task<ChatSession>](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+[Task<ChatSession>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
-### **AddAndProcessUserMessage(String)** +### **AddAndProcessUserMessage(String, CancellationToken)** Compute KV cache for the user message and add it to the chat history. ```csharp -public Task AddAndProcessUserMessage(string content) +public Task AddAndProcessUserMessage(string content, CancellationToken cancellationToken = null) ``` #### Parameters -`content` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`content` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task<ChatSession>](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+[Task<ChatSession>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
-### **AddAndProcessAssistantMessage(String)** +### **AddAndProcessAssistantMessage(String, CancellationToken)** Compute KV cache for the assistant message and add it to the chat history. ```csharp -public Task AddAndProcessAssistantMessage(string content) +public Task AddAndProcessAssistantMessage(string content, CancellationToken cancellationToken = null) ``` #### Parameters -`content` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`content` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task<ChatSession>](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+[Task<ChatSession>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
### **ReplaceUserMessage(Message, Message)** @@ -457,114 +468,114 @@ public ChatSession ReplaceUserMessage(Message oldMessage, Message newMessage) Chat with the model. ```csharp -public IAsyncEnumerable ChatAsync(Message message, bool applyInputTransformPipeline, IInferenceParams inferenceParams, CancellationToken cancellationToken) +public IAsyncEnumerable ChatAsync(Message message, bool applyInputTransformPipeline, IInferenceParams? inferenceParams = null, CancellationToken cancellationToken = null) ``` #### Parameters `message` [Message](./llama.common.chathistory.message.md)
-`applyInputTransformPipeline` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`applyInputTransformPipeline` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
-`inferenceParams` [IInferenceParams](./llama.abstractions.iinferenceparams.md)
+`inferenceParams` [IInferenceParams](./llama.abstractions.iinferenceparams.md)?
-`cancellationToken` [CancellationToken](https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
+`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[IAsyncEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)
+[IAsyncEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)
#### Exceptions -[ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentexception)
+[ArgumentException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentexception)
### **ChatAsync(Message, IInferenceParams, CancellationToken)** Chat with the model. ```csharp -public IAsyncEnumerable ChatAsync(Message message, IInferenceParams inferenceParams, CancellationToken cancellationToken) +public IAsyncEnumerable ChatAsync(Message message, IInferenceParams? inferenceParams = null, CancellationToken cancellationToken = null) ``` #### Parameters `message` [Message](./llama.common.chathistory.message.md)
-`inferenceParams` [IInferenceParams](./llama.abstractions.iinferenceparams.md)
+`inferenceParams` [IInferenceParams](./llama.abstractions.iinferenceparams.md)?
-`cancellationToken` [CancellationToken](https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
+`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[IAsyncEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)
+[IAsyncEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)
### **ChatAsync(ChatHistory, Boolean, IInferenceParams, CancellationToken)** Chat with the model. ```csharp -public IAsyncEnumerable ChatAsync(ChatHistory history, bool applyInputTransformPipeline, IInferenceParams inferenceParams, CancellationToken cancellationToken) +public IAsyncEnumerable ChatAsync(ChatHistory history, bool applyInputTransformPipeline, IInferenceParams? inferenceParams = null, CancellationToken cancellationToken = null) ``` #### Parameters `history` [ChatHistory](./llama.common.chathistory.md)
-`applyInputTransformPipeline` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`applyInputTransformPipeline` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
-`inferenceParams` [IInferenceParams](./llama.abstractions.iinferenceparams.md)
+`inferenceParams` [IInferenceParams](./llama.abstractions.iinferenceparams.md)?
-`cancellationToken` [CancellationToken](https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
+`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[IAsyncEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)
+[IAsyncEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)
#### Exceptions -[ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentexception)
+[ArgumentException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentexception)
### **ChatAsync(ChatHistory, IInferenceParams, CancellationToken)** Chat with the model. ```csharp -public IAsyncEnumerable ChatAsync(ChatHistory history, IInferenceParams inferenceParams, CancellationToken cancellationToken) +public IAsyncEnumerable ChatAsync(ChatHistory history, IInferenceParams? inferenceParams = null, CancellationToken cancellationToken = null) ``` #### Parameters `history` [ChatHistory](./llama.common.chathistory.md)
-`inferenceParams` [IInferenceParams](./llama.abstractions.iinferenceparams.md)
+`inferenceParams` [IInferenceParams](./llama.abstractions.iinferenceparams.md)?
-`cancellationToken` [CancellationToken](https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
+`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[IAsyncEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)
+[IAsyncEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)
### **RegenerateAssistantMessageAsync(InferenceParams, CancellationToken)** Regenerate the last assistant message. ```csharp -public IAsyncEnumerable RegenerateAssistantMessageAsync(InferenceParams inferenceParams, CancellationToken cancellationToken) +public IAsyncEnumerable RegenerateAssistantMessageAsync(InferenceParams? inferenceParams = null, CancellationToken cancellationToken = null) ``` #### Parameters -`inferenceParams` [InferenceParams](./llama.common.inferenceparams.md)
+`inferenceParams` [InferenceParams](./llama.common.inferenceparams.md)?
-`cancellationToken` [CancellationToken](https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
+`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[IAsyncEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)
+[IAsyncEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)
#### Exceptions -[InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
+[InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
--- diff --git a/docs/xmldocs/llama.common.authorrole.md b/docs/xmldocs/llama.common.authorrole.md index b2325e581..05df3cd96 100644 --- a/docs/xmldocs/llama.common.authorrole.md +++ b/docs/xmldocs/llama.common.authorrole.md @@ -12,8 +12,8 @@ Role of the message author, e.g. user/assistant/system public enum AuthorRole ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://docs.microsoft.com/en-us/dotnet/api/system.enum) → [AuthorRole](./llama.common.authorrole.md)
-Implements [IComparable](https://docs.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://docs.microsoft.com/en-us/dotnet/api/system.iconvertible) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://learn.microsoft.com/en-us/dotnet/api/system.enum) → [AuthorRole](./llama.common.authorrole.md)
+Implements [IComparable](https://learn.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://learn.microsoft.com/en-us/dotnet/api/system.iconvertible) ## Fields diff --git a/docs/xmldocs/llama.common.chathistory.md b/docs/xmldocs/llama.common.chathistory.md index 8535637a7..61de9dcee 100644 --- a/docs/xmldocs/llama.common.chathistory.md +++ b/docs/xmldocs/llama.common.chathistory.md @@ -12,8 +12,8 @@ The chat history class public class ChatHistory ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ChatHistory](./llama.common.chathistory.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ChatHistory](./llama.common.chathistory.md)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties @@ -27,7 +27,7 @@ public List Messages { get; set; } #### Property Value -[List<Message>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
+[List<Message>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
## Constructors @@ -66,7 +66,7 @@ public void AddMessage(AuthorRole authorRole, string content) `authorRole` [AuthorRole](./llama.common.authorrole.md)
Role of the message author -`content` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`content` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
Message content ### **ToJson()** @@ -79,23 +79,23 @@ public string ToJson() #### Returns -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **FromJson(String)** Deserialize a chat history from JSON ```csharp -public static ChatHistory FromJson(string json) +public static ChatHistory? FromJson(string json) ``` #### Parameters -`json` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`json` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
#### Returns -[ChatHistory](./llama.common.chathistory.md)
+[ChatHistory](./llama.common.chathistory.md)?
--- diff --git a/docs/xmldocs/llama.common.chathistory.message.md b/docs/xmldocs/llama.common.chathistory.message.md new file mode 100644 index 000000000..0b60d5c4f --- /dev/null +++ b/docs/xmldocs/llama.common.chathistory.message.md @@ -0,0 +1,64 @@ +[`< Back`](./) + +--- + +# Message + +Namespace: LLama.Common + +Chat message representation + +```csharp +internal class Message +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [Message](./llama.common.chathistory.message.md)
+Attributes [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) + +## Properties + +### **AuthorRole** + +Role of the message author, e.g. user/assistant/system + +```csharp +public AuthorRole AuthorRole { get; set; } +``` + +#### Property Value + +[AuthorRole](./llama.common.authorrole.md)
+ +### **Content** + +Message content + +```csharp +public string Content { get; set; } +``` + +#### Property Value + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +## Constructors + +### **Message(AuthorRole, String)** + +Create a new instance + +```csharp +public Message(AuthorRole authorRole, string content) +``` + +#### Parameters + +`authorRole` [AuthorRole](./llama.common.authorrole.md)
+Role of message author + +`content` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+Message content + +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.common.contextoverflowstrategy.md b/docs/xmldocs/llama.common.contextoverflowstrategy.md new file mode 100644 index 000000000..a89ea7f36 --- /dev/null +++ b/docs/xmldocs/llama.common.contextoverflowstrategy.md @@ -0,0 +1,28 @@ +[`< Back`](./) + +--- + +# ContextOverflowStrategy + +Namespace: LLama.Common + +Defines how the executor should behave when the context window fills up + on a model that does not support native memory shifting (e.g., 2D RoPE models). + +```csharp +public enum ContextOverflowStrategy +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://learn.microsoft.com/en-us/dotnet/api/system.enum) → [ContextOverflowStrategy](./llama.common.contextoverflowstrategy.md)
+Implements [IComparable](https://learn.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://learn.microsoft.com/en-us/dotnet/api/system.iconvertible) + +## Fields + +| Name | Value | Description | +| --- | --: | --- | +| ThrowException | 0 | The engine will throw a ContextOverflowException. Use this to manually manage context pruning in your application layer. (Equivalent to llama-cli's --no-context-shift). | +| TruncateAndReprefill | 1 | The engine will silently drop a percentage of the oldest tokens (preserving the system prompt) and completely re-prefill the context. | + +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.common.fixedsizequeue-1.md b/docs/xmldocs/llama.common.fixedsizequeue-1.md index 87db982fb..1cfe69a0a 100644 --- a/docs/xmldocs/llama.common.fixedsizequeue-1.md +++ b/docs/xmldocs/llama.common.fixedsizequeue-1.md @@ -6,62 +6,67 @@ Namespace: LLama.Common -A queue with fixed storage size. - Currently it's only a naive implementation and needs to be further optimized in the future. +A queue with fixed storage size backed by a circular buffer. ```csharp -public class FixedSizeQueue : , , , System.Collections.IEnumerable +public class FixedSizeQueue : IReadOnlyList`1, IReadOnlyCollection`1, IEnumerable`1, System.Collections.IEnumerable ``` #### Type Parameters `T`
-Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [FixedSizeQueue<T>](./llama.common.fixedsizequeue-1.md)
-Implements IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, [IEnumerable](https://docs.microsoft.com/en-us/dotnet/api/system.collections.ienumerable)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute), [DefaultMemberAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.reflection.defaultmemberattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [FixedSizeQueue<T>](./llama.common.fixedsizequeue-1.md)
+Implements IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>, [IEnumerable](https://learn.microsoft.com/en-us/dotnet/api/system.collections.ienumerable)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute), [DefaultMemberAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.defaultmemberattribute) ## Properties -### **Item** +### **Count** + +Number of items in this queue ```csharp -public T Item { get; } +public int Count { get; } ``` #### Property Value -T
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
-### **Count** +### **Capacity** -Number of items in this queue +Maximum number of items allowed in this queue ```csharp -public int Count { get; } +public int Capacity { get; } ``` #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
-### **Capacity** +## Indexers -Maximum number of items allowed in this queue +### **this[Int32]** ```csharp -public int Capacity { get; } +public T this[int index] { get; } ``` +#### Parameters + +`index` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+T
## Constructors ### **FixedSizeQueue(Int32)** -Create a new queue +Create a new queue. ```csharp public FixedSizeQueue(int size) @@ -69,12 +74,12 @@ public FixedSizeQueue(int size) #### Parameters -`size` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
-the maximum number of items to store in this queue +`size` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+The maximum number of items to store in this queue. ### **FixedSizeQueue(Int32, IEnumerable<T>)** -Fill the quene with the data. Please ensure that data.Count <= size +Fill the queue with existing data. Please ensure that data.Count <= size ```csharp public FixedSizeQueue(int size, IEnumerable data) @@ -82,7 +87,7 @@ public FixedSizeQueue(int size, IEnumerable data) #### Parameters -`size` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`size` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
`data` IEnumerable<T>
@@ -90,7 +95,7 @@ public FixedSizeQueue(int size, IEnumerable data) ### **Enqueue(T)** -Enquene an element. +Enqueue an element. When the queue is full the oldest element is overwritten. ```csharp public void Enqueue(T item) diff --git a/docs/xmldocs/llama.common.inferenceparams.md b/docs/xmldocs/llama.common.inferenceparams.md index b087f7515..7f5c087f1 100644 --- a/docs/xmldocs/llama.common.inferenceparams.md +++ b/docs/xmldocs/llama.common.inferenceparams.md @@ -9,25 +9,15 @@ Namespace: LLama.Common The parameters used for inference. ```csharp -public class InferenceParams : LLama.Abstractions.IInferenceParams, System.IEquatable`1[[LLama.Common.InferenceParams, LLamaSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] +public record class InferenceParams : LLama.Abstractions.IInferenceParams, System.IEquatable`1[[LLama.Common.InferenceParams, LLamaSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [InferenceParams](./llama.common.inferenceparams.md)
-Implements [IInferenceParams](./llama.abstractions.iinferenceparams.md), [IEquatable<InferenceParams>](https://docs.microsoft.com/en-us/dotnet/api/system.iequatable-1)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [InferenceParams](./llama.common.inferenceparams.md)
+Implements [IInferenceParams](./llama.abstractions.iinferenceparams.md), [IEquatable<InferenceParams>](https://learn.microsoft.com/en-us/dotnet/api/system.iequatable-1)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties -### **EqualityContract** - -```csharp -protected Type EqualityContract { get; } -``` - -#### Property Value - -[Type](https://docs.microsoft.com/en-us/dotnet/api/system.type)
- ### **TokensKeep** number of tokens to keep from initial prompt when applying context shifting @@ -38,7 +28,7 @@ public int TokensKeep { get; set; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **MaxTokens** @@ -51,7 +41,7 @@ public int MaxTokens { get; set; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **AntiPrompts** @@ -63,10 +53,12 @@ public IReadOnlyList AntiPrompts { get; set; } #### Property Value -[IReadOnlyList<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ireadonlylist-1)
+[IReadOnlyList<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ireadonlylist-1)
### **SamplingPipeline** +Set a custom sampling pipeline to use. + ```csharp public ISamplingPipeline SamplingPipeline { get; set; } ``` @@ -77,106 +69,63 @@ public ISamplingPipeline SamplingPipeline { get; set; } ### **DecodeSpecialTokens** +If true, special characters will be converted to text. If false they will be invisible. + ```csharp public bool DecodeSpecialTokens { get; set; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -## Constructors - -### **InferenceParams(InferenceParams)** - -```csharp -protected InferenceParams(InferenceParams original) -``` - -#### Parameters - -`original` [InferenceParams](./llama.common.inferenceparams.md)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
-### **InferenceParams()** +### **OverflowStrategy** -```csharp -public InferenceParams() -``` - -## Methods - -### **ToString()** +Defines the strategy the executor should use when the context window is full + and the model architecture does not support native memory shifting. + Defaults to [ContextOverflowStrategy.ThrowException](./llama.common.contextoverflowstrategy.md#throwexception) to prevent + unintended data loss and latency spikes. ```csharp -public string ToString() +public ContextOverflowStrategy OverflowStrategy { get; set; } ``` -#### Returns - -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
- -### **PrintMembers(StringBuilder)** - -```csharp -protected bool PrintMembers(StringBuilder builder) -``` - -#### Parameters - -`builder` [StringBuilder](https://docs.microsoft.com/en-us/dotnet/api/system.text.stringbuilder)
- -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -### **GetHashCode()** - -```csharp -public int GetHashCode() -``` +#### Property Value -#### Returns +[ContextOverflowStrategy](./llama.common.contextoverflowstrategy.md)
-[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+### **ContextTruncationPercentage** -### **Equals(Object)** +The percentage of past tokens to discard when [InferenceParams.OverflowStrategy](./llama.common.inferenceparams.md#overflowstrategy) + is set to [ContextOverflowStrategy.TruncateAndReprefill](./llama.common.contextoverflowstrategy.md#truncateandreprefill). + Defaults to 0.1f (10%). Valid range is typically between 0.01f and 0.99f. ```csharp -public bool Equals(object obj) +public float ContextTruncationPercentage { get; set; } ``` -#### Parameters - -`obj` [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object)
+#### Property Value -#### Returns +[Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
-[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+## Constructors -### **Equals(InferenceParams)** +### **InferenceParams(InferenceParams)** ```csharp -public bool Equals(InferenceParams other) +protected InferenceParams(InferenceParams original) ``` #### Parameters -`other` [InferenceParams](./llama.common.inferenceparams.md)
- -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`original` [InferenceParams](./llama.common.inferenceparams.md)
-### **<Clone>$()** +### **InferenceParams()** ```csharp -public InferenceParams $() +public InferenceParams() ``` -#### Returns - -[InferenceParams](./llama.common.inferenceparams.md)
- --- [`< Back`](./) diff --git a/docs/xmldocs/llama.common.mirostattype.md b/docs/xmldocs/llama.common.mirostattype.md index 36e98fa07..1980bf03a 100644 --- a/docs/xmldocs/llama.common.mirostattype.md +++ b/docs/xmldocs/llama.common.mirostattype.md @@ -13,8 +13,8 @@ Type of "mirostat" sampling to use. public enum MirostatType ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://docs.microsoft.com/en-us/dotnet/api/system.enum) → [MirostatType](./llama.common.mirostattype.md)
-Implements [IComparable](https://docs.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://docs.microsoft.com/en-us/dotnet/api/system.iconvertible) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://learn.microsoft.com/en-us/dotnet/api/system.enum) → [MirostatType](./llama.common.mirostattype.md)
+Implements [IComparable](https://learn.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://learn.microsoft.com/en-us/dotnet/api/system.iconvertible) ## Fields diff --git a/docs/xmldocs/llama.common.modelparams.md b/docs/xmldocs/llama.common.modelparams.md index 737bc5552..6c4d55586 100644 --- a/docs/xmldocs/llama.common.modelparams.md +++ b/docs/xmldocs/llama.common.modelparams.md @@ -9,167 +9,211 @@ Namespace: LLama.Common The parameters for initializing a LLama model. ```csharp -public class ModelParams : LLama.Abstractions.ILLamaParams, LLama.Abstractions.IModelParams, LLama.Abstractions.IContextParams, System.IEquatable`1[[LLama.Common.ModelParams, LLamaSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] +public record class ModelParams : LLama.Abstractions.ILLamaParams, LLama.Abstractions.IModelParams, LLama.Abstractions.IContextParams, System.IEquatable`1[[LLama.Common.ModelParams, LLamaSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ModelParams](./llama.common.modelparams.md)
-Implements [ILLamaParams](./llama.abstractions.illamaparams.md), [IModelParams](./llama.abstractions.imodelparams.md), [IContextParams](./llama.abstractions.icontextparams.md), [IEquatable<ModelParams>](https://docs.microsoft.com/en-us/dotnet/api/system.iequatable-1)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ModelParams](./llama.common.modelparams.md)
+Implements [ILLamaParams](./llama.abstractions.illamaparams.md), [IModelParams](./llama.abstractions.imodelparams.md), [IContextParams](./llama.abstractions.icontextparams.md), [IEquatable<ModelParams>](https://learn.microsoft.com/en-us/dotnet/api/system.iequatable-1)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties -### **EqualityContract** +### **ContextSize** + +Model context size (n_ctx) ```csharp -protected Type EqualityContract { get; } +public uint? ContextSize { get; set; } ``` #### Property Value -[Type](https://docs.microsoft.com/en-us/dotnet/api/system.type)
+[UInt32?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
-### **ContextSize** +### **ContextType** + +The type of context ```csharp -public Nullable ContextSize { get; set; } +public LLamaContextType ContextType { get; set; } ``` #### Property Value -[Nullable<UInt32>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[LLamaContextType](./llama.native.llamacontexttype.md)
### **MainGpu** +main_gpu interpretation depends on split_mode: + +- **None** - The GPU that is used for the entire mode. +- **Row** - The GPU that is used for small tensors and intermediate results. +- **Layer** - Ignored. + ```csharp public int MainGpu { get; set; } ``` #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **SplitMode** +How to split the model across multiple GPUs + ```csharp -public Nullable SplitMode { get; set; } +public GPUSplitMode? SplitMode { get; set; } ``` #### Property Value -[Nullable<GPUSplitMode>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[GPUSplitMode?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **TensorBufferOverrides** +Buffer type overrides for specific tensor patterns, allowing you to specify hardware devices to use for individual tensors or sets of tensors. + Equivalent to --override-tensor or -ot on the llama.cpp command line or tensor_buft_overrides internally. + ```csharp public List TensorBufferOverrides { get; set; } ``` #### Property Value -[List<TensorBufferOverride>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
+[List<TensorBufferOverride>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
-### **GpuLayerCount** +### **Devices** + +Names of the backend devices the model may use, in priority order, e.g. "Vulkan1" or "CUDA0" (see [NativeApi.ggml_backend_dev_name(IntPtr)](./llama.native.nativeapi.md#ggml_backend_dev_nameintptr)). + Equivalent to --device on the llama.cpp command line or `devices` in `llama_model_params`. ```csharp -public int GpuLayerCount { get; set; } +public List Devices { get; set; } ``` #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[List<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
-### **SeqMax** +**Remarks:** + +When empty, llama.cpp picks the devices itself: all discrete GPUs, or the first integrated GPU when there is no discrete GPU. + Setting this list explicitly bypasses that selection, which is the only way to run on an integrated GPU in a machine that also has a discrete GPU. + [IModelParams.MainGpu](./llama.abstractions.imodelparams.md#maingpu) is an index into this list when it is non-empty. Names are matched case insensitively; a name that does not match any available device throws [UnknownDeviceException](./llama.exceptions.unknowndeviceexception.md) when the model is loaded. + +### **GpuLayerCount** + +Number of layers to run in VRAM / GPU memory (n_gpu_layers) ```csharp -public uint SeqMax { get; set; } +public int GpuLayerCount { get; set; } ``` #### Property Value -[UInt32](https://docs.microsoft.com/en-us/dotnet/api/system.uint32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
-### **UseMemorymap** +### **SeqMax** + +max number of sequences (i.e. distinct states for recurrent models) ```csharp -public bool UseMemorymap { get; set; } +public uint SeqMax { get; set; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
+ +### **RecurrentRollbackSnapshots** -### **UseMemoryLock** +The number of recurrent-state snapshots per seq for rollback ```csharp -public bool UseMemoryLock { get; set; } +public uint RecurrentRollbackSnapshots { get; set; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
### **ModelPath** +Model path (model) + ```csharp public string ModelPath { get; set; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Threads** +Number of threads (null = autodetect) (n_threads) + ```csharp -public Nullable Threads { get; set; } +public int? Threads { get; set; } ``` #### Property Value -[Nullable<Int32>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[Int32?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **BatchThreads** +Number of threads to use for batch processing (null = autodetect) (n_threads) + ```csharp -public Nullable BatchThreads { get; set; } +public int? BatchThreads { get; set; } ``` #### Property Value -[Nullable<Int32>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[Int32?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **BatchSize** +maximum batch size that can be submitted at once (must be >=32 to use BLAS) (n_batch) + ```csharp public uint BatchSize { get; set; } ``` #### Property Value -[UInt32](https://docs.microsoft.com/en-us/dotnet/api/system.uint32)
+[UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
### **UBatchSize** +Physical batch size + ```csharp public uint UBatchSize { get; set; } ``` #### Property Value -[UInt32](https://docs.microsoft.com/en-us/dotnet/api/system.uint32)
+[UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
### **Embeddings** +If true, extract embeddings (together with logits). + ```csharp public bool Embeddings { get; set; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **TensorSplits** +how split tensors should be distributed across GPUs + ```csharp public TensorSplitsCollection TensorSplits { get; set; } ``` @@ -180,156 +224,218 @@ public TensorSplitsCollection TensorSplits { get; set; } ### **CheckTensors** +Validate model tensor data before loading + ```csharp public bool CheckTensors { get; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **MetadataOverrides** +Override specific metadata items in the model + ```csharp public List MetadataOverrides { get; set; } ``` #### Property Value -[List<MetadataOverride>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
+[List<MetadataOverride>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
+ +### **LoadMode** + +How the load this model + +```csharp +public LLamaLoadMode LoadMode { get; set; } +``` + +#### Property Value + +[LLamaLoadMode](./llama.native.llamaloadmode.md)
+ +### **LoadMTP** + +Whether to load MTP layers + +```csharp +public bool LoadMTP { get; set; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **RopeFrequencyBase** +RoPE base frequency (null to fetch from the model) + ```csharp -public Nullable RopeFrequencyBase { get; set; } +public float? RopeFrequencyBase { get; set; } ``` #### Property Value -[Nullable<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[Single?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **RopeFrequencyScale** +RoPE frequency scaling factor (null to fetch from the model) + ```csharp -public Nullable RopeFrequencyScale { get; set; } +public float? RopeFrequencyScale { get; set; } ``` #### Property Value -[Nullable<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[Single?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **YarnExtrapolationFactor** +YaRN extrapolation mix factor (null = from model) + ```csharp -public Nullable YarnExtrapolationFactor { get; set; } +public float? YarnExtrapolationFactor { get; set; } ``` #### Property Value -[Nullable<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[Single?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **YarnAttentionFactor** +YaRN magnitude scaling factor (null = from model) + ```csharp -public Nullable YarnAttentionFactor { get; set; } +public float? YarnAttentionFactor { get; set; } ``` #### Property Value -[Nullable<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[Single?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **YarnBetaFast** +YaRN low correction dim (null = from model) + ```csharp -public Nullable YarnBetaFast { get; set; } +public float? YarnBetaFast { get; set; } ``` #### Property Value -[Nullable<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[Single?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **YarnBetaSlow** +YaRN high correction dim (null = from model) + ```csharp -public Nullable YarnBetaSlow { get; set; } +public float? YarnBetaSlow { get; set; } ``` #### Property Value -[Nullable<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[Single?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **YarnOriginalContext** +YaRN original context length (null = from model) + ```csharp -public Nullable YarnOriginalContext { get; set; } +public uint? YarnOriginalContext { get; set; } ``` #### Property Value -[Nullable<UInt32>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[UInt32?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **YarnScalingType** +YaRN scaling method to use. + ```csharp -public Nullable YarnScalingType { get; set; } +public RopeScalingType? YarnScalingType { get; set; } ``` #### Property Value -[Nullable<RopeScalingType>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[RopeScalingType?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **TypeK** +Override the type of the K cache + ```csharp -public Nullable TypeK { get; set; } +public GGMLType? TypeK { get; set; } ``` #### Property Value -[Nullable<GGMLType>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[GGMLType?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **TypeV** +Override the type of the V cache + ```csharp -public Nullable TypeV { get; set; } +public GGMLType? TypeV { get; set; } ``` #### Property Value -[Nullable<GGMLType>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[GGMLType?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **NoKqvOffload** +Whether to disable offloading the KQV cache to the GPU + ```csharp public bool NoKqvOffload { get; set; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **FlashAttention** +Whether to use flash attention + ```csharp -public bool FlashAttention { get; set; } +public bool? FlashAttention { get; set; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **DefragThreshold** +#### Caution + +This member is obsolete. + +--- + +defragment the KV cache if holes/size > defrag_threshold, Set to <= 0 to disable (default) + ```csharp -public Nullable DefragThreshold { get; set; } +public float? DefragThreshold { get; set; } ``` #### Property Value -[Nullable<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[Single?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
### **PoolingType** +How to pool (sum) embedding results by sequence id (ignored if no pooling layer) + ```csharp public LLamaPoolingType PoolingType { get; set; } ``` @@ -340,6 +446,8 @@ public LLamaPoolingType PoolingType { get; set; } ### **AttentionType** +Attention type to use for embeddings + ```csharp public LLamaAttentionType AttentionType { get; set; } ``` @@ -350,122 +458,96 @@ public LLamaAttentionType AttentionType { get; set; } ### **VocabOnly** +Load vocab only (no weights) + ```csharp public bool VocabOnly { get; set; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
-### **Encoding** +### **OpOffload** + +Offload host tensor operations to device ```csharp -public Encoding Encoding { get; set; } +public bool? OpOffload { get; set; } ``` #### Property Value -[Encoding](https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding)
+[Boolean?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
-## Constructors +### **SwaFull** -### **ModelParams(String)** - - - -```csharp -public ModelParams(string modelPath) -``` - -#### Parameters - -`modelPath` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
-The model path. - -### **ModelParams(ModelParams)** +Use full-size SWA cache (https://github.com/ggml-org/llama.cpp/pull/13194#issuecomment-2868343055) ```csharp -protected ModelParams(ModelParams original) +public bool? SwaFull { get; set; } ``` -#### Parameters +#### Property Value -`original` [ModelParams](./llama.common.modelparams.md)
+[Boolean?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
-## Methods +**Remarks:** -### **ToString()** +Setting to false when n_seq_max > 1 can cause bad performance in some cases + ref: https://github.com/ggml-org/llama.cpp/pull/13845#issuecomment-2924800573 -```csharp -public string ToString() -``` +### **KVUnified** -#### Returns - -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
- -### **PrintMembers(StringBuilder)** +use a unified buffer across the input sequences when computing the attention. + try to disable when n_seq_max > 1 for improved performance when the sequences do not share a large prefix +
+ ref: https://github.com/ggml-org/llama.cpp/pull/14363 ```csharp -protected bool PrintMembers(StringBuilder builder) +public bool? KVUnified { get; set; } ``` -#### Parameters - -`builder` [StringBuilder](https://docs.microsoft.com/en-us/dotnet/api/system.text.stringbuilder)
+#### Property Value -#### Returns +[Boolean?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
-[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+### **Encoding** -### **GetHashCode()** +The encoding to use for models ```csharp -public int GetHashCode() +public Encoding Encoding { get; set; } ``` -#### Returns - -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -### **Equals(Object)** - -```csharp -public bool Equals(object obj) -``` +#### Property Value -#### Parameters +[Encoding](https://learn.microsoft.com/en-us/dotnet/api/system.text.encoding)
-`obj` [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object)
+## Constructors -#### Returns +### **ModelParams(String)** -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
-### **Equals(ModelParams)** ```csharp -public bool Equals(ModelParams other) +public ModelParams(string modelPath) ``` #### Parameters -`other` [ModelParams](./llama.common.modelparams.md)
- -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`modelPath` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+The model path. -### **<Clone>$()** +### **ModelParams(ModelParams)** ```csharp -public ModelParams $() +protected ModelParams(ModelParams original) ``` -#### Returns +#### Parameters -[ModelParams](./llama.common.modelparams.md)
+`original` [ModelParams](./llama.common.modelparams.md)
--- diff --git a/docs/xmldocs/llama.exceptions.contextoverflowexception.md b/docs/xmldocs/llama.exceptions.contextoverflowexception.md new file mode 100644 index 000000000..3a9f1f120 --- /dev/null +++ b/docs/xmldocs/llama.exceptions.contextoverflowexception.md @@ -0,0 +1,159 @@ +[`< Back`](./) + +--- + +# ContextOverflowException + +Namespace: LLama.Exceptions + +Thrown when the KV cache context is full and the model architecture + cannot mathematically support native memory shifting, or when the + ContextOverflowStrategy.ThrowException is used. + +```csharp +public class ContextOverflowException : System.Exception, System.Runtime.Serialization.ISerializable +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception) → [ContextOverflowException](./llama.exceptions.contextoverflowexception.md)
+Implements [ISerializable](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) + +## Properties + +### **TargetSite** + +```csharp +public MethodBase? TargetSite { get; } +``` + +#### Property Value + +[MethodBase](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
+ +### **Message** + +```csharp +public virtual string Message { get; } +``` + +#### Property Value + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **Data** + +```csharp +public virtual IDictionary Data { get; } +``` + +#### Property Value + +[IDictionary](https://learn.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
+ +### **InnerException** + +```csharp +public Exception? InnerException { get; } +``` + +#### Property Value + +[Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception)
+ +### **HelpLink** + +```csharp +public virtual string? HelpLink { get; set; } +``` + +#### Property Value + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **Source** + +```csharp +public virtual string? Source { get; set; } +``` + +#### Property Value + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **HResult** + +```csharp +public int HResult { get; set; } +``` + +#### Property Value + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **StackTrace** + +```csharp +public virtual string? StackTrace { get; } +``` + +#### Property Value + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +## Constructors + +### **ContextOverflowException()** + +Initializes a new instance of the ContextOverflowException class with a default error message. + +```csharp +public ContextOverflowException() +``` + +### **ContextOverflowException(String)** + +Initializes a new instance of the ContextOverflowException class with a specified error message. + +```csharp +public ContextOverflowException(string message) +``` + +#### Parameters + +`message` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+The message that describes the error. + +### **ContextOverflowException(String, Exception)** + +Initializes a new instance of the ContextOverflowException class with a specified error message + and a reference to the inner exception that is the cause of this exception. + +```csharp +public ContextOverflowException(string message, Exception innerException) +``` + +#### Parameters + +`message` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+The message that describes the error. + +`innerException` [Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception)
+The exception that is the cause of the current exception. + +## Events + +### **SerializeObjectState** + +#### Caution + +BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information. + +--- + +```csharp +protected event EventHandler? SerializeObjectState; +``` + +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.exceptions.getlogitsinvalidindexexception.md b/docs/xmldocs/llama.exceptions.getlogitsinvalidindexexception.md index 6ec2c9cd7..71e7fb50b 100644 --- a/docs/xmldocs/llama.exceptions.getlogitsinvalidindexexception.md +++ b/docs/xmldocs/llama.exceptions.getlogitsinvalidindexexception.md @@ -12,8 +12,8 @@ Namespace: LLama.Exceptions public class GetLogitsInvalidIndexException : RuntimeError, System.Runtime.Serialization.ISerializable ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://docs.microsoft.com/en-us/dotnet/api/system.exception) → [RuntimeError](./llama.exceptions.runtimeerror.md) → [GetLogitsInvalidIndexException](./llama.exceptions.getlogitsinvalidindexexception.md)
-Implements [ISerializable](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception) → [RuntimeError](./llama.exceptions.runtimeerror.md) → [GetLogitsInvalidIndexException](./llama.exceptions.getlogitsinvalidindexexception.md)
+Implements [ISerializable](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable) ## Properties @@ -27,67 +27,67 @@ public int Index { get; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **TargetSite** ```csharp -public MethodBase TargetSite { get; } +public MethodBase? TargetSite { get; } ``` #### Property Value -[MethodBase](https://docs.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
+[MethodBase](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
### **Message** ```csharp -public string Message { get; } +public virtual string Message { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Data** ```csharp -public IDictionary Data { get; } +public virtual IDictionary Data { get; } ``` #### Property Value -[IDictionary](https://docs.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
+[IDictionary](https://learn.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
### **InnerException** ```csharp -public Exception InnerException { get; } +public Exception? InnerException { get; } ``` #### Property Value -[Exception](https://docs.microsoft.com/en-us/dotnet/api/system.exception)
+[Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception)
### **HelpLink** ```csharp -public string HelpLink { get; set; } +public virtual string? HelpLink { get; set; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Source** ```csharp -public string Source { get; set; } +public virtual string? Source { get; set; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **HResult** @@ -97,17 +97,17 @@ public int HResult { get; set; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **StackTrace** ```csharp -public string StackTrace { get; } +public virtual string? StackTrace { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
## Constructors @@ -119,7 +119,7 @@ public GetLogitsInvalidIndexException(int index) #### Parameters -`index` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`index` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
## Events @@ -132,7 +132,7 @@ BinaryFormatter serialization is obsolete and should not be used. See https://ak --- ```csharp -protected event EventHandler SerializeObjectState; +protected event EventHandler? SerializeObjectState; ``` --- diff --git a/docs/xmldocs/llama.exceptions.llamadecodeerror.md b/docs/xmldocs/llama.exceptions.llamadecodeerror.md index bfda8b8d2..00123fc78 100644 --- a/docs/xmldocs/llama.exceptions.llamadecodeerror.md +++ b/docs/xmldocs/llama.exceptions.llamadecodeerror.md @@ -12,8 +12,8 @@ Namespace: LLama.Exceptions public class LLamaDecodeError : RuntimeError, System.Runtime.Serialization.ISerializable ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://docs.microsoft.com/en-us/dotnet/api/system.exception) → [RuntimeError](./llama.exceptions.runtimeerror.md) → [LLamaDecodeError](./llama.exceptions.llamadecodeerror.md)
-Implements [ISerializable](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception) → [RuntimeError](./llama.exceptions.runtimeerror.md) → [LLamaDecodeError](./llama.exceptions.llamadecodeerror.md)
+Implements [ISerializable](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable) ## Properties @@ -32,62 +32,62 @@ public DecodeResult ReturnCode { get; } ### **TargetSite** ```csharp -public MethodBase TargetSite { get; } +public MethodBase? TargetSite { get; } ``` #### Property Value -[MethodBase](https://docs.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
+[MethodBase](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
### **Message** ```csharp -public string Message { get; } +public virtual string Message { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Data** ```csharp -public IDictionary Data { get; } +public virtual IDictionary Data { get; } ``` #### Property Value -[IDictionary](https://docs.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
+[IDictionary](https://learn.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
### **InnerException** ```csharp -public Exception InnerException { get; } +public Exception? InnerException { get; } ``` #### Property Value -[Exception](https://docs.microsoft.com/en-us/dotnet/api/system.exception)
+[Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception)
### **HelpLink** ```csharp -public string HelpLink { get; set; } +public virtual string? HelpLink { get; set; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Source** ```csharp -public string Source { get; set; } +public virtual string? Source { get; set; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **HResult** @@ -97,17 +97,17 @@ public int HResult { get; set; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **StackTrace** ```csharp -public string StackTrace { get; } +public virtual string? StackTrace { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
## Constructors @@ -132,7 +132,7 @@ BinaryFormatter serialization is obsolete and should not be used. See https://ak --- ```csharp -protected event EventHandler SerializeObjectState; +protected event EventHandler? SerializeObjectState; ``` --- diff --git a/docs/xmldocs/llama.exceptions.loadweightsfailedexception.md b/docs/xmldocs/llama.exceptions.loadweightsfailedexception.md index a0caa41c1..6c652f030 100644 --- a/docs/xmldocs/llama.exceptions.loadweightsfailedexception.md +++ b/docs/xmldocs/llama.exceptions.loadweightsfailedexception.md @@ -12,9 +12,9 @@ Loading model weights failed public class LoadWeightsFailedException : RuntimeError, System.Runtime.Serialization.ISerializable ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://docs.microsoft.com/en-us/dotnet/api/system.exception) → [RuntimeError](./llama.exceptions.runtimeerror.md) → [LoadWeightsFailedException](./llama.exceptions.loadweightsfailedexception.md)
-Implements [ISerializable](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception) → [RuntimeError](./llama.exceptions.runtimeerror.md) → [LoadWeightsFailedException](./llama.exceptions.loadweightsfailedexception.md)
+Implements [ISerializable](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties @@ -28,67 +28,67 @@ public string ModelPath { get; } #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **TargetSite** ```csharp -public MethodBase TargetSite { get; } +public MethodBase? TargetSite { get; } ``` #### Property Value -[MethodBase](https://docs.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
+[MethodBase](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
### **Message** ```csharp -public string Message { get; } +public virtual string Message { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Data** ```csharp -public IDictionary Data { get; } +public virtual IDictionary Data { get; } ``` #### Property Value -[IDictionary](https://docs.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
+[IDictionary](https://learn.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
### **InnerException** ```csharp -public Exception InnerException { get; } +public Exception? InnerException { get; } ``` #### Property Value -[Exception](https://docs.microsoft.com/en-us/dotnet/api/system.exception)
+[Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception)
### **HelpLink** ```csharp -public string HelpLink { get; set; } +public virtual string? HelpLink { get; set; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Source** ```csharp -public string Source { get; set; } +public virtual string? Source { get; set; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **HResult** @@ -98,29 +98,31 @@ public int HResult { get; set; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **StackTrace** ```csharp -public string StackTrace { get; } +public virtual string? StackTrace { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
## Constructors ### **LoadWeightsFailedException(String)** +Create a new RuntimeError + ```csharp public LoadWeightsFailedException(string modelPath) ``` #### Parameters -`modelPath` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`modelPath` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
## Events @@ -133,7 +135,7 @@ BinaryFormatter serialization is obsolete and should not be used. See https://ak --- ```csharp -protected event EventHandler SerializeObjectState; +protected event EventHandler? SerializeObjectState; ``` --- diff --git a/docs/xmldocs/llama.exceptions.missingtemplateexception.md b/docs/xmldocs/llama.exceptions.missingtemplateexception.md index 53037142c..f35539c23 100644 --- a/docs/xmldocs/llama.exceptions.missingtemplateexception.md +++ b/docs/xmldocs/llama.exceptions.missingtemplateexception.md @@ -12,70 +12,70 @@ Namespace: LLama.Exceptions public class MissingTemplateException : RuntimeError, System.Runtime.Serialization.ISerializable ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://docs.microsoft.com/en-us/dotnet/api/system.exception) → [RuntimeError](./llama.exceptions.runtimeerror.md) → [MissingTemplateException](./llama.exceptions.missingtemplateexception.md)
-Implements [ISerializable](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception) → [RuntimeError](./llama.exceptions.runtimeerror.md) → [MissingTemplateException](./llama.exceptions.missingtemplateexception.md)
+Implements [ISerializable](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable) ## Properties ### **TargetSite** ```csharp -public MethodBase TargetSite { get; } +public MethodBase? TargetSite { get; } ``` #### Property Value -[MethodBase](https://docs.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
+[MethodBase](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
### **Message** ```csharp -public string Message { get; } +public virtual string Message { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Data** ```csharp -public IDictionary Data { get; } +public virtual IDictionary Data { get; } ``` #### Property Value -[IDictionary](https://docs.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
+[IDictionary](https://learn.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
### **InnerException** ```csharp -public Exception InnerException { get; } +public Exception? InnerException { get; } ``` #### Property Value -[Exception](https://docs.microsoft.com/en-us/dotnet/api/system.exception)
+[Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception)
### **HelpLink** ```csharp -public string HelpLink { get; set; } +public virtual string? HelpLink { get; set; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Source** ```csharp -public string Source { get; set; } +public virtual string? Source { get; set; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **HResult** @@ -85,17 +85,17 @@ public int HResult { get; set; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **StackTrace** ```csharp -public string StackTrace { get; } +public virtual string? StackTrace { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
## Constructors @@ -107,13 +107,15 @@ public MissingTemplateException() ### **MissingTemplateException(String)** +Create a new RuntimeError + ```csharp public MissingTemplateException(string message) ``` #### Parameters -`message` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`message` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
## Events @@ -126,7 +128,7 @@ BinaryFormatter serialization is obsolete and should not be used. See https://ak --- ```csharp -protected event EventHandler SerializeObjectState; +protected event EventHandler? SerializeObjectState; ``` --- diff --git a/docs/xmldocs/llama.exceptions.runtimeerror.md b/docs/xmldocs/llama.exceptions.runtimeerror.md index cc36835b7..ed6d1aaf6 100644 --- a/docs/xmldocs/llama.exceptions.runtimeerror.md +++ b/docs/xmldocs/llama.exceptions.runtimeerror.md @@ -12,70 +12,70 @@ Base class for LLamaSharp runtime errors (i.e. errors produced by llama.cpp, con public class RuntimeError : System.Exception, System.Runtime.Serialization.ISerializable ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://docs.microsoft.com/en-us/dotnet/api/system.exception) → [RuntimeError](./llama.exceptions.runtimeerror.md)
-Implements [ISerializable](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception) → [RuntimeError](./llama.exceptions.runtimeerror.md)
+Implements [ISerializable](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable) ## Properties ### **TargetSite** ```csharp -public MethodBase TargetSite { get; } +public MethodBase? TargetSite { get; } ``` #### Property Value -[MethodBase](https://docs.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
+[MethodBase](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
### **Message** ```csharp -public string Message { get; } +public virtual string Message { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Data** ```csharp -public IDictionary Data { get; } +public virtual IDictionary Data { get; } ``` #### Property Value -[IDictionary](https://docs.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
+[IDictionary](https://learn.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
### **InnerException** ```csharp -public Exception InnerException { get; } +public Exception? InnerException { get; } ``` #### Property Value -[Exception](https://docs.microsoft.com/en-us/dotnet/api/system.exception)
+[Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception)
### **HelpLink** ```csharp -public string HelpLink { get; set; } +public virtual string? HelpLink { get; set; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Source** ```csharp -public string Source { get; set; } +public virtual string? Source { get; set; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **HResult** @@ -85,17 +85,17 @@ public int HResult { get; set; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **StackTrace** ```csharp -public string StackTrace { get; } +public virtual string? StackTrace { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
## Constructors @@ -109,7 +109,7 @@ public RuntimeError(string message) #### Parameters -`message` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`message` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
## Events @@ -122,7 +122,7 @@ BinaryFormatter serialization is obsolete and should not be used. See https://ak --- ```csharp -protected event EventHandler SerializeObjectState; +protected event EventHandler? SerializeObjectState; ``` --- diff --git a/docs/xmldocs/llama.exceptions.templatenotfoundexception.md b/docs/xmldocs/llama.exceptions.templatenotfoundexception.md index 1f689471b..e7afcd864 100644 --- a/docs/xmldocs/llama.exceptions.templatenotfoundexception.md +++ b/docs/xmldocs/llama.exceptions.templatenotfoundexception.md @@ -12,70 +12,70 @@ Namespace: LLama.Exceptions public class TemplateNotFoundException : RuntimeError, System.Runtime.Serialization.ISerializable ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://docs.microsoft.com/en-us/dotnet/api/system.exception) → [RuntimeError](./llama.exceptions.runtimeerror.md) → [TemplateNotFoundException](./llama.exceptions.templatenotfoundexception.md)
-Implements [ISerializable](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception) → [RuntimeError](./llama.exceptions.runtimeerror.md) → [TemplateNotFoundException](./llama.exceptions.templatenotfoundexception.md)
+Implements [ISerializable](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable) ## Properties ### **TargetSite** ```csharp -public MethodBase TargetSite { get; } +public MethodBase? TargetSite { get; } ``` #### Property Value -[MethodBase](https://docs.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
+[MethodBase](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
### **Message** ```csharp -public string Message { get; } +public virtual string Message { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Data** ```csharp -public IDictionary Data { get; } +public virtual IDictionary Data { get; } ``` #### Property Value -[IDictionary](https://docs.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
+[IDictionary](https://learn.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
### **InnerException** ```csharp -public Exception InnerException { get; } +public Exception? InnerException { get; } ``` #### Property Value -[Exception](https://docs.microsoft.com/en-us/dotnet/api/system.exception)
+[Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception)
### **HelpLink** ```csharp -public string HelpLink { get; set; } +public virtual string? HelpLink { get; set; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Source** ```csharp -public string Source { get; set; } +public virtual string? Source { get; set; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **HResult** @@ -85,29 +85,31 @@ public int HResult { get; set; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **StackTrace** ```csharp -public string StackTrace { get; } +public virtual string? StackTrace { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
## Constructors ### **TemplateNotFoundException(String)** +Create a new RuntimeError + ```csharp public TemplateNotFoundException(string name) ``` #### Parameters -`name` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`name` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
## Events @@ -120,7 +122,7 @@ BinaryFormatter serialization is obsolete and should not be used. See https://ak --- ```csharp -protected event EventHandler SerializeObjectState; +protected event EventHandler? SerializeObjectState; ``` --- diff --git a/docs/xmldocs/llama.exceptions.unknowndeviceexception.md b/docs/xmldocs/llama.exceptions.unknowndeviceexception.md new file mode 100644 index 000000000..a13d17886 --- /dev/null +++ b/docs/xmldocs/llama.exceptions.unknowndeviceexception.md @@ -0,0 +1,159 @@ +[`< Back`](./) + +--- + +# UnknownDeviceException + +Namespace: LLama.Exceptions + +Thrown when a device name in [IModelParams.Devices](./llama.abstractions.imodelparams.md#devices) does not match any available ggml backend device + +```csharp +public class UnknownDeviceException : System.Exception, System.Runtime.Serialization.ISerializable +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception) → [UnknownDeviceException](./llama.exceptions.unknowndeviceexception.md)
+Implements [ISerializable](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.serialization.iserializable)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) + +## Properties + +### **RequestedDevice** + +The device name which was requested but could not be found + +```csharp +public string RequestedDevice { get; } +``` + +#### Property Value + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **AvailableDevices** + +Names of all devices available on this machine, as returned by [NativeApi.ggml_backend_dev_name(IntPtr)](./llama.native.nativeapi.md#ggml_backend_dev_nameintptr) + +```csharp +public IReadOnlyList AvailableDevices { get; } +``` + +#### Property Value + +[IReadOnlyList<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ireadonlylist-1)
+ +### **TargetSite** + +```csharp +public MethodBase? TargetSite { get; } +``` + +#### Property Value + +[MethodBase](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.methodbase)
+ +### **Message** + +```csharp +public virtual string Message { get; } +``` + +#### Property Value + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **Data** + +```csharp +public virtual IDictionary Data { get; } +``` + +#### Property Value + +[IDictionary](https://learn.microsoft.com/en-us/dotnet/api/system.collections.idictionary)
+ +### **InnerException** + +```csharp +public Exception? InnerException { get; } +``` + +#### Property Value + +[Exception](https://learn.microsoft.com/en-us/dotnet/api/system.exception)
+ +### **HelpLink** + +```csharp +public virtual string? HelpLink { get; set; } +``` + +#### Property Value + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **Source** + +```csharp +public virtual string? Source { get; set; } +``` + +#### Property Value + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **HResult** + +```csharp +public int HResult { get; set; } +``` + +#### Property Value + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **StackTrace** + +```csharp +public virtual string? StackTrace { get; } +``` + +#### Property Value + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +## Constructors + +### **UnknownDeviceException(String, IReadOnlyList<String>)** + +Create a new UnknownDeviceException + +```csharp +public UnknownDeviceException(string requestedDevice, IReadOnlyList availableDevices) +``` + +#### Parameters + +`requestedDevice` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+The device name which was requested but could not be found + +`availableDevices` [IReadOnlyList<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ireadonlylist-1)
+Names of all devices available on this machine + +## Events + +### **SerializeObjectState** + +#### Caution + +BinaryFormatter serialization is obsolete and should not be used. See https://aka.ms/binaryformatter for more information. + +--- + +```csharp +protected event EventHandler? SerializeObjectState; +``` + +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.extensions.icontextparamsextensions.md b/docs/xmldocs/llama.extensions.icontextparamsextensions.md index f9f9439d1..a15a32f6d 100644 --- a/docs/xmldocs/llama.extensions.icontextparamsextensions.md +++ b/docs/xmldocs/llama.extensions.icontextparamsextensions.md @@ -12,30 +12,30 @@ Extension methods to the IContextParams interface public static class IContextParamsExtensions ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [IContextParamsExtensions](./llama.extensions.icontextparamsextensions.md)
-Attributes [ExtensionAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.extensionattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [IContextParamsExtensions](./llama.extensions.icontextparamsextensions.md)
+Attributes [ExtensionAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.extensionattribute) ## Methods -### **ToLlamaContextParams(IContextParams, LLamaContextParams&)** +### **ToLlamaContextParams(IContextParams, out LLamaContextParams)** Convert the given `IModelParams` into a `LLamaContextParams` ```csharp -public static void ToLlamaContextParams(IContextParams params, LLamaContextParams& result) +public static void ToLlamaContextParams(IContextParams params, out LLamaContextParams result) ``` #### Parameters `params` [IContextParams](./llama.abstractions.icontextparams.md)
-`result` [LLamaContextParams&](./llama.native.llamacontextparams&.md)
+`out` `result` [LLamaContextParams](./llama.native.llamacontextparams.md)
#### Exceptions -[FileNotFoundException](https://docs.microsoft.com/en-us/dotnet/api/system.io.filenotfoundexception)
+[FileNotFoundException](https://learn.microsoft.com/en-us/dotnet/api/system.io.filenotfoundexception)
-[ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentexception)
+[ArgumentException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentexception)
--- diff --git a/docs/xmldocs/llama.extensions.imodelparamsextensions.md b/docs/xmldocs/llama.extensions.imodelparamsextensions.md index cf236d452..a58d49bde 100644 --- a/docs/xmldocs/llama.extensions.imodelparamsextensions.md +++ b/docs/xmldocs/llama.extensions.imodelparamsextensions.md @@ -12,34 +12,37 @@ Extension methods to the IModelParams interface public static class IModelParamsExtensions ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [IModelParamsExtensions](./llama.extensions.imodelparamsextensions.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute), [ExtensionAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.extensionattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [IModelParamsExtensions](./llama.extensions.imodelparamsextensions.md)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute), [ExtensionAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.extensionattribute) ## Methods -### **ToLlamaModelParams(IModelParams, LLamaModelParams&)** +### **ToLlamaModelParams(IModelParams, out LLamaModelParams)** Convert the given `IModelParams` into a `LLamaModelParams` ```csharp -public static IDisposable ToLlamaModelParams(IModelParams params, LLamaModelParams& result) +public static IDisposable ToLlamaModelParams(IModelParams params, out LLamaModelParams result) ``` #### Parameters `params` [IModelParams](./llama.abstractions.imodelparams.md)
-`result` [LLamaModelParams&](./llama.native.llamamodelparams&.md)
+`out` `result` [LLamaModelParams](./llama.native.llamamodelparams.md)
#### Returns -[IDisposable](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable)
+[IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable)
#### Exceptions -[FileNotFoundException](https://docs.microsoft.com/en-us/dotnet/api/system.io.filenotfoundexception)
+[FileNotFoundException](https://learn.microsoft.com/en-us/dotnet/api/system.io.filenotfoundexception)
-[ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentexception)
+[ArgumentException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentexception)
+ +[UnknownDeviceException](./llama.exceptions.unknowndeviceexception.md)
+Thrown if a name in [IModelParams.Devices](./llama.abstractions.imodelparams.md#devices) does not match any available device --- diff --git a/docs/xmldocs/llama.extensions.intptrextensions.md b/docs/xmldocs/llama.extensions.intptrextensions.md new file mode 100644 index 000000000..dcb0a963c --- /dev/null +++ b/docs/xmldocs/llama.extensions.intptrextensions.md @@ -0,0 +1,59 @@ +[`< Back`](./) + +--- + +# IntPtrExtensions + +Namespace: LLama.Extensions + +```csharp +public static class IntPtrExtensions +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [IntPtrExtensions](./llama.extensions.intptrextensions.md)
+Attributes [ExtensionAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.extensionattribute) + +## Methods + +### **PtrToStringWithDefault(IntPtr, String)** + +Converts a native UTF-8 string pointer to a managed string, returning a fallback value when no data is available. + +```csharp +public static string PtrToStringWithDefault(IntPtr ptr, string defaultValue = "") +``` + +#### Parameters + +`ptr` [IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
+Pointer to a null-terminated UTF-8 string. + +`defaultValue` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+Value to return when the pointer is [IntPtr.Zero](https://learn.microsoft.com/en-us/dotnet/api/system.intptr.zero) or when the string is empty. + +#### Returns + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+Managed string representation of the native data, or `defaultValue` when unavailable. + +### **PtrToString(IntPtr)** + +Converts a pointer to a null-terminated UTF-8 string into a managed string. + +```csharp +public static string? PtrToString(IntPtr ptr) +``` + +#### Parameters + +`ptr` [IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
+Pointer to the first byte of a null-terminated UTF-8 string. + +#### Returns + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)?
+Managed string representation, or `null` when the pointer is zero or the string is empty. + +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.extensions.spannormalizationextensions.md b/docs/xmldocs/llama.extensions.spannormalizationextensions.md index c7f7bf081..5a5076112 100644 --- a/docs/xmldocs/llama.extensions.spannormalizationextensions.md +++ b/docs/xmldocs/llama.extensions.spannormalizationextensions.md @@ -12,8 +12,8 @@ Extensions to span which apply in-place normalization public static class SpanNormalizationExtensions ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [SpanNormalizationExtensions](./llama.extensions.spannormalizationextensions.md)
-Attributes [ExtensionAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.extensionattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [SpanNormalizationExtensions](./llama.extensions.spannormalizationextensions.md)
+Attributes [ExtensionAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.extensionattribute) ## Methods @@ -27,11 +27,11 @@ public static Single[] MaxAbsoluteNormalization(Single[] vector) #### Parameters -`vector` [Single[]](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`vector` [Single[]](https://learn.microsoft.com/en-us/dotnet/api/system.single)
#### Returns -[Single[]](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+[Single[]](https://learn.microsoft.com/en-us/dotnet/api/system.single)
The same array ### **MaxAbsoluteNormalization(Span<Single>)** @@ -44,11 +44,11 @@ public static Span MaxAbsoluteNormalization(Span vector) #### Parameters -`vector` [Span<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1)
+`vector` [Span<Single>](https://learn.microsoft.com/en-us/dotnet/api/system.span-1)
#### Returns -[Span<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1)
+[Span<Single>](https://learn.microsoft.com/en-us/dotnet/api/system.span-1)
The same span ### **TaxicabNormalization(Single[])** @@ -61,11 +61,11 @@ public static Single[] TaxicabNormalization(Single[] vector) #### Parameters -`vector` [Single[]](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`vector` [Single[]](https://learn.microsoft.com/en-us/dotnet/api/system.single)
#### Returns -[Single[]](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+[Single[]](https://learn.microsoft.com/en-us/dotnet/api/system.single)
The same array **Remarks:** @@ -82,11 +82,11 @@ public static Span TaxicabNormalization(Span vector) #### Parameters -`vector` [Span<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1)
+`vector` [Span<Single>](https://learn.microsoft.com/en-us/dotnet/api/system.span-1)
#### Returns -[Span<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1)
+[Span<Single>](https://learn.microsoft.com/en-us/dotnet/api/system.span-1)
The same span **Remarks:** @@ -103,11 +103,11 @@ public static Single[] EuclideanNormalization(Single[] vector) #### Parameters -`vector` [Single[]](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`vector` [Single[]](https://learn.microsoft.com/en-us/dotnet/api/system.single)
#### Returns -[Single[]](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+[Single[]](https://learn.microsoft.com/en-us/dotnet/api/system.single)
The same array **Remarks:** @@ -124,11 +124,11 @@ public static Span EuclideanNormalization(Span vector) #### Parameters -`vector` [Span<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1)
+`vector` [Span<Single>](https://learn.microsoft.com/en-us/dotnet/api/system.span-1)
#### Returns -[Span<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1)
+[Span<Single>](https://learn.microsoft.com/en-us/dotnet/api/system.span-1)
The same span **Remarks:** @@ -145,11 +145,11 @@ public static Single[] EuclideanNormalization(ReadOnlySpan vector) #### Parameters -`vector` [ReadOnlySpan<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+`vector` [ReadOnlySpan<Single>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
#### Returns -[Single[]](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+[Single[]](https://learn.microsoft.com/en-us/dotnet/api/system.single)
The same span ### **PNormalization(Single[], Int32)** @@ -166,13 +166,13 @@ public static Single[] PNormalization(Single[] vector, int p) #### Parameters -`vector` [Single[]](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`vector` [Single[]](https://learn.microsoft.com/en-us/dotnet/api/system.single)
-`p` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`p` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
#### Returns -[Single[]](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+[Single[]](https://learn.microsoft.com/en-us/dotnet/api/system.single)
The same array ### **PNormalization(Span<Single>, Int32)** @@ -189,13 +189,13 @@ public static Span PNormalization(Span vector, int p) #### Parameters -`vector` [Span<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1)
+`vector` [Span<Single>](https://learn.microsoft.com/en-us/dotnet/api/system.span-1)
-`p` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`p` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
#### Returns -[Span<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1)
+[Span<Single>](https://learn.microsoft.com/en-us/dotnet/api/system.span-1)
The same span --- diff --git a/docs/xmldocs/llama.instructexecutor.instructexecutorstate.md b/docs/xmldocs/llama.instructexecutor.instructexecutorstate.md new file mode 100644 index 000000000..9f6186e81 --- /dev/null +++ b/docs/xmldocs/llama.instructexecutor.instructexecutorstate.md @@ -0,0 +1,176 @@ +[`< Back`](./) + +--- + +# InstructExecutorState + +Namespace: LLama + +The descriptor of the state of the instruct executor. + +```csharp +internal class InstructExecutorState : ExecutorBaseState +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ExecutorBaseState](./llama.statefulexecutorbase.executorbasestate.md) → [InstructExecutorState](./llama.instructexecutor.instructexecutorstate.md)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute), [JsonConverterAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.serialization.jsonconverterattribute) + +## Properties + +### **IsPromptRun** + +Whether the executor is running for the first time (running the prompt). + +```csharp +public bool IsPromptRun { get; set; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **InputPrefixTokens** + +Instruction prefix tokens. + +```csharp +public LLamaToken[]? InputPrefixTokens { get; set; } +``` + +#### Property Value + +[LLamaToken[]](./llama.native.llamatoken.md)
+ +### **InputSuffixTokens** + +Instruction suffix tokens. + +```csharp +public LLamaToken[]? InputSuffixTokens { get; set; } +``` + +#### Property Value + +[LLamaToken[]](./llama.native.llamatoken.md)
+ +### **PastTokensCount** + +```csharp +public int PastTokensCount { get; set; } +``` + +#### Property Value + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **ConsumedTokensCount** + +```csharp +public int ConsumedTokensCount { get; set; } +``` + +#### Property Value + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **ConsumedSessionCount** + +```csharp +public int ConsumedSessionCount { get; set; } +``` + +#### Property Value + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **MatchingSessionTokensCount** + +```csharp +public int MatchingSessionTokensCount { get; set; } +``` + +#### Property Value + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **SessionFilePath** + +```csharp +public string? SessionFilePath { get; set; } +``` + +#### Property Value + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **Embeds** + +```csharp +public LLamaToken[] Embeds { get; set; } +``` + +#### Property Value + +[LLamaToken[]](./llama.native.llamatoken.md)
+ +### **EmbedInps** + +```csharp +public LLamaToken[] EmbedInps { get; set; } +``` + +#### Property Value + +[LLamaToken[]](./llama.native.llamatoken.md)
+ +### **SessionTokens** + +```csharp +public LLamaToken[] SessionTokens { get; set; } +``` + +#### Property Value + +[LLamaToken[]](./llama.native.llamatoken.md)
+ +### **LastTokens** + +```csharp +public LLamaToken[] LastTokens { get; set; } +``` + +#### Property Value + +[LLamaToken[]](./llama.native.llamatoken.md)
+ +### **LastTokensCapacity** + +```csharp +public int LastTokensCapacity { get; set; } +``` + +#### Property Value + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **MirostatMu** + +```csharp +public float? MirostatMu { get; set; } +``` + +#### Property Value + +[Single?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
+ +## Constructors + +### **InstructExecutorState()** + +```csharp +public InstructExecutorState() +``` + +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.instructexecutor.md b/docs/xmldocs/llama.instructexecutor.md index 77a3d5ac5..58802af4d 100644 --- a/docs/xmldocs/llama.instructexecutor.md +++ b/docs/xmldocs/llama.instructexecutor.md @@ -12,9 +12,9 @@ The LLama executor for instruct mode. public class InstructExecutor : StatefulExecutorBase, LLama.Abstractions.ILLamaExecutor ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [StatefulExecutorBase](./llama.statefulexecutorbase.md) → [InstructExecutor](./llama.instructexecutor.md)
+Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [StatefulExecutorBase](./llama.statefulexecutorbase.md) → [InstructExecutor](./llama.instructexecutor.md)
Implements [ILLamaExecutor](./llama.abstractions.illamaexecutor.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Fields @@ -22,9 +22,7 @@ Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/ap The logger used by this executor. -```csharp -protected ILogger _logger; -``` +### **_logger** ### **_pastTokensCount** @@ -44,7 +42,7 @@ protected int _consumedTokensCount; ### **_n_session_consumed** - +Number of tokens consumed from the session cache during the current run. ```csharp protected int _n_session_consumed; @@ -52,7 +50,7 @@ protected int _n_session_consumed; ### **_n_matching_session_tokens** - +Number of prompt tokens that match the loaded session cache prefix. ```csharp protected int _n_matching_session_tokens; @@ -63,7 +61,7 @@ protected int _n_matching_session_tokens; The path of the session file. ```csharp -protected string _pathSession; +protected string? _pathSession; ``` ### **_embeds** @@ -84,7 +82,7 @@ protected List _embed_inps; ### **_session_tokens** - +Tokens recovered from the session file and reused to warm up the KV cache. ```csharp protected List _session_tokens; @@ -112,6 +110,18 @@ public LLamaContext Context { get; } [LLamaContext](./llama.llamacontext.md)
+### **AntipromptProcessor** + +Tracks anti-prompts across streamed output. + +```csharp +protected AntipromptProcessor AntipromptProcessor { get; } +``` + +#### Property Value + +[AntipromptProcessor](./llama.antipromptprocessor.md)
+ ### **IsMultiModal** ```csharp @@ -120,163 +130,204 @@ public bool IsMultiModal { get; } #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **ClipModel** ```csharp -public LLavaWeights ClipModel { get; } +public MtmdWeights? ClipModel { get; } ``` #### Property Value -[LLavaWeights](./llama.llavaweights.md)
+[MtmdWeights](./llama.mtmdweights.md)
-### **Images** +### **Embeds** ```csharp -public List Images { get; } +public List Embeds { get; } ``` #### Property Value -[List<Byte[]>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
- -## Constructors - -### **InstructExecutor(LLamaContext, String, String, ILogger)** +[List<SafeMtmdEmbed>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
+### **MtmdChunks** +Pending multimodal chunks produced by the MTMD tokenizer. ```csharp -public InstructExecutor(LLamaContext context, string instructionPrefix, string instructionSuffix, ILogger logger) +protected SafeMtmdInputChunks? MtmdChunks { get; set; } ``` -#### Parameters +#### Property Value -`context` [LLamaContext](./llama.llamacontext.md)
+[SafeMtmdInputChunks](./llama.native.safemtmdinputchunks.md)
-`instructionPrefix` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+## Constructors -`instructionSuffix` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+### **.ctor** -`logger` ILogger
+### **.ctor** ## Methods ### **GetStateData()** +Capture the executor state in a serializable object. + ```csharp -public ExecutorBaseState GetStateData() +public override ExecutorBaseState GetStateData() ``` #### Returns [ExecutorBaseState](./llama.statefulexecutorbase.executorbasestate.md)
+State snapshot suitable for persistence. -### **LoadState(ExecutorBaseState)** +### **LoadState(ExecutorBaseState, CancellationToken)** + +Restore executor state from a previously captured snapshot. ```csharp -public Task LoadState(ExecutorBaseState data) +public override Task LoadState(ExecutorBaseState data, CancellationToken cancellationToken = null) ``` #### Parameters `data` [ExecutorBaseState](./llama.statefulexecutorbase.executorbasestate.md)
+State snapshot created by [StatefulExecutorBase.GetStateData()](./llama.statefulexecutorbase.md#getstatedata). + +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
+[Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
-### **SaveState(String)** +### **SaveState(String, CancellationToken)** + +Save the executor state to a serialized snapshot file. ```csharp -public Task SaveState(string filename) +public override async Task SaveState(string filename, CancellationToken cancellationToken = null) ``` #### Parameters -`filename` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`filename` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+Destination file for the serialized state. + +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
+[Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
-### **LoadState(String)** +### **LoadState(String, CancellationToken)** + +Restore executor state from a serialized snapshot file. ```csharp -public Task LoadState(string filename) +public override async Task LoadState(string filename, CancellationToken cancellationToken = null) ``` #### Parameters -`filename` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`filename` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+Path to the snapshot produced by [StatefulExecutorBase.SaveState(String, CancellationToken)](./llama.statefulexecutorbase.md#savestatestring-cancellationtoken). + +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
+[Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
-### **GetLoopCondition(InferStateArgs)** +### **GetLoopCondition(InferStateArgs, CancellationToken)** + +Determine whether the inference loop should continue processing tokens. ```csharp -protected Task GetLoopCondition(InferStateArgs args) +protected override Task GetLoopCondition(InferStateArgs args, CancellationToken cancellationToken) ``` #### Parameters `args` [InferStateArgs](./llama.statefulexecutorbase.inferstateargs.md)
+Mutable state associated with the current inference. + +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task<Boolean>](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+[Task<Boolean>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+`true` to continue generating; otherwise `false`. -### **PreprocessInputs(String, InferStateArgs)** +### **PreprocessInputs(String, InferStateArgs, CancellationToken)** + +Prepare the executor for inference by tokenizing input and updating cached state. ```csharp -protected Task PreprocessInputs(string text, InferStateArgs args) +protected override Task PreprocessInputs(string? text, InferStateArgs args, CancellationToken cancellationToken) ``` #### Parameters -`text` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`text` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)?
+Prompt text to process. `args` [InferStateArgs](./llama.statefulexecutorbase.inferstateargs.md)
+Mutable state associated with the current inference. + +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
+[Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
-### **PostProcess(IInferenceParams, InferStateArgs)** +### **PostProcess(IInferenceParams, InferStateArgs, CancellationToken)** + +Perform any post-processing on the generated tokens. ```csharp -protected Task>> PostProcess(IInferenceParams inferenceParams, InferStateArgs args) +protected override Task<(bool, IReadOnlyList)> PostProcess(IInferenceParams inferenceParams, InferStateArgs args, CancellationToken cancellationToken) ``` #### Parameters `inferenceParams` [IInferenceParams](./llama.abstractions.iinferenceparams.md)
+Parameters controlling sampling. `args` [InferStateArgs](./llama.statefulexecutorbase.inferstateargs.md)
+Mutable state associated with the current inference. + +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task<ValueTuple<Boolean, IReadOnlyList<String>>>](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+[Task<(Boolean, IReadOnlyList<String>)>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+A tuple indicating whether generation should stop and any extra outputs to emit. -### **InferInternal(IInferenceParams, InferStateArgs)** +### **InferInternal(IInferenceParams, InferStateArgs, CancellationToken)** + +Core inference loop that advances the model by one step. ```csharp -protected Task InferInternal(IInferenceParams inferenceParams, InferStateArgs args) +protected override async Task InferInternal(IInferenceParams inferenceParams, InferStateArgs args, CancellationToken cancellationToken) ``` #### Parameters `inferenceParams` [IInferenceParams](./llama.abstractions.iinferenceparams.md)
+Parameters controlling sampling. `args` [InferStateArgs](./llama.statefulexecutorbase.inferstateargs.md)
+Mutable state associated with the current inference. + +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
+[Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
--- diff --git a/docs/xmldocs/llama.interactiveexecutor.interactiveexecutorstate.md b/docs/xmldocs/llama.interactiveexecutor.interactiveexecutorstate.md new file mode 100644 index 000000000..eb271ed49 --- /dev/null +++ b/docs/xmldocs/llama.interactiveexecutor.interactiveexecutorstate.md @@ -0,0 +1,152 @@ +[`< Back`](./) + +--- + +# InteractiveExecutorState + +Namespace: LLama + +Serializable state specific to the interactive executor. + +```csharp +internal class InteractiveExecutorState : ExecutorBaseState +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ExecutorBaseState](./llama.statefulexecutorbase.executorbasestate.md) → [InteractiveExecutorState](./llama.interactiveexecutor.interactiveexecutorstate.md)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [JsonConverterAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.serialization.jsonconverterattribute) + +## Properties + +### **IsPromptRun** + +Whether the executor is running for the first time (running the prompt). + +```csharp +public bool IsPromptRun { get; set; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **PastTokensCount** + +```csharp +public int PastTokensCount { get; set; } +``` + +#### Property Value + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **ConsumedTokensCount** + +```csharp +public int ConsumedTokensCount { get; set; } +``` + +#### Property Value + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **ConsumedSessionCount** + +```csharp +public int ConsumedSessionCount { get; set; } +``` + +#### Property Value + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **MatchingSessionTokensCount** + +```csharp +public int MatchingSessionTokensCount { get; set; } +``` + +#### Property Value + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **SessionFilePath** + +```csharp +public string? SessionFilePath { get; set; } +``` + +#### Property Value + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **Embeds** + +```csharp +public LLamaToken[] Embeds { get; set; } +``` + +#### Property Value + +[LLamaToken[]](./llama.native.llamatoken.md)
+ +### **EmbedInps** + +```csharp +public LLamaToken[] EmbedInps { get; set; } +``` + +#### Property Value + +[LLamaToken[]](./llama.native.llamatoken.md)
+ +### **SessionTokens** + +```csharp +public LLamaToken[] SessionTokens { get; set; } +``` + +#### Property Value + +[LLamaToken[]](./llama.native.llamatoken.md)
+ +### **LastTokens** + +```csharp +public LLamaToken[] LastTokens { get; set; } +``` + +#### Property Value + +[LLamaToken[]](./llama.native.llamatoken.md)
+ +### **LastTokensCapacity** + +```csharp +public int LastTokensCapacity { get; set; } +``` + +#### Property Value + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **MirostatMu** + +```csharp +public float? MirostatMu { get; set; } +``` + +#### Property Value + +[Single?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
+ +## Constructors + +### **InteractiveExecutorState()** + +```csharp +public InteractiveExecutorState() +``` + +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.interactiveexecutor.md b/docs/xmldocs/llama.interactiveexecutor.md index 8230e03c2..def39606e 100644 --- a/docs/xmldocs/llama.interactiveexecutor.md +++ b/docs/xmldocs/llama.interactiveexecutor.md @@ -12,9 +12,9 @@ The LLama executor for interactive mode. public class InteractiveExecutor : StatefulExecutorBase, LLama.Abstractions.ILLamaExecutor ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [StatefulExecutorBase](./llama.statefulexecutorbase.md) → [InteractiveExecutor](./llama.interactiveexecutor.md)
+Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [StatefulExecutorBase](./llama.statefulexecutorbase.md) → [InteractiveExecutor](./llama.interactiveexecutor.md)
Implements [ILLamaExecutor](./llama.abstractions.illamaexecutor.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Fields @@ -22,9 +22,7 @@ Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/ap The logger used by this executor. -```csharp -protected ILogger _logger; -``` +### **_logger** ### **_pastTokensCount** @@ -44,7 +42,7 @@ protected int _consumedTokensCount; ### **_n_session_consumed** - +Number of tokens consumed from the session cache during the current run. ```csharp protected int _n_session_consumed; @@ -52,7 +50,7 @@ protected int _n_session_consumed; ### **_n_matching_session_tokens** - +Number of prompt tokens that match the loaded session cache prefix. ```csharp protected int _n_matching_session_tokens; @@ -63,7 +61,7 @@ protected int _n_matching_session_tokens; The path of the session file. ```csharp -protected string _pathSession; +protected string? _pathSession; ``` ### **_embeds** @@ -84,7 +82,7 @@ protected List _embed_inps; ### **_session_tokens** - +Tokens recovered from the session file and reused to warm up the KV cache. ```csharp protected List _session_tokens; @@ -112,187 +110,224 @@ public LLamaContext Context { get; } [LLamaContext](./llama.llamacontext.md)
-### **IsMultiModal** +### **AntipromptProcessor** + +Tracks anti-prompts across streamed output. ```csharp -public bool IsMultiModal { get; } +protected AntipromptProcessor AntipromptProcessor { get; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[AntipromptProcessor](./llama.antipromptprocessor.md)
-### **ClipModel** +### **IsMultiModal** ```csharp -public LLavaWeights ClipModel { get; } +public bool IsMultiModal { get; } ``` #### Property Value -[LLavaWeights](./llama.llavaweights.md)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
-### **Images** +### **ClipModel** ```csharp -public List Images { get; } +public MtmdWeights? ClipModel { get; } ``` #### Property Value -[List<Byte[]>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
- -## Constructors - -### **InteractiveExecutor(LLamaContext, ILogger)** - +[MtmdWeights](./llama.mtmdweights.md)
+### **Embeds** ```csharp -public InteractiveExecutor(LLamaContext context, ILogger logger) +public List Embeds { get; } ``` -#### Parameters - -`context` [LLamaContext](./llama.llamacontext.md)
- -`logger` ILogger
+#### Property Value -### **InteractiveExecutor(LLamaContext, LLavaWeights, ILogger)** +[List<SafeMtmdEmbed>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
+### **MtmdChunks** +Pending multimodal chunks produced by the MTMD tokenizer. ```csharp -public InteractiveExecutor(LLamaContext context, LLavaWeights clipModel, ILogger logger) +protected SafeMtmdInputChunks? MtmdChunks { get; set; } ``` -#### Parameters +#### Property Value + +[SafeMtmdInputChunks](./llama.native.safemtmdinputchunks.md)
-`context` [LLamaContext](./llama.llamacontext.md)
+## Constructors -`clipModel` [LLavaWeights](./llama.llavaweights.md)
+### **.ctor** -`logger` ILogger
+### **.ctor** ## Methods ### **GetStateData()** +Capture the executor state in a serializable object. + ```csharp -public ExecutorBaseState GetStateData() +public override ExecutorBaseState GetStateData() ``` #### Returns [ExecutorBaseState](./llama.statefulexecutorbase.executorbasestate.md)
+State snapshot suitable for persistence. + +### **LoadState(ExecutorBaseState, CancellationToken)** -### **LoadState(ExecutorBaseState)** +Restore executor state from a previously captured snapshot. ```csharp -public Task LoadState(ExecutorBaseState data) +public override Task LoadState(ExecutorBaseState data, CancellationToken cancellationToken = null) ``` #### Parameters `data` [ExecutorBaseState](./llama.statefulexecutorbase.executorbasestate.md)
+State snapshot created by [StatefulExecutorBase.GetStateData()](./llama.statefulexecutorbase.md#getstatedata). + +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
+[Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
+ +### **SaveState(String, CancellationToken)** -### **SaveState(String)** +Save the executor state to a serialized snapshot file. ```csharp -public Task SaveState(string filename) +public override async Task SaveState(string filename, CancellationToken cancellationToken = null) ``` #### Parameters -`filename` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`filename` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+Destination file for the serialized state. + +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
+[Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
+ +### **LoadState(String, CancellationToken)** -### **LoadState(String)** +Restore executor state from a serialized snapshot file. ```csharp -public Task LoadState(string filename) +public override async Task LoadState(string filename, CancellationToken cancellationToken = null) ``` #### Parameters -`filename` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`filename` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+Path to the snapshot produced by [StatefulExecutorBase.SaveState(String, CancellationToken)](./llama.statefulexecutorbase.md#savestatestring-cancellationtoken). + +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
+[Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
-### **GetLoopCondition(InferStateArgs)** +### **GetLoopCondition(InferStateArgs, CancellationToken)** -Define whether to continue the loop to generate responses. +Decide whether generation should continue for the current iteration. ```csharp -protected Task GetLoopCondition(InferStateArgs args) +protected override Task GetLoopCondition(InferStateArgs args, CancellationToken cancellationToken) ``` #### Parameters `args` [InferStateArgs](./llama.statefulexecutorbase.inferstateargs.md)
+Mutable inference state. + +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task<Boolean>](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+[Task<Boolean>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+`true` to keep generating; otherwise `false`. + +### **PreprocessInputs(String, InferStateArgs, CancellationToken)** -### **PreprocessInputs(String, InferStateArgs)** +Preprocess the incoming prompt or continuation text before inference. ```csharp -protected Task PreprocessInputs(string text, InferStateArgs args) +protected override Task PreprocessInputs(string? text, InferStateArgs args, CancellationToken cancellationToken) ``` #### Parameters -`text` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`text` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)?
+Prompt text or continuation provided by the caller. `args` [InferStateArgs](./llama.statefulexecutorbase.inferstateargs.md)
+Mutable inference state. + +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
+[Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
-### **PostProcess(IInferenceParams, InferStateArgs)** +### **PostProcess(IInferenceParams, InferStateArgs, CancellationToken)** -Return whether to break the generation. +Decide whether generation should stop based on antiprompts, token limits, or end-of-generation markers. ```csharp -protected Task>> PostProcess(IInferenceParams inferenceParams, InferStateArgs args) +protected override Task<(bool, IReadOnlyList)> PostProcess(IInferenceParams inferenceParams, InferStateArgs args, CancellationToken cancellationToken) ``` #### Parameters `inferenceParams` [IInferenceParams](./llama.abstractions.iinferenceparams.md)
+Sampling parameters controlling generation. `args` [InferStateArgs](./llama.statefulexecutorbase.inferstateargs.md)
+Mutable inference state. + +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task<ValueTuple<Boolean, IReadOnlyList<String>>>](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+[Task<(Boolean, IReadOnlyList<String>)>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+Tuple describing whether to stop and any additional outputs to emit. -### **InferInternal(IInferenceParams, InferStateArgs)** +### **InferInternal(IInferenceParams, InferStateArgs, CancellationToken)** + +Core inference loop that advances the model by one step. ```csharp -protected Task InferInternal(IInferenceParams inferenceParams, InferStateArgs args) +protected override async Task InferInternal(IInferenceParams inferenceParams, InferStateArgs args, CancellationToken cancellationToken) ``` #### Parameters `inferenceParams` [IInferenceParams](./llama.abstractions.iinferenceparams.md)
+Parameters controlling sampling. `args` [InferStateArgs](./llama.statefulexecutorbase.inferstateargs.md)
+Mutable state associated with the current inference. + +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
+[Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
--- diff --git a/docs/xmldocs/llama.llamacontext.md b/docs/xmldocs/llama.llamacontext.md index 8f1f2cd62..bf9569782 100644 --- a/docs/xmldocs/llama.llamacontext.md +++ b/docs/xmldocs/llama.llamacontext.md @@ -12,9 +12,9 @@ A llama_context, which holds all the context required to interact with a model public sealed class LLamaContext : System.IDisposable ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [LLamaContext](./llama.llamacontext.md)
-Implements [IDisposable](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [LLamaContext](./llama.llamacontext.md)
+Implements [IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties @@ -28,7 +28,7 @@ public uint ContextSize { get; } #### Property Value -[UInt32](https://docs.microsoft.com/en-us/dotnet/api/system.uint32)
+[UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
### **EmbeddingSize** @@ -40,7 +40,7 @@ public int EmbeddingSize { get; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **Params** @@ -80,7 +80,7 @@ public Encoding Encoding { get; } #### Property Value -[Encoding](https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding)
+[Encoding](https://learn.microsoft.com/en-us/dotnet/api/system.text.encoding)
### **GenerationThreads** @@ -92,7 +92,7 @@ public int GenerationThreads { get; set; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **BatchThreads** @@ -104,7 +104,7 @@ public int BatchThreads { get; set; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **BatchSize** @@ -116,7 +116,7 @@ public uint BatchSize { get; } #### Property Value -[UInt32](https://docs.microsoft.com/en-us/dotnet/api/system.uint32)
+[UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
### **Vocab** @@ -132,25 +132,7 @@ public Vocabulary Vocab { get; } ## Constructors -### **LLamaContext(LLamaWeights, IContextParams, ILogger)** - -Create a new LLamaContext for the given LLamaWeights - -```csharp -public LLamaContext(LLamaWeights model, IContextParams params, ILogger logger) -``` - -#### Parameters - -`model` [LLamaWeights](./llama.llamaweights.md)
- -`params` [IContextParams](./llama.abstractions.icontextparams.md)
- -`logger` ILogger
- -#### Exceptions - -[ObjectDisposedException](https://docs.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
+### **.ctor** ## Methods @@ -159,17 +141,17 @@ public LLamaContext(LLamaWeights model, IContextParams params, ILogger logger) Tokenize a string. ```csharp -public LLamaToken[] Tokenize(string text, bool addBos, bool special) +public LLamaToken[] Tokenize(string text, bool addBos = true, bool special = false) ``` #### Parameters -`text` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`text` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
-`addBos` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`addBos` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
Whether to add a bos to the text. -`special` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`special` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
Allow tokenizing special and/or control tokens which otherwise are not exposed and treated as plaintext. #### Returns @@ -192,11 +174,11 @@ public string DeTokenize(IReadOnlyList tokens) #### Parameters -`tokens` [IReadOnlyList<LLamaToken>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ireadonlylist-1)
+`tokens` [IReadOnlyList<LLamaToken>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ireadonlylist-1)
#### Returns -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **SaveState(String)** @@ -208,7 +190,7 @@ public void SaveState(string filename) #### Parameters -`filename` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`filename` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **SaveState(String, LLamaSeqId)** @@ -220,7 +202,7 @@ public void SaveState(string filename, LLamaSeqId sequence) #### Parameters -`filename` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`filename` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
`sequence` [LLamaSeqId](./llama.native.llamaseqid.md)
@@ -270,7 +252,7 @@ public void LoadState(string filename) #### Parameters -`filename` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`filename` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **LoadState(String, LLamaSeqId)** @@ -282,7 +264,7 @@ public void LoadState(string filename, LLamaSeqId sequence) #### Parameters -`filename` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`filename` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
`sequence` [LLamaSeqId](./llama.native.llamaseqid.md)
@@ -333,18 +315,18 @@ public EncodeResult Encode(LLamaBatch batch) ```csharp -public Task EncodeAsync(LLamaBatch batch, CancellationToken cancellationToken) +public Task EncodeAsync(LLamaBatch batch, CancellationToken cancellationToken = null) ``` #### Parameters `batch` [LLamaBatch](./llama.native.llamabatch.md)
-`cancellationToken` [CancellationToken](https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
+`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task<EncodeResult>](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+[Task<EncodeResult>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
### **Decode(LLamaBatch)** @@ -367,18 +349,18 @@ public DecodeResult Decode(LLamaBatch batch) ```csharp -public Task DecodeAsync(LLamaBatch batch, CancellationToken cancellationToken) +public Task DecodeAsync(LLamaBatch batch, CancellationToken cancellationToken = null) ``` #### Parameters `batch` [LLamaBatch](./llama.native.llamabatch.md)
-`cancellationToken` [CancellationToken](https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
+`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task<DecodeResult>](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+[Task<DecodeResult>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
### **Decode(LLamaBatchEmbeddings)** @@ -401,40 +383,42 @@ public DecodeResult Decode(LLamaBatchEmbeddings batch) ```csharp -public Task DecodeAsync(LLamaBatchEmbeddings batch, CancellationToken cancellationToken) +public Task DecodeAsync(LLamaBatchEmbeddings batch, CancellationToken cancellationToken = null) ``` #### Parameters `batch` [LLamaBatchEmbeddings](./llama.native.llamabatchembeddings.md)
-`cancellationToken` [CancellationToken](https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
+`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task<DecodeResult>](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+[Task<DecodeResult>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
-### **DecodeAsync(List<LLamaToken>, LLamaSeqId, LLamaBatch, Int32)** +### **DecodeAsync(List<LLamaToken>, LLamaSeqId, LLamaBatch, Int32, CancellationToken)** ```csharp -public Task> DecodeAsync(List tokens, LLamaSeqId id, LLamaBatch batch, int n_past) +public Task<(DecodeResult, int, int)> DecodeAsync(List tokens, LLamaSeqId id, LLamaBatch batch, int n_past, CancellationToken cancellationToken = null) ``` #### Parameters -`tokens` [List<LLamaToken>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
+`tokens` [List<LLamaToken>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
`id` [LLamaSeqId](./llama.native.llamaseqid.md)
`batch` [LLamaBatch](./llama.native.llamabatch.md)
-`n_past` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`n_past` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task<ValueTuple<DecodeResult, Int32, Int32>>](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+[Task<(DecodeResult, Int32, Int32)>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
A tuple, containing the decode result, the number of tokens that have not been decoded yet and the total number of tokens that have been decoded. ### **Dispose()** diff --git a/docs/xmldocs/llama.llamacontext.sequencestate.md b/docs/xmldocs/llama.llamacontext.sequencestate.md new file mode 100644 index 000000000..500a810cb --- /dev/null +++ b/docs/xmldocs/llama.llamacontext.sequencestate.md @@ -0,0 +1,99 @@ +[`< Back`](./) + +--- + +# SequenceState + +Namespace: LLama + +The state of a single sequence, which can be reloaded later + +```csharp +internal class SequenceState : LLama.Native.SafeLLamaHandleBase, System.IDisposable +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [CriticalFinalizerObject](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.constrainedexecution.criticalfinalizerobject) → [SafeHandle](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.safehandle) → [SafeLLamaHandleBase](./llama.native.safellamahandlebase.md) → [SequenceState](./llama.llamacontext.sequencestate.md)
+Implements [IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute) + +## Fields + +### **handle** + +```csharp +protected IntPtr handle; +``` + +## Properties + +### **Size** + +Get the size in bytes of this state object + +```csharp +public UIntPtr Size { get; } +``` + +#### Property Value + +[UIntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.uintptr)
+ +### **IsInvalid** + +```csharp +public override bool IsInvalid { get; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **IsClosed** + +```csharp +public bool IsClosed { get; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +## Methods + +### **ReleaseHandle()** + +```csharp +protected override bool ReleaseHandle() +``` + +#### Returns + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **CopyTo(Byte*, UInt64, UInt64)** + +Copy bytes to a destination pointer. + +```csharp +public ulong CopyTo(Byte* dst, ulong length, ulong offset = 0) +``` + +#### Parameters + +`dst` [Byte*](https://learn.microsoft.com/en-us/dotnet/api/system.byte*)
+Destination to write to + +`length` [UInt64](https://learn.microsoft.com/en-us/dotnet/api/system.uint64)
+Length of the destination buffer + +`offset` [UInt64](https://learn.microsoft.com/en-us/dotnet/api/system.uint64)
+Offset from start of src to start copying from + +#### Returns + +[UInt64](https://learn.microsoft.com/en-us/dotnet/api/system.uint64)
+Number of bytes written to destination + +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.llamacontext.state.md b/docs/xmldocs/llama.llamacontext.state.md new file mode 100644 index 000000000..d713394e9 --- /dev/null +++ b/docs/xmldocs/llama.llamacontext.state.md @@ -0,0 +1,135 @@ +[`< Back`](./) + +--- + +# State + +Namespace: LLama + +The state of this context, which can be reloaded later + +```csharp +internal class State : LLama.Native.SafeLLamaHandleBase, System.IDisposable +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [CriticalFinalizerObject](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.constrainedexecution.criticalfinalizerobject) → [SafeHandle](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.safehandle) → [SafeLLamaHandleBase](./llama.native.safellamahandlebase.md) → [State](./llama.llamacontext.state.md)
+Implements [IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable)
+Attributes [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) + +## Fields + +### **handle** + +```csharp +protected IntPtr handle; +``` + +## Properties + +### **Size** + +Get the size in bytes of this state object + +```csharp +public UIntPtr Size { get; } +``` + +#### Property Value + +[UIntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.uintptr)
+ +### **IsInvalid** + +```csharp +public override bool IsInvalid { get; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **IsClosed** + +```csharp +public bool IsClosed { get; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +## Methods + +### **ReleaseHandle()** + +```csharp +protected override bool ReleaseHandle() +``` + +#### Returns + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **SaveAsync(Stream)** + +Write all the bytes of this state to the given stream + +```csharp +public async Task SaveAsync(Stream stream) +``` + +#### Parameters + +`stream` [Stream](https://learn.microsoft.com/en-us/dotnet/api/system.io.stream)
+ +#### Returns + +[Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
+ +### **Save(Stream)** + +Write all the bytes of this state to the given stream + +```csharp +public void Save(Stream stream) +``` + +#### Parameters + +`stream` [Stream](https://learn.microsoft.com/en-us/dotnet/api/system.io.stream)
+ +### **LoadAsync(Stream)** + +Load a state from a stream + +```csharp +public static async Task LoadAsync(Stream stream) +``` + +#### Parameters + +`stream` [Stream](https://learn.microsoft.com/en-us/dotnet/api/system.io.stream)
+ +#### Returns + +[Task<State>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+ +### **Load(Stream)** + +Load a state from a stream + +```csharp +public static State Load(Stream stream) +``` + +#### Parameters + +`stream` [Stream](https://learn.microsoft.com/en-us/dotnet/api/system.io.stream)
+ +#### Returns + +[State](./llama.llamacontext.state.md)
+ +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.llamaembedder.md b/docs/xmldocs/llama.llamaembedder.md deleted file mode 100644 index 8bf2c258a..000000000 --- a/docs/xmldocs/llama.llamaembedder.md +++ /dev/null @@ -1,102 +0,0 @@ -[`< Back`](./) - ---- - -# LLamaEmbedder - -Namespace: LLama - -Generate high dimensional embedding vectors from text - -```csharp -public sealed class LLamaEmbedder : System.IDisposable, Microsoft.Extensions.AI.IEmbeddingGenerator`2[[System.String, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Microsoft.Extensions.AI.Embedding`1[[System.Single, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], Microsoft.Extensions.AI.Abstractions, Version=9.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], Microsoft.Extensions.AI.IEmbeddingGenerator -``` - -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [LLamaEmbedder](./llama.llamaembedder.md)
-Implements [IDisposable](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable), IEmbeddingGenerator<String, Embedding<Single>>, IEmbeddingGenerator
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) - -## Properties - -### **EmbeddingSize** - -Dimension of embedding vectors - -```csharp -public int EmbeddingSize { get; private set; } -``` - -#### Property Value - -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -### **Context** - -LLama Context - -```csharp -public LLamaContext Context { get; private set; } -``` - -#### Property Value - -[LLamaContext](./llama.llamacontext.md)
- -## Constructors - -### **LLamaEmbedder(LLamaWeights, IContextParams, ILogger)** - -Create a new embedder, using the given LLamaWeights - -```csharp -public LLamaEmbedder(LLamaWeights weights, IContextParams params, ILogger logger) -``` - -#### Parameters - -`weights` [LLamaWeights](./llama.llamaweights.md)
- -`params` [IContextParams](./llama.abstractions.icontextparams.md)
- -`logger` ILogger
- -## Methods - -### **Dispose()** - -```csharp -public void Dispose() -``` - -### **GetEmbeddings(String, CancellationToken)** - -Get high dimensional embedding vectors for the given text. Depending on the pooling type used when constructing - this [LLamaEmbedder](./llama.llamaembedder.md) this may return an embedding vector per token, or one single embedding vector for the entire string. - -```csharp -public Task> GetEmbeddings(string input, CancellationToken cancellationToken) -``` - -#### Parameters - -`input` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
- -`cancellationToken` [CancellationToken](https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
- -#### Returns - -[Task<IReadOnlyList<Single[]>>](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
- -#### Exceptions - -[RuntimeError](./llama.exceptions.runtimeerror.md)
- -[NotSupportedException](https://docs.microsoft.com/en-us/dotnet/api/system.notsupportedexception)
- -**Remarks:** - -Embedding vectors are not normalized, consider using one of the extensions in [SpanNormalizationExtensions](./llama.extensions.spannormalizationextensions.md). - ---- - -[`< Back`](./) diff --git a/docs/xmldocs/llama.llamaquantizer.md b/docs/xmldocs/llama.llamaquantizer.md index 4a8756391..bc5f0a8dc 100644 --- a/docs/xmldocs/llama.llamaquantizer.md +++ b/docs/xmldocs/llama.llamaquantizer.md @@ -12,8 +12,8 @@ The quantizer to quantize the model. public static class LLamaQuantizer ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [LLamaQuantizer](./llama.llamaquantizer.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [LLamaQuantizer](./llama.llamaquantizer.md)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Methods @@ -22,70 +22,70 @@ Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/ap Quantize the model. ```csharp -public static bool Quantize(string srcFileName, string dstFilename, LLamaFtype ftype, int nthread, bool allowRequantize, bool quantizeOutputTensor) +public static bool Quantize(string srcFileName, string dstFilename, LLamaFtype ftype, int nthread = -1, bool allowRequantize = true, bool quantizeOutputTensor = false) ``` #### Parameters -`srcFileName` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`srcFileName` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
The model file to be quantized. -`dstFilename` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`dstFilename` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
The path to save the quantized model. `ftype` [LLamaFtype](./llama.native.llamaftype.md)
The type of quantization. -`nthread` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`nthread` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
Thread to be used during the quantization. By default it's the physical core number. -`allowRequantize` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`allowRequantize` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
-`quantizeOutputTensor` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`quantizeOutputTensor` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
#### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
Whether the quantization is successful. #### Exceptions -[ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentexception)
+[ArgumentException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentexception)
### **Quantize(String, String, String, Int32, Boolean, Boolean)** Quantize the model. ```csharp -public static bool Quantize(string srcFileName, string dstFilename, string ftype, int nthread, bool allowRequantize, bool quantizeOutputTensor) +public static bool Quantize(string srcFileName, string dstFilename, string ftype, int nthread = -1, bool allowRequantize = true, bool quantizeOutputTensor = false) ``` #### Parameters -`srcFileName` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`srcFileName` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
The model file to be quantized. -`dstFilename` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`dstFilename` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
The path to save the quantized model. -`ftype` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`ftype` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
The type of quantization. -`nthread` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`nthread` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
Thread to be used during the quantization. By default it's the physical core number. -`allowRequantize` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`allowRequantize` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
-`quantizeOutputTensor` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`quantizeOutputTensor` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
#### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
Whether the quantization is successful. #### Exceptions -[ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentexception)
+[ArgumentException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentexception)
--- diff --git a/docs/xmldocs/llama.llamareranker.md b/docs/xmldocs/llama.llamareranker.md index 00e77dd36..fbd277437 100644 --- a/docs/xmldocs/llama.llamareranker.md +++ b/docs/xmldocs/llama.llamareranker.md @@ -12,9 +12,9 @@ Get rank scores between prompt and documents public sealed class LLamaReranker : System.IDisposable ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [LLamaReranker](./llama.llamareranker.md)
-Implements [IDisposable](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [LLamaReranker](./llama.llamareranker.md)
+Implements [IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties @@ -28,7 +28,7 @@ public int EmbeddingSize { get; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **Context** @@ -44,21 +44,7 @@ public LLamaContext Context { get; } ## Constructors -### **LLamaReranker(LLamaWeights, IContextParams, ILogger)** - -Create a new reranker, using the given LLamaWeights - -```csharp -public LLamaReranker(LLamaWeights weights, IContextParams params, ILogger logger) -``` - -#### Parameters - -`weights` [LLamaWeights](./llama.llamaweights.md)
- -`params` [IContextParams](./llama.abstractions.icontextparams.md)
- -`logger` ILogger
+### **.ctor** ## Methods @@ -73,58 +59,58 @@ public void Dispose() Retrieve relevance scores for input and documents by reranking, execute once. ```csharp -public Task> GetRelevanceScores(string input, IReadOnlyList documents, bool normalize, CancellationToken cancellationToken) +public async Task> GetRelevanceScores(string input, IReadOnlyList documents, bool normalize = false, CancellationToken cancellationToken = null) ``` #### Parameters -`input` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`input` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
-`documents` [IReadOnlyList<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ireadonlylist-1)
+`documents` [IReadOnlyList<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ireadonlylist-1)
-`normalize` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`normalize` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
Whether to normalize the score to the range (0, 1) -`cancellationToken` [CancellationToken](https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
+`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task<IReadOnlyList<Single>>](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+[Task<IReadOnlyList<Single>>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
#### Exceptions [RuntimeError](./llama.exceptions.runtimeerror.md)
-[NotSupportedException](https://docs.microsoft.com/en-us/dotnet/api/system.notsupportedexception)
+[NotSupportedException](https://learn.microsoft.com/en-us/dotnet/api/system.notsupportedexception)
### **GetRelevanceScoreWithTokenCount(String, String, Boolean, CancellationToken)** Retrieve relevance score for input and document by reranking ```csharp -public Task> GetRelevanceScoreWithTokenCount(string input, string document, bool normalize, CancellationToken cancellationToken) +public async Task<(float Score, int Tokens)> GetRelevanceScoreWithTokenCount(string input, string document, bool normalize = false, CancellationToken cancellationToken = null) ``` #### Parameters -`input` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`input` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
-`document` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`document` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
-`normalize` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`normalize` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
Whether to normalize the score to the range (0, 1) -`cancellationToken` [CancellationToken](https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
+`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task<ValueTuple<Single, Int32>>](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+[Task<(Single, Int32)>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
#### Exceptions [RuntimeError](./llama.exceptions.runtimeerror.md)
-[NotSupportedException](https://docs.microsoft.com/en-us/dotnet/api/system.notsupportedexception)
+[NotSupportedException](https://learn.microsoft.com/en-us/dotnet/api/system.notsupportedexception)
--- diff --git a/docs/xmldocs/llama.llamatemplate.md b/docs/xmldocs/llama.llamatemplate.md index e35898bc2..7e0b089da 100644 --- a/docs/xmldocs/llama.llamatemplate.md +++ b/docs/xmldocs/llama.llamatemplate.md @@ -12,8 +12,8 @@ Converts a sequence of messages into text according to a model template public sealed class LLamaTemplate ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [LLamaTemplate](./llama.llamatemplate.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute), [DefaultMemberAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.reflection.defaultmemberattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [LLamaTemplate](./llama.llamatemplate.md)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute), [DefaultMemberAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.reflection.defaultmemberattribute) ## Fields @@ -37,29 +37,35 @@ public int Count { get; private set; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
-### **Item** +### **AddAssistant** + +Whether to end the prompt with the token(s) that indicate the start of an assistant message. ```csharp -public TextMessage Item { get; } +public bool AddAssistant { get; set; } ``` #### Property Value -[TextMessage](./llama.llamatemplate.textmessage.md)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
-### **AddAssistant** +## Indexers -Whether to end the prompt with the token(s) that indicate the start of an assistant message. +### **this[Int32]** ```csharp -public bool AddAssistant { get; set; } +public TextMessage this[int index] { get; } ``` +#### Parameters + +`index` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[TextMessage](./llama.llamatemplate.textmessage.md)
## Constructors @@ -68,7 +74,7 @@ public bool AddAssistant { get; set; } Construct a new template, using the default model template ```csharp -public LLamaTemplate(SafeLlamaModelHandle model, string name, bool strict) +public LLamaTemplate(SafeLlamaModelHandle model, string? name = null, bool strict = true) ``` #### Parameters @@ -76,10 +82,10 @@ public LLamaTemplate(SafeLlamaModelHandle model, string name, bool strict) `model` [SafeLlamaModelHandle](./llama.native.safellamamodelhandle.md)
The native handle of the loaded model. -`name` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`name` [String](https://learn.microsoft.com/en-us/dotnet/api/system.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](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`strict` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
Setting this to true will cause the call to throw if no valid templates are found. ### **LLamaTemplate(LLamaWeights, Boolean)** @@ -87,7 +93,7 @@ Setting this to true will cause the call to throw if no valid templates are foun Construct a new template, using the default model template ```csharp -public LLamaTemplate(LLamaWeights weights, bool strict) +public LLamaTemplate(LLamaWeights weights, bool strict = true) ``` #### Parameters @@ -95,7 +101,7 @@ public LLamaTemplate(LLamaWeights weights, bool strict) `weights` [LLamaWeights](./llama.llamaweights.md)
The handle of the loaded model's weights. -`strict` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`strict` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
Setting this to true will cause the call to throw if no valid templates are found. ### **LLamaTemplate(String)** @@ -103,12 +109,12 @@ Setting this to true will cause the call to throw if no valid templates are foun Construct a new template, using a custom template. ```csharp -public LLamaTemplate(string customTemplate) +public LLamaTemplate(string? customTemplate) ``` #### Parameters -`customTemplate` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`customTemplate` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)?
**Remarks:** @@ -126,9 +132,9 @@ public LLamaTemplate Add(string role, string content) #### Parameters -`role` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`role` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
-`content` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`content` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
#### Returns @@ -162,7 +168,7 @@ public LLamaTemplate RemoveAt(int index) #### Parameters -`index` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`index` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
#### Returns @@ -187,7 +193,7 @@ public ReadOnlySpan Apply() #### Returns -[ReadOnlySpan<Byte>](https://docs.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+[ReadOnlySpan<Byte>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
A span over the buffer that holds the applied template --- diff --git a/docs/xmldocs/llama.llamatemplate.textmessage.md b/docs/xmldocs/llama.llamatemplate.textmessage.md new file mode 100644 index 000000000..ac8844615 --- /dev/null +++ b/docs/xmldocs/llama.llamatemplate.textmessage.md @@ -0,0 +1,62 @@ +[`< Back`](./) + +--- + +# TextMessage + +Namespace: LLama + +A message that has been added to a template + +```csharp +internal readonly struct TextMessage +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [TextMessage](./llama.llamatemplate.textmessage.md)
+Attributes [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute), [IsReadOnlyAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.isreadonlyattribute) + +## Properties + +### **Role** + +The "role" string for this message + +```csharp +public string Role { get; } +``` + +#### Property Value + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **Content** + +The text content of this message + +```csharp +public string Content { get; } +``` + +#### Property Value + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +## Methods + +### **Deconstruct(out String, out String)** + +Deconstruct this message into role and content + +```csharp +public void Deconstruct(out string role, out string content) +``` + +#### Parameters + +`out` `role` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +`out` `content` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.llamatransforms.defaulthistorytransform.md b/docs/xmldocs/llama.llamatransforms.defaulthistorytransform.md new file mode 100644 index 000000000..ae0239e55 --- /dev/null +++ b/docs/xmldocs/llama.llamatransforms.defaulthistorytransform.md @@ -0,0 +1,167 @@ +[`< Back`](./) + +--- + +# DefaultHistoryTransform + +Namespace: LLama + +The default history transform. + Uses plain text with the following format: + [Author]: [Message] + +```csharp +internal class DefaultHistoryTransform : LLama.Abstractions.IHistoryTransform +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [DefaultHistoryTransform](./llama.llamatransforms.defaulthistorytransform.md)
+Implements [IHistoryTransform](./llama.abstractions.ihistorytransform.md)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) + +## Properties + +### **UserName** + +```csharp +public string UserName { get; } +``` + +#### Property Value + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **AssistantName** + +```csharp +public string AssistantName { get; } +``` + +#### Property Value + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **SystemName** + +```csharp +public string SystemName { get; } +``` + +#### Property Value + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **UnknownName** + +```csharp +public string UnknownName { get; } +``` + +#### Property Value + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **IsInstructMode** + +```csharp +public bool IsInstructMode { get; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +## Constructors + +### **DefaultHistoryTransform(String, String, String, String, Boolean)** + + + +```csharp +public DefaultHistoryTransform(string? userName = null, string? assistantName = null, string? systemName = null, string? unknownName = null, bool isInstructMode = false) +``` + +#### Parameters + +`userName` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)?
+ +`assistantName` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)?
+ +`systemName` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)?
+ +`unknownName` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)?
+ +`isInstructMode` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +## Methods + +### **Clone()** + +Copy the transform. + +```csharp +public IHistoryTransform Clone() +``` + +#### Returns + +[IHistoryTransform](./llama.abstractions.ihistorytransform.md)
+ +### **HistoryToText(ChatHistory)** + +Convert a ChatHistory instance to plain text. + +```csharp +public virtual string HistoryToText(ChatHistory history) +``` + +#### Parameters + +`history` [ChatHistory](./llama.common.chathistory.md)
+The ChatHistory instance + +#### Returns + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **TextToHistory(AuthorRole, String)** + +Converts plain text to a ChatHistory instance. + +```csharp +public virtual ChatHistory TextToHistory(AuthorRole role, string text) +``` + +#### Parameters + +`role` [AuthorRole](./llama.common.authorrole.md)
+The role for the author. + +`text` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+The chat history as plain text. + +#### Returns + +[ChatHistory](./llama.common.chathistory.md)
+The updated history. + +### **TrimNamesFromText(String, AuthorRole)** + +Drop the name at the beginning and the end of the text. + +```csharp +public virtual string TrimNamesFromText(string text, AuthorRole role) +``` + +#### Parameters + +`text` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +`role` [AuthorRole](./llama.common.authorrole.md)
+ +#### Returns + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.llamatransforms.emptytextoutputstreamtransform.md b/docs/xmldocs/llama.llamatransforms.emptytextoutputstreamtransform.md new file mode 100644 index 000000000..bd830ac35 --- /dev/null +++ b/docs/xmldocs/llama.llamatransforms.emptytextoutputstreamtransform.md @@ -0,0 +1,58 @@ +[`< Back`](./) + +--- + +# EmptyTextOutputStreamTransform + +Namespace: LLama + +A no-op text input transform. + +```csharp +internal class EmptyTextOutputStreamTransform : LLama.Abstractions.ITextStreamTransform +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [EmptyTextOutputStreamTransform](./llama.llamatransforms.emptytextoutputstreamtransform.md)
+Implements [ITextStreamTransform](./llama.abstractions.itextstreamtransform.md) + +## Constructors + +### **EmptyTextOutputStreamTransform()** + +```csharp +public EmptyTextOutputStreamTransform() +``` + +## Methods + +### **TransformAsync(IAsyncEnumerable<String>)** + +Takes a stream of tokens and transforms them, returning a new stream of tokens asynchronously. + +```csharp +public IAsyncEnumerable TransformAsync(IAsyncEnumerable tokens) +``` + +#### Parameters + +`tokens` [IAsyncEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)
+ +#### Returns + +[IAsyncEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)
+ +### **Clone()** + +Copy the transform. + +```csharp +public ITextStreamTransform Clone() +``` + +#### Returns + +[ITextStreamTransform](./llama.abstractions.itextstreamtransform.md)
+ +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.llamatransforms.keywordtextoutputstreamtransform.md b/docs/xmldocs/llama.llamatransforms.keywordtextoutputstreamtransform.md new file mode 100644 index 000000000..12cb06cc3 --- /dev/null +++ b/docs/xmldocs/llama.llamatransforms.keywordtextoutputstreamtransform.md @@ -0,0 +1,133 @@ +[`< Back`](./) + +--- + +# KeywordTextOutputStreamTransform + +Namespace: LLama + +A text output transform that removes the keywords from the response. + +```csharp +internal class KeywordTextOutputStreamTransform : LLama.Abstractions.ITextStreamTransform +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [KeywordTextOutputStreamTransform](./llama.llamatransforms.keywordtextoutputstreamtransform.md)
+Implements [ITextStreamTransform](./llama.abstractions.itextstreamtransform.md)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) + +## Properties + +### **Keywords** + +Keywords that you want to remove from the response. + This property is used for JSON serialization. + +```csharp +public HashSet Keywords { get; } +``` + +#### Property Value + +[HashSet<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.hashset-1)
+ +### **MaxKeywordLength** + +Maximum length of the keywords. + This property is used for JSON serialization. + +```csharp +public int MaxKeywordLength { get; } +``` + +#### Property Value + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **RemoveAllMatchedTokens** + +If set to true, when getting a matched keyword, all the related tokens will be removed. + Otherwise only the part of keyword will be removed. + This property is used for JSON serialization. + +```csharp +public bool RemoveAllMatchedTokens { get; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +## Constructors + +### **KeywordTextOutputStreamTransform(HashSet<String>, Int32, Boolean)** + +JSON constructor. + +```csharp +public KeywordTextOutputStreamTransform(HashSet keywords, int maxKeywordLength, bool removeAllMatchedTokens) +``` + +#### Parameters + +`keywords` [HashSet<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.hashset-1)
+ +`maxKeywordLength` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +`removeAllMatchedTokens` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **KeywordTextOutputStreamTransform(IEnumerable<String>, Int32, Boolean)** + + + +```csharp +public KeywordTextOutputStreamTransform(IEnumerable keywords, int redundancyLength = 3, bool removeAllMatchedTokens = false) +``` + +#### Parameters + +`keywords` [IEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
+Keywords that you want to remove from the response. + +`redundancyLength` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+The extra length when searching for the keyword. For example, if your only keyword is "highlight", + maybe the token you get is "\r\nhighligt". In this condition, if redundancyLength=0, the token cannot be successfully matched because the length of "\r\nhighligt" (10) + has already exceeded the maximum length of the keywords (8). On the contrary, setting redundancyLengyh >= 2 leads to successful match. + The larger the redundancyLength is, the lower the processing speed. But as an experience, it won't introduce too much performance impact when redundancyLength <= 5 + +`removeAllMatchedTokens` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+If set to true, when getting a matched keyword, all the related tokens will be removed. Otherwise only the part of keyword will be removed. + +## Methods + +### **Clone()** + +Copy the transform. + +```csharp +public ITextStreamTransform Clone() +``` + +#### Returns + +[ITextStreamTransform](./llama.abstractions.itextstreamtransform.md)
+ +### **TransformAsync(IAsyncEnumerable<String>)** + +Takes a stream of tokens and transforms them, returning a new stream of tokens asynchronously. + +```csharp +public IAsyncEnumerable TransformAsync(IAsyncEnumerable tokens) +``` + +#### Parameters + +`tokens` [IAsyncEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)
+ +#### Returns + +[IAsyncEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)
+ +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.llamatransforms.md b/docs/xmldocs/llama.llamatransforms.md index b69b80e1a..2f9f1643f 100644 --- a/docs/xmldocs/llama.llamatransforms.md +++ b/docs/xmldocs/llama.llamatransforms.md @@ -12,7 +12,7 @@ A class that contains all the transforms provided internally by LLama. public class LLamaTransforms ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [LLamaTransforms](./llama.llamatransforms.md) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [LLamaTransforms](./llama.llamatransforms.md) ## Constructors diff --git a/docs/xmldocs/llama.llamatransforms.naivetextinputtransform.md b/docs/xmldocs/llama.llamatransforms.naivetextinputtransform.md new file mode 100644 index 000000000..9e1498e08 --- /dev/null +++ b/docs/xmldocs/llama.llamatransforms.naivetextinputtransform.md @@ -0,0 +1,58 @@ +[`< Back`](./) + +--- + +# NaiveTextInputTransform + +Namespace: LLama + +A text input transform that only trims the text. + +```csharp +internal class NaiveTextInputTransform : LLama.Abstractions.ITextTransform +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [NaiveTextInputTransform](./llama.llamatransforms.naivetextinputtransform.md)
+Implements [ITextTransform](./llama.abstractions.itexttransform.md) + +## Constructors + +### **NaiveTextInputTransform()** + +```csharp +public NaiveTextInputTransform() +``` + +## Methods + +### **Transform(String)** + +Takes a string and transforms it. + +```csharp +public string Transform(string text) +``` + +#### Parameters + +`text` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +#### Returns + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **Clone()** + +Copy the transform. + +```csharp +public ITextTransform Clone() +``` + +#### Returns + +[ITextTransform](./llama.abstractions.itexttransform.md)
+ +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.llamaweights.md b/docs/xmldocs/llama.llamaweights.md index 7ef9fba93..1eff4f572 100644 --- a/docs/xmldocs/llama.llamaweights.md +++ b/docs/xmldocs/llama.llamaweights.md @@ -12,9 +12,9 @@ A set of model weights, loaded into memory. public sealed class LLamaWeights : System.IDisposable ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [LLamaWeights](./llama.llamaweights.md)
-Implements [IDisposable](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [LLamaWeights](./llama.llamaweights.md)
+Implements [IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties @@ -44,7 +44,7 @@ public int ContextSize { get; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **SizeInBytes** @@ -56,7 +56,7 @@ public ulong SizeInBytes { get; } #### Property Value -[UInt64](https://docs.microsoft.com/en-us/dotnet/api/system.uint64)
+[UInt64](https://learn.microsoft.com/en-us/dotnet/api/system.uint64)
### **ParameterCount** @@ -68,7 +68,7 @@ public ulong ParameterCount { get; } #### Property Value -[UInt64](https://docs.microsoft.com/en-us/dotnet/api/system.uint64)
+[UInt64](https://learn.microsoft.com/en-us/dotnet/api/system.uint64)
### **EmbeddingSize** @@ -80,7 +80,7 @@ public int EmbeddingSize { get; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **Vocab** @@ -104,7 +104,7 @@ public IReadOnlyDictionary Metadata { get; set; } #### Property Value -[IReadOnlyDictionary<String, String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ireadonlydictionary-2)
+[IReadOnlyDictionary<String, String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ireadonlydictionary-2)
## Methods @@ -129,7 +129,7 @@ public static LLamaWeights LoadFromFile(IModelParams params) Load weights into memory ```csharp -public static Task LoadFromFileAsync(IModelParams params, CancellationToken token, IProgress progressReporter) +public static async Task LoadFromFileAsync(IModelParams params, CancellationToken token = null, IProgress? progressReporter = null) ``` #### Parameters @@ -137,22 +137,22 @@ public static Task LoadFromFileAsync(IModelParams params, Cancella `params` [IModelParams](./llama.abstractions.imodelparams.md)
Parameters to use to load the model -`token` [CancellationToken](https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
+`token` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
A cancellation token that can interrupt model loading -`progressReporter` [IProgress<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.iprogress-1)
+`progressReporter` [IProgress<Single>](https://learn.microsoft.com/en-us/dotnet/api/system.iprogress-1)?
Receives progress updates as the model loads (0 to 1) #### Returns -[Task<LLamaWeights>](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+[Task<LLamaWeights>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
#### Exceptions [LoadWeightsFailedException](./llama.exceptions.loadweightsfailedexception.md)
Thrown if weights failed to load for any reason. e.g. Invalid file format or loading cancelled. -[OperationCanceledException](https://docs.microsoft.com/en-us/dotnet/api/system.operationcanceledexception)
+[OperationCanceledException](https://learn.microsoft.com/en-us/dotnet/api/system.operationcanceledexception)
Thrown if the cancellation token is cancelled. ### **Dispose()** @@ -161,23 +161,7 @@ Thrown if the cancellation token is cancelled. public void Dispose() ``` -### **CreateContext(IContextParams, ILogger)** - -Create a llama_context using this model - -```csharp -public LLamaContext CreateContext(IContextParams params, ILogger logger) -``` - -#### Parameters - -`params` [IContextParams](./llama.abstractions.icontextparams.md)
- -`logger` ILogger
- -#### Returns - -[LLamaContext](./llama.llamacontext.md)
+### **CreateContext** ### **Tokenize(String, Boolean, Boolean, Encoding)** @@ -189,14 +173,14 @@ public LLamaToken[] Tokenize(string text, bool add_bos, bool special, Encoding e #### Parameters -`text` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`text` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
-`add_bos` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`add_bos` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
-`special` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`special` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
Allow tokenizing special and/or control tokens which otherwise are not exposed and treated as plaintext. -`encoding` [Encoding](https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding)
+`encoding` [Encoding](https://learn.microsoft.com/en-us/dotnet/api/system.text.encoding)
#### Returns diff --git a/docs/xmldocs/llama.llavaweights.md b/docs/xmldocs/llama.llavaweights.md deleted file mode 100644 index 59a44ae29..000000000 --- a/docs/xmldocs/llama.llavaweights.md +++ /dev/null @@ -1,204 +0,0 @@ -[`< Back`](./) - ---- - -# LLavaWeights - -Namespace: LLama - -A set of llava model weights (mmproj), loaded into memory. - -```csharp -public sealed class LLavaWeights : System.IDisposable -``` - -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [LLavaWeights](./llama.llavaweights.md)
-Implements [IDisposable](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) - -## Properties - -### **NativeHandle** - -The native handle, which is used in the native APIs - -```csharp -public SafeLlavaModelHandle NativeHandle { get; } -``` - -#### Property Value - -[SafeLlavaModelHandle](./llama.native.safellavamodelhandle.md)
- -**Remarks:** - -Be careful how you use this! - -## Methods - -### **LoadFromFile(String)** - -Load weights into memory - -```csharp -public static LLavaWeights LoadFromFile(string mmProject) -``` - -#### Parameters - -`mmProject` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
-path to the "mmproj" model file - -#### Returns - -[LLavaWeights](./llama.llavaweights.md)
- -### **LoadFromFileAsync(String, CancellationToken)** - -Load weights into memory - -```csharp -public static Task LoadFromFileAsync(string mmProject, CancellationToken token) -``` - -#### Parameters - -`mmProject` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
-path to the "mmproj" model file - -`token` [CancellationToken](https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
- -#### Returns - -[Task<LLavaWeights>](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
- -### **CreateImageEmbeddings(LLamaContext, Byte[])** - -Create the Image Embeddings from the bytes of an image. - -```csharp -public SafeLlavaImageEmbedHandle CreateImageEmbeddings(LLamaContext ctxLlama, Byte[] image) -``` - -#### Parameters - -`ctxLlama` [LLamaContext](./llama.llamacontext.md)
- -`image` [Byte[]](https://docs.microsoft.com/en-us/dotnet/api/system.byte)
-Image bytes. Supported formats: - -- -- -- -- - -#### Returns - -[SafeLlavaImageEmbedHandle](./llama.native.safellavaimageembedhandle.md)
- -### **CreateImageEmbeddings(Byte[], Int32)** - -Create the Image Embeddings. - -```csharp -public SafeLlavaImageEmbedHandle CreateImageEmbeddings(Byte[] image, int threads) -``` - -#### Parameters - -`image` [Byte[]](https://docs.microsoft.com/en-us/dotnet/api/system.byte)
-Image in binary format (it supports jpeg format only) - -`threads` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
-Number of threads to use - -#### Returns - -[SafeLlavaImageEmbedHandle](./llama.native.safellavaimageembedhandle.md)
-return the SafeHandle of these embeddings - -### **CreateImageEmbeddings(LLamaContext, String)** - -Create the Image Embeddings from the bytes of an image. - -```csharp -public SafeLlavaImageEmbedHandle CreateImageEmbeddings(LLamaContext ctxLlama, string image) -``` - -#### Parameters - -`ctxLlama` [LLamaContext](./llama.llamacontext.md)
- -`image` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
-Path to the image file. Supported formats: - -- -- -- -- - -#### Returns - -[SafeLlavaImageEmbedHandle](./llama.native.safellavaimageembedhandle.md)
- -#### Exceptions - -[InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
- -### **CreateImageEmbeddings(String, Int32)** - -Create the Image Embeddings from the bytes of an image. - -```csharp -public SafeLlavaImageEmbedHandle CreateImageEmbeddings(string image, int threads) -``` - -#### Parameters - -`image` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
-Path to the image file. Supported formats: - -- -- -- -- - -`threads` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -#### Returns - -[SafeLlavaImageEmbedHandle](./llama.native.safellavaimageembedhandle.md)
- -#### Exceptions - -[InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
- -### **EvalImageEmbed(LLamaContext, SafeLlavaImageEmbedHandle, Int32&)** - -Eval the image embeddings - -```csharp -public bool EvalImageEmbed(LLamaContext ctxLlama, SafeLlavaImageEmbedHandle imageEmbed, Int32& n_past) -``` - -#### Parameters - -`ctxLlama` [LLamaContext](./llama.llamacontext.md)
- -`imageEmbed` [SafeLlavaImageEmbedHandle](./llama.native.safellavaimageembedhandle.md)
- -`n_past` [Int32&](https://docs.microsoft.com/en-us/dotnet/api/system.int32&)
- -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -### **Dispose()** - -```csharp -public void Dispose() -``` - ---- - -[`< Back`](./) diff --git a/docs/xmldocs/llama.mtmdweights.md b/docs/xmldocs/llama.mtmdweights.md new file mode 100644 index 000000000..655ce0015 --- /dev/null +++ b/docs/xmldocs/llama.mtmdweights.md @@ -0,0 +1,316 @@ +[`< Back`](./) + +--- + +# MtmdWeights + +Namespace: LLama + +Lightweight wrapper around the MTMD native context and its helpers. + +```csharp +public sealed class MtmdWeights : System.IDisposable +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [MtmdWeights](./llama.mtmdweights.md)
+Implements [IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) + +## Properties + +### **NativeHandle** + +The native handle, which is used in the native APIs + +```csharp +public SafeMtmdModelHandle NativeHandle { get; } +``` + +#### Property Value + +[SafeMtmdModelHandle](./llama.native.safemtmdmodelhandle.md)
+ +**Remarks:** + +Be careful how you use this! + +### **SupportsVision** + +Indicates whether the model supports vision inputs. + +```csharp +public bool SupportsVision { get; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **SupportsAudio** + +Indicates whether the model supports audio inputs. + +```csharp +public bool SupportsAudio { get; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **UsesNonCausalAttention** + +Indicates whether the model decodes using the non-causal path. + +```csharp +public bool UsesNonCausalAttention { get; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **UsesMRope** + +Indicates whether the model decodes using multi-scale RoPE. + +```csharp +public bool UsesMRope { get; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **SampleRate** + +Gets the audio sample rate advertised by the model. + +```csharp +public int SampleRate { get; } +``` + +#### Property Value + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +## Methods + +### **LoadFromFile(String, LLamaWeights, MtmdContextParams)** + +Load weights into memory + +```csharp +public static MtmdWeights LoadFromFile(string mmProject, LLamaWeights textModel, MtmdContextParams mtmdCtxParams) +``` + +#### Parameters + +`mmProject` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+Path to the mmproj file + +`textModel` [LLamaWeights](./llama.llamaweights.md)
+The text model + +`mtmdCtxParams` [MtmdContextParams](./llama.native.mtmdcontextparams.md)
+Parameters for MTMD context creation + +#### Returns + +[MtmdWeights](./llama.mtmdweights.md)
+ +### **LoadFromFileAsync(String, LLamaWeights, MtmdContextParams, CancellationToken)** + +Load weights into memory + +```csharp +public static async Task LoadFromFileAsync(string mmProject, LLamaWeights textModel, MtmdContextParams mtmdCtxParams, CancellationToken token = null) +``` + +#### Parameters + +`mmProject` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+Path to the mmproj file + +`textModel` [LLamaWeights](./llama.llamaweights.md)
+The text model + +`mtmdCtxParams` [MtmdContextParams](./llama.native.mtmdcontextparams.md)
+Parameters for MTMD context creation + +`token` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
+ +#### Returns + +[Task<MtmdWeights>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+ +### **LoadMedia(String)** + +Load media from disk and keep it pending for the next tokenize call. + +```csharp +public SafeMtmdEmbed LoadMedia(string path) +``` + +#### Parameters + +`path` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +#### Returns + +[SafeMtmdEmbed](./llama.native.safemtmdembed.md)
+ +### **LoadMedia(ReadOnlySpan<Byte>)** + +Load media from an in-memory buffer and keep it pending for the next tokenize call. + +```csharp +public SafeMtmdEmbed LoadMedia(ReadOnlySpan data) +``` + +#### Parameters + +`data` [ReadOnlySpan<Byte>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+ +#### Returns + +[SafeMtmdEmbed](./llama.native.safemtmdembed.md)
+ +### **ClearMedia()** + +Clear any pending media buffers before or after tokenization. + +```csharp +public void ClearMedia() +``` + +### **Tokenize(String, Boolean, Boolean, out SafeMtmdInputChunks)** + +Tokenize text (with optional special tokens) against the pending media buffers. + +```csharp +public int Tokenize(string text, bool addSpecial, bool parseSpecial, out SafeMtmdInputChunks chunks) +``` + +#### Parameters + +`text` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +`addSpecial` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +`parseSpecial` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +`out` `chunks` [SafeMtmdInputChunks](./llama.native.safemtmdinputchunks.md)
+ +#### Returns + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **Tokenize(String, Boolean, Boolean, ReadOnlySpan<SafeMtmdEmbed>, out SafeMtmdInputChunks)** + +Tokenize text (with optional special tokens) against explicit media embeddings. + The caller retains ownership of `embeds`. + +```csharp +public int Tokenize(string text, bool addSpecial, bool parseSpecial, ReadOnlySpan embeds, out SafeMtmdInputChunks chunks) +``` + +#### Parameters + +`text` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +`addSpecial` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +`parseSpecial` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +`embeds` [ReadOnlySpan<SafeMtmdEmbed>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+ +`out` `chunks` [SafeMtmdInputChunks](./llama.native.safemtmdinputchunks.md)
+ +#### Returns + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **EvaluateChunks(SafeMtmdInputChunks, SafeLLamaContextHandle, ref Int32, Int32, Int32, Boolean)** + +Evaluate a chunk batch using the helper that performs mtmd encode + llama decode. + +```csharp +public int EvaluateChunks(SafeMtmdInputChunks chunks, SafeLLamaContextHandle llamaContext, ref int nPast, int seqId, int nBatch, bool logitsLast) +``` + +#### Parameters + +`chunks` [SafeMtmdInputChunks](./llama.native.safemtmdinputchunks.md)
+ +`llamaContext` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
+ +`ref` `nPast` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +`seqId` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +`nBatch` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +`logitsLast` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +#### Returns + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **EvaluateChunk(IntPtr, SafeLLamaContextHandle, ref Int32, Int32, Int32, Boolean)** + +```csharp +public int EvaluateChunk(IntPtr chunkPtr, SafeLLamaContextHandle llamaContext, ref int nPast, int seqId, int nBatch, bool logitsLast) +``` + +#### Parameters + +`chunkPtr` [IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
+ +`llamaContext` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
+ +`ref` `nPast` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +`seqId` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +`nBatch` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +`logitsLast` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +#### Returns + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **DecodeImageChunk(IntPtr, SafeLLamaContextHandle, IntPtr, ref Int32, Int32, Int32)** + +```csharp +public int DecodeImageChunk(IntPtr chunkPtr, SafeLLamaContextHandle llamaContext, IntPtr encodedEmbeddings, ref int nPast, int seqId, int nBatch) +``` + +#### Parameters + +`chunkPtr` [IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
+ +`llamaContext` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
+ +`encodedEmbeddings` [IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
+ +`ref` `nPast` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +`seqId` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +`nBatch` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +#### Returns + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **Dispose()** + +```csharp +public void Dispose() +``` + +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.native.avxlevel.md b/docs/xmldocs/llama.native.avxlevel.md index 038681ab2..b2c448671 100644 --- a/docs/xmldocs/llama.native.avxlevel.md +++ b/docs/xmldocs/llama.native.avxlevel.md @@ -12,14 +12,14 @@ Avx support configuration public enum AvxLevel ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://docs.microsoft.com/en-us/dotnet/api/system.enum) → [AvxLevel](./llama.native.avxlevel.md)
-Implements [IComparable](https://docs.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://docs.microsoft.com/en-us/dotnet/api/system.iconvertible) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://learn.microsoft.com/en-us/dotnet/api/system.enum) → [AvxLevel](./llama.native.avxlevel.md)
+Implements [IComparable](https://learn.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://learn.microsoft.com/en-us/dotnet/api/system.iconvertible) ## Fields | Name | Value | Description | | --- | --: | --- | -| None | 0 | No AVX | +| None | 0 | No AVX or SSE4.2. For x86_64 CPUs that only provide SSSE3 / SSE2. | | Avx | 1 | Advanced Vector Extensions (supported by most processors after 2011) | | Avx2 | 2 | AVX2 (supported by most processors after 2013) | | Avx512 | 3 | AVX512 (supported by some processors after 2016, not widely supported) | diff --git a/docs/xmldocs/llama.native.decoderesult.md b/docs/xmldocs/llama.native.decoderesult.md index fe2f0fa4c..c9f60b84d 100644 --- a/docs/xmldocs/llama.native.decoderesult.md +++ b/docs/xmldocs/llama.native.decoderesult.md @@ -12,14 +12,14 @@ Return codes from llama_decode public enum DecodeResult ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://docs.microsoft.com/en-us/dotnet/api/system.enum) → [DecodeResult](./llama.native.decoderesult.md)
-Implements [IComparable](https://docs.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://docs.microsoft.com/en-us/dotnet/api/system.iconvertible) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://learn.microsoft.com/en-us/dotnet/api/system.enum) → [DecodeResult](./llama.native.decoderesult.md)
+Implements [IComparable](https://learn.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://learn.microsoft.com/en-us/dotnet/api/system.iconvertible) ## Fields | Name | Value | Description | | --- | --: | --- | -| Error | -1 | An unspecified error | +| InvalidInputBatch | -1 | Input batch was invalid | | Ok | 0 | Ok. | | NoKvSlot | 1 | Could not find a KV slot for the batch (try reducing the size of the batch or increase the context) | | ComputeAborted | 2 | Compute was aborted (e.g. due to callback request or timeout) | diff --git a/docs/xmldocs/llama.native.defaultnativelibraryselectingpolicy.md b/docs/xmldocs/llama.native.defaultnativelibraryselectingpolicy.md index e290485de..2398d7980 100644 --- a/docs/xmldocs/llama.native.defaultnativelibraryselectingpolicy.md +++ b/docs/xmldocs/llama.native.defaultnativelibraryselectingpolicy.md @@ -6,11 +6,13 @@ Namespace: LLama.Native +Decides the selected native library that should be loaded according to the configurations. + ```csharp public class DefaultNativeLibrarySelectingPolicy : LLama.Abstractions.INativeLibrarySelectingPolicy ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [DefaultNativeLibrarySelectingPolicy](./llama.native.defaultnativelibraryselectingpolicy.md)
+Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [DefaultNativeLibrarySelectingPolicy](./llama.native.defaultnativelibraryselectingpolicy.md)
Implements [INativeLibrarySelectingPolicy](./llama.abstractions.inativelibraryselectingpolicy.md) ## Constructors @@ -25,8 +27,10 @@ public DefaultNativeLibrarySelectingPolicy() ### **Apply(Description, SystemInfo, LLamaLogCallback)** +Select the native library. + ```csharp -public IEnumerable Apply(Description description, SystemInfo systemInfo, LLamaLogCallback logCallback) +public IEnumerable Apply(Description description, SystemInfo systemInfo, LLamaLogCallback? logCallback) ``` #### Parameters @@ -34,12 +38,15 @@ public IEnumerable Apply(Description description, SystemInfo sys `description` [Description](./llama.native.nativelibraryconfig.description.md)
`systemInfo` [SystemInfo](./llama.native.systeminfo.md)
+The system information of the current machine. -`logCallback` [LLamaLogCallback](./llama.native.nativelogconfig.llamalogcallback.md)
+`logCallback` [LLamaLogCallback](./llama.native.nativelogconfig.llamalogcallback.md)?
+The log callback. #### Returns -[IEnumerable<INativeLibrary>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
+[IEnumerable<INativeLibrary>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
+The information of the selected native library files, in order by priority from the beginning to the end. --- diff --git a/docs/xmldocs/llama.native.encoderesult.md b/docs/xmldocs/llama.native.encoderesult.md index 9106a5dcf..3eb6bdc44 100644 --- a/docs/xmldocs/llama.native.encoderesult.md +++ b/docs/xmldocs/llama.native.encoderesult.md @@ -12,8 +12,8 @@ Return codes from llama_encode public enum EncodeResult ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://docs.microsoft.com/en-us/dotnet/api/system.enum) → [EncodeResult](./llama.native.encoderesult.md)
-Implements [IComparable](https://docs.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://docs.microsoft.com/en-us/dotnet/api/system.iconvertible) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://learn.microsoft.com/en-us/dotnet/api/system.enum) → [EncodeResult](./llama.native.encoderesult.md)
+Implements [IComparable](https://learn.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://learn.microsoft.com/en-us/dotnet/api/system.iconvertible) ## Fields diff --git a/docs/xmldocs/llama.native.ggmltype.md b/docs/xmldocs/llama.native.ggmltype.md index cd8361bc0..39a521be8 100644 --- a/docs/xmldocs/llama.native.ggmltype.md +++ b/docs/xmldocs/llama.native.ggmltype.md @@ -12,8 +12,8 @@ Possible GGML quantisation types public enum GGMLType ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://docs.microsoft.com/en-us/dotnet/api/system.enum) → [GGMLType](./llama.native.ggmltype.md)
-Implements [IComparable](https://docs.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://docs.microsoft.com/en-us/dotnet/api/system.iconvertible) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://learn.microsoft.com/en-us/dotnet/api/system.enum) → [GGMLType](./llama.native.ggmltype.md)
+Implements [IComparable](https://learn.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://learn.microsoft.com/en-us/dotnet/api/system.iconvertible) ## Fields diff --git a/docs/xmldocs/llama.native.gpusplitmode.md b/docs/xmldocs/llama.native.gpusplitmode.md index c7f384cb9..9b8c34871 100644 --- a/docs/xmldocs/llama.native.gpusplitmode.md +++ b/docs/xmldocs/llama.native.gpusplitmode.md @@ -12,8 +12,8 @@ Namespace: LLama.Native public enum GPUSplitMode ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://docs.microsoft.com/en-us/dotnet/api/system.enum) → [GPUSplitMode](./llama.native.gpusplitmode.md)
-Implements [IComparable](https://docs.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://docs.microsoft.com/en-us/dotnet/api/system.iconvertible) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://learn.microsoft.com/en-us/dotnet/api/system.enum) → [GPUSplitMode](./llama.native.gpusplitmode.md)
+Implements [IComparable](https://learn.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://learn.microsoft.com/en-us/dotnet/api/system.iconvertible) **Remarks:** @@ -26,6 +26,7 @@ llama_split_mode | None | 0 | Single GPU | | Layer | 1 | Split layers and KV across GPUs | | Row | 2 | split layers and KV across GPUs, use tensor parallelism if supported | +| Tensor | 3 | | --- diff --git a/docs/xmldocs/llama.native.icustomsampler.md b/docs/xmldocs/llama.native.icustomsampler.md index 717c3f598..cc0214d6f 100644 --- a/docs/xmldocs/llama.native.icustomsampler.md +++ b/docs/xmldocs/llama.native.icustomsampler.md @@ -12,8 +12,8 @@ A custom sampler stage for modifying logits or selecting a token public interface ICustomSampler : System.IDisposable ``` -Implements [IDisposable](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute) +Implements [IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute) ## Properties @@ -22,28 +22,28 @@ Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/ap The human readable name of this stage ```csharp -public abstract string Name { get; } +string Name { get; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
## Methods -### **Apply(LLamaTokenDataArrayNative&)** +### **Apply(ref LLamaTokenDataArrayNative)** Apply this stage to a set of logits. This can modify logits or select a token (or both). If logits are modified the Sorted flag must be set to false. ```csharp -void Apply(LLamaTokenDataArrayNative& tokenData) +void Apply(ref LLamaTokenDataArrayNative tokenData) ``` #### Parameters -`tokenData` [LLamaTokenDataArrayNative&](./llama.native.llamatokendataarraynative&.md)
+`ref` `tokenData` [LLamaTokenDataArrayNative](./llama.native.llamatokendataarraynative.md)
**Remarks:** diff --git a/docs/xmldocs/llama.native.llamaattentiontype.md b/docs/xmldocs/llama.native.llamaattentiontype.md index 9d26960d4..2a5c1e44b 100644 --- a/docs/xmldocs/llama.native.llamaattentiontype.md +++ b/docs/xmldocs/llama.native.llamaattentiontype.md @@ -12,8 +12,8 @@ Namespace: LLama.Native public enum LLamaAttentionType ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://docs.microsoft.com/en-us/dotnet/api/system.enum) → [LLamaAttentionType](./llama.native.llamaattentiontype.md)
-Implements [IComparable](https://docs.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://docs.microsoft.com/en-us/dotnet/api/system.iconvertible) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://learn.microsoft.com/en-us/dotnet/api/system.enum) → [LLamaAttentionType](./llama.native.llamaattentiontype.md)
+Implements [IComparable](https://learn.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://learn.microsoft.com/en-us/dotnet/api/system.iconvertible) **Remarks:** diff --git a/docs/xmldocs/llama.native.llamabatch.md b/docs/xmldocs/llama.native.llamabatch.md index e37e681fd..1a35fc980 100644 --- a/docs/xmldocs/llama.native.llamabatch.md +++ b/docs/xmldocs/llama.native.llamabatch.md @@ -12,8 +12,8 @@ A batch allows submitting multiple tokens to multiple sequences simultaneously public class LLamaBatch ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [LLamaBatch](./llama.native.llamabatch.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [LLamaBatch](./llama.native.llamabatch.md)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties @@ -27,7 +27,7 @@ public int TokenCount { get; private set; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **SequenceCapacity** @@ -39,7 +39,7 @@ public int SequenceCapacity { get; private set; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
## Constructors @@ -69,14 +69,14 @@ The token to add `pos` [LLamaPos](./llama.native.llamapos.md)
The position to add it att -`sequences` [ReadOnlySpan<LLamaSeqId>](https://docs.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+`sequences` [ReadOnlySpan<LLamaSeqId>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
The set of sequences to add this token to -`logits` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`logits` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
#### Returns -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
The index that the token was added at. Use this for GetLogitsIth **Remarks:** @@ -99,14 +99,14 @@ The token to add `pos` [LLamaPos](./llama.native.llamapos.md)
The position to add it att -`sequences` [List<LLamaSeqId>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
+`sequences` [List<LLamaSeqId>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
The set of sequences to add this token to -`logits` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`logits` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
#### Returns -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
The index that the token was added at. Use this for GetLogitsIth **Remarks:** @@ -132,11 +132,11 @@ The position to add it att `sequence` [LLamaSeqId](./llama.native.llamaseqid.md)
The sequence to add this token to -`logits` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`logits` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
#### Returns -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
The index that the token was added at. Use this for GetLogitsIth **Remarks:** @@ -153,7 +153,7 @@ public int AddRange(ReadOnlySpan tokens, LLamaPos start, LLamaSeqId #### Parameters -`tokens` [ReadOnlySpan<LLamaToken>](https://docs.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+`tokens` [ReadOnlySpan<LLamaToken>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
The tokens to add `start` [LLamaPos](./llama.native.llamapos.md)
@@ -162,12 +162,12 @@ The starting position to add tokens at `sequence` [LLamaSeqId](./llama.native.llamaseqid.md)
The sequence to add this token to -`logitsLast` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`logitsLast` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
Whether the final token should generate logits #### Returns -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
The index that the final token was added at. Use this for GetLogitsIth ### **Clear()** diff --git a/docs/xmldocs/llama.native.llamabatchembeddings.md b/docs/xmldocs/llama.native.llamabatchembeddings.md index bd6dc673e..2649b1646 100644 --- a/docs/xmldocs/llama.native.llamabatchembeddings.md +++ b/docs/xmldocs/llama.native.llamabatchembeddings.md @@ -12,8 +12,8 @@ An embeddings batch allows submitting embeddings to multiple sequences simultane public class LLamaBatchEmbeddings ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [LLamaBatchEmbeddings](./llama.native.llamabatchembeddings.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [LLamaBatchEmbeddings](./llama.native.llamabatchembeddings.md)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties @@ -27,7 +27,7 @@ public int EmbeddingDimensions { get; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **EmbeddingsCount** @@ -39,7 +39,7 @@ public int EmbeddingsCount { get; private set; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **SequenceCapacity** @@ -51,7 +51,7 @@ public int SequenceCapacity { get; private set; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
## Constructors @@ -65,7 +65,7 @@ public LLamaBatchEmbeddings(int embeddingDimensions) #### Parameters -`embeddingDimensions` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`embeddingDimensions` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
## Methods @@ -79,20 +79,20 @@ public int Add(ReadOnlySpan embedding, LLamaPos pos, ReadOnlySpan +`embedding` [ReadOnlySpan<Single>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
The embedding to add `pos` [LLamaPos](./llama.native.llamapos.md)
The position to add it att -`sequences` [ReadOnlySpan<LLamaSeqId>](https://docs.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+`sequences` [ReadOnlySpan<LLamaSeqId>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
The set of sequences to add this token to -`logits` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`logits` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
#### Returns -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
The index that the token was added at. Use this for GetLogitsIth **Remarks:** @@ -109,17 +109,17 @@ public int Add(ReadOnlySpan embedding, LLamaPos pos, LLamaSeqId sequence, #### Parameters -`embedding` [ReadOnlySpan<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+`embedding` [ReadOnlySpan<Single>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
`pos` [LLamaPos](./llama.native.llamapos.md)
`sequence` [LLamaSeqId](./llama.native.llamaseqid.md)
-`logits` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`logits` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
#### Returns -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
The index that the token was added at. Use this for GetLogitsIth ### **Add<TParam>(TParam, WriteEmbeddingsDelegate<TParam>, LLamaPos, ReadOnlySpan<LLamaSeqId>, Boolean)** @@ -146,15 +146,15 @@ Delegate called once to write data into a span `pos` [LLamaPos](./llama.native.llamapos.md)
Position to write this embedding to -`sequences` [ReadOnlySpan<LLamaSeqId>](https://docs.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+`sequences` [ReadOnlySpan<LLamaSeqId>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
All sequences to assign this embedding to -`logits` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`logits` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
Whether logits should be generated for this embedding #### Returns -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
The index that the token was added at. Use this for GetLogitsIth **Remarks:** @@ -188,12 +188,12 @@ Position to write this embedding to `sequence` [LLamaSeqId](./llama.native.llamaseqid.md)
Sequence to assign this embedding to -`logits` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`logits` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
Whether logits should be generated for this embedding #### Returns -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
The index that the token was added at. Use this for GetLogitsIth **Remarks:** diff --git a/docs/xmldocs/llama.native.llamachatmessage.md b/docs/xmldocs/llama.native.llamachatmessage.md index f89cf7354..1a94f6c9a 100644 --- a/docs/xmldocs/llama.native.llamachatmessage.md +++ b/docs/xmldocs/llama.native.llamachatmessage.md @@ -12,7 +12,7 @@ Namespace: LLama.Native public struct LLamaChatMessage ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaChatMessage](./llama.native.llamachatmessage.md) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaChatMessage](./llama.native.llamachatmessage.md) **Remarks:** diff --git a/docs/xmldocs/llama.native.llamacontextparams.md b/docs/xmldocs/llama.native.llamacontextparams.md index 3be7f1587..5985c9b71 100644 --- a/docs/xmldocs/llama.native.llamacontextparams.md +++ b/docs/xmldocs/llama.native.llamacontextparams.md @@ -12,7 +12,7 @@ A C# representation of the llama.cpp `llama_context_params` struct public struct LLamaContextParams ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaContextParams](./llama.native.llamacontextparams.md) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaContextParams](./llama.native.llamacontextparams.md) **Remarks:** @@ -53,6 +53,22 @@ max number of sequences (i.e. distinct states for recurrent models) public uint n_seq_max; ``` +### **n_rs_seq** + +number of recurrent-state snapshots per seq for rollback (0 = no rollback) [EXPERIMENTAL] + +```csharp +public uint n_rs_seq; +``` + +### **n_outputs_max** + +max outputs in a ubatch (0 = n_batch) + +```csharp +public uint n_outputs_max; +``` + ### **n_threads** number of threads to use for generation @@ -69,6 +85,14 @@ number of threads to use for batch processing public int n_threads_batch; ``` +### **context_type** + +Set the type of context (e.g. MTP) + +```csharp +public LLamaContextType context_type; +``` + ### **rope_scaling_type** RoPE scaling type, from `enum llama_rope_scaling_type` @@ -93,6 +117,14 @@ Attention type to use for embeddings public LLamaAttentionType attention_type; ``` +### **llama_flash_attn_type** + +when to enable Flash Attention + +```csharp +public LLamaFlashAttentionType llama_flash_attn_type; +``` + ### **rope_freq_base** RoPE base frequency, 0 = from model @@ -151,7 +183,7 @@ public uint yarn_orig_ctx; ### **defrag_threshold** -defragment the KV cache if holes/size > defrag_threshold, Set to < 0 to disable (default) +defragment the KV cache if holes/size > defrag_threshold, Set to <= 0 to disable (default) ```csharp public float defrag_threshold; @@ -205,6 +237,31 @@ User data passed into abort_callback public IntPtr abort_callback_user_data; ``` +### **samplers** + +backend sampler chain configuration (sampler chains must remain alive) + +```csharp +public IntPtr samplers; +``` + +### **n_samplers** + +number of sampler entries in [LLamaContextParams.samplers](./llama.native.llamacontextparams.md#samplers) + +```csharp +public UIntPtr n_samplers; +``` + +### **ctx_other** + +a source/target/parent context. + can be utilized in various ways, for example by sharing results or llama_memory between 2 contexts + +```csharp +public IntPtr ctx_other; +``` + ## Properties ### **embeddings** @@ -217,7 +274,7 @@ public bool embeddings { get; set; } #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **offload_kqv** @@ -229,31 +286,60 @@ public bool offload_kqv { get; set; } #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
-### **flash_attention** +### **no_perf** -whether to use flash attention. EXPERIMENTAL +whether to measure performance timings ```csharp -public bool flash_attention { get; set; } +public bool no_perf { get; set; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
-### **no_perf** +### **op_offload** -whether to measure performance timings +offload host tensor operations to device ```csharp -public bool no_perf { get; set; } +public bool op_offload { get; set; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **swa_full** + +use full-size SWA cache (https://github.com/ggml-org/llama.cpp/pull/13194#issuecomment-2868343055) + NOTE: setting to false when n_seq_max > 1 can cause bad performance in some cases + ref: https://github.com/ggml-org/llama.cpp/pull/13845#issuecomment-2924800573 + +```csharp +public bool swa_full { get; set; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **kv_unified** + +use a unified buffer across the input sequences when computing the attention. + try to disable when n_seq_max > 1 for improved performance when the sequences do not share a large prefix +
+ ref: https://github.com/ggml-org/llama.cpp/pull/14363 + +```csharp +public bool kv_unified { get; set; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
## Methods @@ -262,7 +348,7 @@ public bool no_perf { get; set; } Get the default LLamaContextParams ```csharp -LLamaContextParams Default() +public static LLamaContextParams Default() ``` #### Returns diff --git a/docs/xmldocs/llama.native.llamacontexttype.md b/docs/xmldocs/llama.native.llamacontexttype.md new file mode 100644 index 000000000..424431677 --- /dev/null +++ b/docs/xmldocs/llama.native.llamacontexttype.md @@ -0,0 +1,31 @@ +[`< Back`](./) + +--- + +# LLamaContextType + +Namespace: LLama.Native + + + +```csharp +public enum LLamaContextType +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://learn.microsoft.com/en-us/dotnet/api/system.enum) → [LLamaContextType](./llama.native.llamacontexttype.md)
+Implements [IComparable](https://learn.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://learn.microsoft.com/en-us/dotnet/api/system.iconvertible) + +**Remarks:** + +llama_context_type + +## Fields + +| Name | Value | Description | +| --- | --: | --- | +| Default | 0 | Default context type | +| Mtp | 1 | Multi token prediction context | + +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.native.llamaflashattentiontype.md b/docs/xmldocs/llama.native.llamaflashattentiontype.md new file mode 100644 index 000000000..265106bb7 --- /dev/null +++ b/docs/xmldocs/llama.native.llamaflashattentiontype.md @@ -0,0 +1,28 @@ +[`< Back`](./) + +--- + +# LLamaFlashAttentionType + +Namespace: LLama.Native + +flash_attn_type + +```csharp +public enum LLamaFlashAttentionType +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://learn.microsoft.com/en-us/dotnet/api/system.enum) → [LLamaFlashAttentionType](./llama.native.llamaflashattentiontype.md)
+Implements [IComparable](https://learn.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://learn.microsoft.com/en-us/dotnet/api/system.iconvertible) + +## Fields + +| Name | Value | Description | +| --- | --: | --- | +| LLAMA_FLASH_ATTENTION_TYPE_AUTO | -1 | attention type auto | +| LLAMA_FLASH_ATTENTION_TYPE_DISABLED | 0 | attention disabled | +| LLAMA_FLASH_ATTENTION_TYPE_ENABLED | 1 | attention enabled | + +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.native.llamaftype.md b/docs/xmldocs/llama.native.llamaftype.md index 158c2d9fb..82bbc88fa 100644 --- a/docs/xmldocs/llama.native.llamaftype.md +++ b/docs/xmldocs/llama.native.llamaftype.md @@ -12,8 +12,8 @@ Supported model file types public enum LLamaFtype ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://docs.microsoft.com/en-us/dotnet/api/system.enum) → [LLamaFtype](./llama.native.llamaftype.md)
-Implements [IComparable](https://docs.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://docs.microsoft.com/en-us/dotnet/api/system.iconvertible) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://learn.microsoft.com/en-us/dotnet/api/system.enum) → [LLamaFtype](./llama.native.llamaftype.md)
+Implements [IComparable](https://learn.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://learn.microsoft.com/en-us/dotnet/api/system.iconvertible) **Remarks:** @@ -55,6 +55,10 @@ C# representation of llama_ftype | MOSTLY_BF16 | 32 | except 1d tensors | | LLAMA_FTYPE_MOSTLY_TQ1_0 | 36 | except 1d tensors | | LLAMA_FTYPE_MOSTLY_TQ2_0 | 37 | except 1d tensors | +| LLAMA_FTYPE_MOSTLY_MXFP4_MOE | 38 | except 1d tensors | +| LLAMA_FTYPE_MOSTLY_NVFP4 | 39 | Except 1d tensors | +| LLAMA_FTYPE_MOSTLY_Q1_0 | 40 | Except 1d tensors | +| LLAMA_FTYPE_MOSTLY_Q2_0 | 41 | Except 1d tensors | | GUESSED | 1024 | File type was not specified | --- diff --git a/docs/xmldocs/llama.native.llamakvcacheviewsafehandle.md b/docs/xmldocs/llama.native.llamakvcacheviewsafehandle.md deleted file mode 100644 index cd724922e..000000000 --- a/docs/xmldocs/llama.native.llamakvcacheviewsafehandle.md +++ /dev/null @@ -1,215 +0,0 @@ -[`< Back`](./) - ---- - -# LLamaKvCacheViewSafeHandle - -Namespace: LLama.Native - -A safe handle for a LLamaKvCacheView - -```csharp -public sealed class LLamaKvCacheViewSafeHandle : SafeLLamaHandleBase, System.IDisposable -``` - -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [CriticalFinalizerObject](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.constrainedexecution.criticalfinalizerobject) → [SafeHandle](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.safehandle) → [SafeLLamaHandleBase](./llama.native.safellamahandlebase.md) → [LLamaKvCacheViewSafeHandle](./llama.native.llamakvcacheviewsafehandle.md)
-Implements [IDisposable](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) - -## Fields - -### **handle** - -```csharp -protected IntPtr handle; -``` - -## Properties - -### **CellCount** - -Number of KV cache cells. This will be the same as the context size. - -```csharp -public int CellCount { get; } -``` - -#### Property Value - -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -### **TokenCount** - -Get the total number of tokens in the KV cache. - - For example, if there are two populated - cells, the first with 1 sequence id in it and the second with 2 sequence - ids then you'll have 3 tokens. - -```csharp -public int TokenCount { get; } -``` - -#### Property Value - -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -### **MaxSequenceCount** - -Maximum number of sequences visible for a cell. There may be more sequences than this - in reality, this is simply the maximum number this view can see. - -```csharp -public int MaxSequenceCount { get; } -``` - -#### Property Value - -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -### **UsedCellCount** - -Number of populated cache cells - -```csharp -public int UsedCellCount { get; } -``` - -#### Property Value - -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -### **MaxContiguous** - -Maximum contiguous empty slots in the cache. - -```csharp -public int MaxContiguous { get; } -``` - -#### Property Value - -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -### **MaxContiguousIdx** - -Index to the start of the MaxContiguous slot range. Can be negative when cache is full. - -```csharp -public int MaxContiguousIdx { get; } -``` - -#### Property Value - -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -### **IsInvalid** - -```csharp -public bool IsInvalid { get; } -``` - -#### Property Value - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -### **IsClosed** - -```csharp -public bool IsClosed { get; } -``` - -#### Property Value - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -## Methods - -### **Allocate(SafeLLamaContextHandle, Int32)** - -Allocate a new KV cache view which can be used to inspect the KV cache - -```csharp -public static LLamaKvCacheViewSafeHandle Allocate(SafeLLamaContextHandle ctx, int maxSequences) -``` - -#### Parameters - -`ctx` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
- -`maxSequences` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
-The maximum number of sequences visible in this view per cell - -#### Returns - -[LLamaKvCacheViewSafeHandle](./llama.native.llamakvcacheviewsafehandle.md)
- -### **ReleaseHandle()** - -```csharp -protected bool ReleaseHandle() -``` - -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -### **Update()** - -Read the current KV cache state into this view. - -```csharp -public void Update() -``` - -### **GetCell(Int32)** - -Get the cell at the given index - -```csharp -public LLamaPos GetCell(int index) -``` - -#### Parameters - -`index` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
-The index of the cell [0, CellCount) - -#### Returns - -[LLamaPos](./llama.native.llamapos.md)
-Data about the cell at the given index - -#### Exceptions - -[ArgumentOutOfRangeException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentoutofrangeexception)
-Thrown if index is out of range (0 <= index < CellCount) - -### **GetCellSequences(Int32)** - -Get all of the sequences assigned to the cell at the given index. This will contain [LLamaKvCacheViewSafeHandle.MaxSequenceCount](./llama.native.llamakvcacheviewsafehandle.md#maxsequencecount) entries - sequences even if the cell actually has more than that many sequences, allocate a new view with a larger maxSequences parameter - if necessary. Invalid sequences will be negative values. - -```csharp -public Span GetCellSequences(int index) -``` - -#### Parameters - -`index` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
-The index of the cell [0, CellCount) - -#### Returns - -[Span<LLamaSeqId>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1)
-A span containing the sequences assigned to this cell - -#### Exceptions - -[ArgumentOutOfRangeException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentoutofrangeexception)
-Thrown if index is out of range (0 <= index < CellCount) - ---- - -[`< Back`](./) diff --git a/docs/xmldocs/llama.native.llamaloadmode.md b/docs/xmldocs/llama.native.llamaloadmode.md new file mode 100644 index 000000000..de42add25 --- /dev/null +++ b/docs/xmldocs/llama.native.llamaloadmode.md @@ -0,0 +1,34 @@ +[`< Back`](./) + +--- + +# LLamaLoadMode + +Namespace: LLama.Native + + + +```csharp +public enum LLamaLoadMode +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://learn.microsoft.com/en-us/dotnet/api/system.enum) → [LLamaLoadMode](./llama.native.llamaloadmode.md)
+Implements [IComparable](https://learn.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://learn.microsoft.com/en-us/dotnet/api/system.iconvertible) + +**Remarks:** + +llama_load_mode + +## Fields + +| Name | Value | Description | +| --- | --: | --- | +| None | 0 | no special loading mode | +| MemoryMap | 1 | memory map the model | +| MemoryLock | 2 | force system to keep model in RAM rather than swapping or compressing | +| MemoryMapAndLock | 3 | mmap + force system to keep model in RAM rather than swapping or compressing | +| DirectIO | 4 | Use direct I/O if available | + +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.native.llamalogitbias.md b/docs/xmldocs/llama.native.llamalogitbias.md index 103ae37f2..f88d3ccad 100644 --- a/docs/xmldocs/llama.native.llamalogitbias.md +++ b/docs/xmldocs/llama.native.llamalogitbias.md @@ -9,11 +9,11 @@ Namespace: LLama.Native A bias to apply directly to a logit ```csharp -public struct LLamaLogitBias +public record struct LLamaLogitBias ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaLogitBias](./llama.native.llamalogitbias.md)
-Implements [IEquatable<LLamaLogitBias>](https://docs.microsoft.com/en-us/dotnet/api/system.iequatable-1) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaLogitBias](./llama.native.llamalogitbias.md)
+Implements [IEquatable<LLamaLogitBias>](https://learn.microsoft.com/en-us/dotnet/api/system.iequatable-1) ## Fields @@ -33,56 +33,6 @@ The bias to add public float Bias; ``` -## Methods - -### **ToString()** - -```csharp -string ToString() -``` - -#### Returns - -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
- -### **GetHashCode()** - -```csharp -int GetHashCode() -``` - -#### Returns - -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -### **Equals(Object)** - -```csharp -bool Equals(object obj) -``` - -#### Parameters - -`obj` [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object)
- -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -### **Equals(LLamaLogitBias)** - -```csharp -bool Equals(LLamaLogitBias other) -``` - -#### Parameters - -`other` [LLamaLogitBias](./llama.native.llamalogitbias.md)
- -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- --- [`< Back`](./) diff --git a/docs/xmldocs/llama.native.llamaloglevel.md b/docs/xmldocs/llama.native.llamaloglevel.md index 508be4647..d7fc134bf 100644 --- a/docs/xmldocs/llama.native.llamaloglevel.md +++ b/docs/xmldocs/llama.native.llamaloglevel.md @@ -14,8 +14,8 @@ Severity level of a log message. This enum should always be aligned with public enum LLamaLogLevel ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://docs.microsoft.com/en-us/dotnet/api/system.enum) → [LLamaLogLevel](./llama.native.llamaloglevel.md)
-Implements [IComparable](https://docs.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://docs.microsoft.com/en-us/dotnet/api/system.iconvertible) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://learn.microsoft.com/en-us/dotnet/api/system.enum) → [LLamaLogLevel](./llama.native.llamaloglevel.md)
+Implements [IComparable](https://learn.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://learn.microsoft.com/en-us/dotnet/api/system.iconvertible) ## Fields diff --git a/docs/xmldocs/llama.native.llamamodelkvoverridetype.md b/docs/xmldocs/llama.native.llamamodelkvoverridetype.md index 28b970c51..648af7ef0 100644 --- a/docs/xmldocs/llama.native.llamamodelkvoverridetype.md +++ b/docs/xmldocs/llama.native.llamamodelkvoverridetype.md @@ -12,8 +12,8 @@ Specifies what type of value is being overridden by LLamaModelKvOverride public enum LLamaModelKvOverrideType ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://docs.microsoft.com/en-us/dotnet/api/system.enum) → [LLamaModelKvOverrideType](./llama.native.llamamodelkvoverridetype.md)
-Implements [IComparable](https://docs.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://docs.microsoft.com/en-us/dotnet/api/system.iconvertible) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://learn.microsoft.com/en-us/dotnet/api/system.enum) → [LLamaModelKvOverrideType](./llama.native.llamamodelkvoverridetype.md)
+Implements [IComparable](https://learn.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://learn.microsoft.com/en-us/dotnet/api/system.iconvertible) **Remarks:** diff --git a/docs/xmldocs/llama.native.llamamodelmetadataoverride.md b/docs/xmldocs/llama.native.llamamodelmetadataoverride.md index eb652d409..40715a5d4 100644 --- a/docs/xmldocs/llama.native.llamamodelmetadataoverride.md +++ b/docs/xmldocs/llama.native.llamamodelmetadataoverride.md @@ -12,24 +12,24 @@ Override a key/value pair in the llama model metadata (llama_model_kv_override) public struct LLamaModelMetadataOverride ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaModelMetadataOverride](./llama.native.llamamodelmetadataoverride.md) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaModelMetadataOverride](./llama.native.llamamodelmetadataoverride.md) ## Fields -### **key** +### **Tag** -Key to override +Type of value ```csharp -public e__FixedBuffer key; +public LLamaModelKvOverrideType Tag; ``` -### **Tag** +### **key** -Type of value +Key to override ```csharp -public LLamaModelKvOverrideType Tag; +public e__FixedBuffer key; ``` ### **IntValue** diff --git a/docs/xmldocs/llama.native.llamamodelparams.md b/docs/xmldocs/llama.native.llamamodelparams.md index 23465a81e..efe52cea3 100644 --- a/docs/xmldocs/llama.native.llamamodelparams.md +++ b/docs/xmldocs/llama.native.llamamodelparams.md @@ -12,10 +12,19 @@ A C# representation of the llama.cpp `llama_model_params` struct public struct LLamaModelParams ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaModelParams](./llama.native.llamamodelparams.md) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaModelParams](./llama.native.llamamodelparams.md) ## Fields +### **devices** + +NULL-terminated list of devices to use for offloading (if NULL, all available devices are used). + Each element is a `ggml_backend_dev_t` as returned by [NativeApi.ggml_backend_dev_get(UIntPtr)](./llama.native.nativeapi.md#ggml_backend_dev_getuintptr). + +```csharp +public IntPtr* devices; +``` + ### **tensor_buft_overrides** NULL-terminated list of buffer types to use for tensors that match a pattern @@ -40,6 +49,14 @@ how to split the model across multiple GPUs public GPUSplitMode split_mode; ``` +### **load_mode** + +How to load the model + +```csharp +public LLamaLoadMode load_mode; +``` + ### **main_gpu** the GPU that is used for the entire model when split_mode is LLAMA_SPLIT_MODE_NONE @@ -62,7 +79,7 @@ called with a progress value between 0 and 1, pass NULL to disable. If the provi returns true, model loading continues. If it returns false, model loading is immediately aborted. ```csharp -public LlamaProgressCallback progress_callback; +public LlamaProgressCallback? progress_callback; ``` ### **progress_callback_user_data** @@ -93,43 +110,67 @@ public bool vocab_only { get; set; } #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
-### **use_mmap** +### **check_tensors** -use mmap if possible +validate model tensor data ```csharp -public bool use_mmap { get; set; } +public bool check_tensors { get; set; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
-### **use_mlock** +### **use_extra_bufts** -force system to keep model in RAM +use extra buffer types (used for weight repacking) ```csharp -public bool use_mlock { get; set; } +public bool use_extra_bufts { get; set; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
-### **check_tensors** +### **no_host** -validate model tensor data +bypass host buffer allowing extra buffers to be used ```csharp -public bool check_tensors { get; set; } +public bool no_host { get; set; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **no_alloc** + +only load metadata and simulate memory allocations + +```csharp +public bool no_alloc { get; set; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **load_mtp** + +whether to load MTP layers + +```csharp +public bool load_mtp { get; set; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
## Methods @@ -138,7 +179,7 @@ public bool check_tensors { get; set; } Create a LLamaModelParams with default values ```csharp -LLamaModelParams Default() +public static LLamaModelParams Default() ``` #### Returns diff --git a/docs/xmldocs/llama.native.llamamodelquantizeparams.md b/docs/xmldocs/llama.native.llamamodelquantizeparams.md index 439d0b1ee..2311b21d9 100644 --- a/docs/xmldocs/llama.native.llamamodelquantizeparams.md +++ b/docs/xmldocs/llama.native.llamamodelquantizeparams.md @@ -12,7 +12,7 @@ Quantizer parameters used in the native API public struct LLamaModelQuantizeParams ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaModelQuantizeParams](./llama.native.llamamodelquantizeparams.md) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaModelQuantizeParams](./llama.native.llamamodelquantizeparams.md) **Remarks:** @@ -76,6 +76,14 @@ pointer to vector containing tensor types public IntPtr tensor_types; ``` +### **prune_layers** + +Pointer to vector containing layer indices to prune + +```csharp +public IntPtr prune_layers; +``` + ## Properties ### **allow_requantize** @@ -88,7 +96,7 @@ public bool allow_requantize { get; set; } #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **quantize_output_tensor** @@ -100,7 +108,7 @@ public bool quantize_output_tensor { get; set; } #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **only_copy** @@ -112,7 +120,7 @@ public bool only_copy { get; set; } #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **pure** @@ -124,7 +132,7 @@ public bool pure { get; set; } #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **keep_split** @@ -136,7 +144,19 @@ public bool keep_split { get; set; } #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **dry_run** + +calculate and show the final quantization size without performing quantization + +```csharp +public bool dry_run { get; set; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
## Methods @@ -145,7 +165,7 @@ public bool keep_split { get; set; } Create a LLamaModelQuantizeParams with default values ```csharp -LLamaModelQuantizeParams Default() +public static LLamaModelQuantizeParams Default() ``` #### Returns diff --git a/docs/xmldocs/llama.native.llamamodeltensorbufferoverride.md b/docs/xmldocs/llama.native.llamamodeltensorbufferoverride.md index 2b1aa0bc8..94e3e70fe 100644 --- a/docs/xmldocs/llama.native.llamamodeltensorbufferoverride.md +++ b/docs/xmldocs/llama.native.llamamodeltensorbufferoverride.md @@ -13,7 +13,7 @@ Represents a mapping between a tensor name pattern and a backend buffer type
public struct LLamaModelTensorBufferOverride ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaModelTensorBufferOverride](./llama.native.llamamodeltensorbufferoverride.md) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaModelTensorBufferOverride](./llama.native.llamamodeltensorbufferoverride.md) ## Fields diff --git a/docs/xmldocs/llama.native.llamanativebatch.md b/docs/xmldocs/llama.native.llamanativebatch.md index 40187d669..3ed0face8 100644 --- a/docs/xmldocs/llama.native.llamanativebatch.md +++ b/docs/xmldocs/llama.native.llamanativebatch.md @@ -6,7 +6,7 @@ Namespace: LLama.Native -Input data for llama_decode +Input data for llama_encode/llama_decode A llama_batch object can contain input about one or many sequences The provided arrays (i.e. token, embd, pos, etc.) must have size of n_tokens @@ -14,7 +14,7 @@ Input data for llama_decode public struct LLamaNativeBatch ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaNativeBatch](./llama.native.llamanativebatch.md) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaNativeBatch](./llama.native.llamanativebatch.md) ## Fields @@ -45,7 +45,7 @@ public Single* embd; ### **pos** the positions of the respective token in the sequence - (if set to NULL, the token position will be tracked automatically by llama_decode) + (if set to NULL, the token position will be tracked automatically by llama_encode/llama_decode) ```csharp public LLamaPos* pos; @@ -70,8 +70,11 @@ public LLamaSeqId** seq_id; ### **logits** -if zero, the logits for the respective token will not be output - (if set to NULL, only the logits for last token will be returned) +if zero, the logits for the respective token will not be output. + If set to NULL: + +- +- ```csharp public Byte* logits; diff --git a/docs/xmldocs/llama.native.llamaperfcontexttimings.md b/docs/xmldocs/llama.native.llamaperfcontexttimings.md index b964644fe..c264a7d1e 100644 --- a/docs/xmldocs/llama.native.llamaperfcontexttimings.md +++ b/docs/xmldocs/llama.native.llamaperfcontexttimings.md @@ -12,7 +12,7 @@ LLama performance information public struct LLamaPerfContextTimings ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaPerfContextTimings](./llama.native.llamaperfcontexttimings.md) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaPerfContextTimings](./llama.native.llamaperfcontexttimings.md) **Remarks:** @@ -30,7 +30,7 @@ public TimeSpan ResetTimestamp { get; } #### Property Value -[TimeSpan](https://docs.microsoft.com/en-us/dotnet/api/system.timespan)
+[TimeSpan](https://learn.microsoft.com/en-us/dotnet/api/system.timespan)
### **Loading** @@ -42,7 +42,7 @@ public TimeSpan Loading { get; } #### Property Value -[TimeSpan](https://docs.microsoft.com/en-us/dotnet/api/system.timespan)
+[TimeSpan](https://learn.microsoft.com/en-us/dotnet/api/system.timespan)
### **PromptEval** @@ -54,7 +54,7 @@ public TimeSpan PromptEval { get; } #### Property Value -[TimeSpan](https://docs.microsoft.com/en-us/dotnet/api/system.timespan)
+[TimeSpan](https://learn.microsoft.com/en-us/dotnet/api/system.timespan)
### **Eval** @@ -66,7 +66,7 @@ public TimeSpan Eval { get; } #### Property Value -[TimeSpan](https://docs.microsoft.com/en-us/dotnet/api/system.timespan)
+[TimeSpan](https://learn.microsoft.com/en-us/dotnet/api/system.timespan)
### **PrompTokensEvaluated** @@ -78,7 +78,7 @@ public int PrompTokensEvaluated { get; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **TokensEvaluated** @@ -90,7 +90,7 @@ public int TokensEvaluated { get; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
--- diff --git a/docs/xmldocs/llama.native.llamapoolingtype.md b/docs/xmldocs/llama.native.llamapoolingtype.md index b5d5ed20c..a1d106229 100644 --- a/docs/xmldocs/llama.native.llamapoolingtype.md +++ b/docs/xmldocs/llama.native.llamapoolingtype.md @@ -12,8 +12,8 @@ Namespace: LLama.Native public enum LLamaPoolingType ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://docs.microsoft.com/en-us/dotnet/api/system.enum) → [LLamaPoolingType](./llama.native.llamapoolingtype.md)
-Implements [IComparable](https://docs.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://docs.microsoft.com/en-us/dotnet/api/system.iconvertible) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://learn.microsoft.com/en-us/dotnet/api/system.enum) → [LLamaPoolingType](./llama.native.llamapoolingtype.md)
+Implements [IComparable](https://learn.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://learn.microsoft.com/en-us/dotnet/api/system.iconvertible) **Remarks:** diff --git a/docs/xmldocs/llama.native.llamapos.md b/docs/xmldocs/llama.native.llamapos.md index f5f1d4fa4..1a19d2722 100644 --- a/docs/xmldocs/llama.native.llamapos.md +++ b/docs/xmldocs/llama.native.llamapos.md @@ -9,11 +9,11 @@ Namespace: LLama.Native Indicates position in a sequence ```csharp -public struct LLamaPos +public record struct LLamaPos ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaPos](./llama.native.llamapos.md)
-Implements [IEquatable<LLamaPos>](https://docs.microsoft.com/en-us/dotnet/api/system.iequatable-1) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaPos](./llama.native.llamapos.md)
+Implements [IEquatable<LLamaPos>](https://learn.microsoft.com/en-us/dotnet/api/system.iequatable-1) ## Fields @@ -25,55 +25,71 @@ The raw value public int Value; ``` -## Methods +## Operators -### **ToString()** +### **explicit operator int(LLamaPos)** + +Convert a LLamaPos into an integer (extract the raw value) ```csharp -string ToString() +public static explicit operator int(LLamaPos pos) ``` +#### Parameters + +`pos` [LLamaPos](./llama.native.llamapos.md)
+ #### Returns -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **implicit operator LLamaPos(Int32)** -### **GetHashCode()** +Convert an integer into a LLamaPos ```csharp -int GetHashCode() +public static implicit operator LLamaPos(int value) ``` +#### Parameters + +`value` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ #### Returns -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[LLamaPos](./llama.native.llamapos.md)
-### **Equals(Object)** +### **operator ++(LLamaPos)** + +Increment this position ```csharp -bool Equals(object obj) +public static LLamaPos operator ++(LLamaPos pos) ``` #### Parameters -`obj` [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object)
+`pos` [LLamaPos](./llama.native.llamapos.md)
#### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[LLamaPos](./llama.native.llamapos.md)
+ +### **operator --(LLamaPos)** -### **Equals(LLamaPos)** +Increment this position ```csharp -bool Equals(LLamaPos other) +public static LLamaPos operator --(LLamaPos pos) ``` #### Parameters -`other` [LLamaPos](./llama.native.llamapos.md)
+`pos` [LLamaPos](./llama.native.llamapos.md)
#### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[LLamaPos](./llama.native.llamapos.md)
--- diff --git a/docs/xmldocs/llama.native.llamaropetype.md b/docs/xmldocs/llama.native.llamaropetype.md index 53ab30d1f..51d8edb69 100644 --- a/docs/xmldocs/llama.native.llamaropetype.md +++ b/docs/xmldocs/llama.native.llamaropetype.md @@ -12,8 +12,8 @@ Namespace: LLama.Native public enum LLamaRopeType ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://docs.microsoft.com/en-us/dotnet/api/system.enum) → [LLamaRopeType](./llama.native.llamaropetype.md)
-Implements [IComparable](https://docs.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://docs.microsoft.com/en-us/dotnet/api/system.iconvertible) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://learn.microsoft.com/en-us/dotnet/api/system.enum) → [LLamaRopeType](./llama.native.llamaropetype.md)
+Implements [IComparable](https://learn.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://learn.microsoft.com/en-us/dotnet/api/system.iconvertible) **Remarks:** diff --git a/docs/xmldocs/llama.native.llamasamplerchainparams.md b/docs/xmldocs/llama.native.llamasamplerchainparams.md index 08eef6098..fbd61f39d 100644 --- a/docs/xmldocs/llama.native.llamasamplerchainparams.md +++ b/docs/xmldocs/llama.native.llamasamplerchainparams.md @@ -12,7 +12,7 @@ Namespace: LLama.Native public struct LLamaSamplerChainParams ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaSamplerChainParams](./llama.native.llamasamplerchainparams.md) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaSamplerChainParams](./llama.native.llamasamplerchainparams.md) **Remarks:** @@ -30,7 +30,7 @@ public bool NoPerf { get; set; } #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
## Methods @@ -39,7 +39,7 @@ public bool NoPerf { get; set; } Get the default LLamaSamplerChainParams ```csharp -LLamaSamplerChainParams Default() +public static LLamaSamplerChainParams Default() ``` #### Returns diff --git a/docs/xmldocs/llama.native.llamasamplingtimings.md b/docs/xmldocs/llama.native.llamasamplingtimings.md index 4f9f1c76e..20d12b158 100644 --- a/docs/xmldocs/llama.native.llamasamplingtimings.md +++ b/docs/xmldocs/llama.native.llamasamplingtimings.md @@ -12,7 +12,7 @@ LLama performance information public struct LLamaSamplingTimings ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaSamplingTimings](./llama.native.llamasamplingtimings.md) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaSamplingTimings](./llama.native.llamasamplingtimings.md) **Remarks:** diff --git a/docs/xmldocs/llama.native.llamaseqid.md b/docs/xmldocs/llama.native.llamaseqid.md index 9fe6f104f..5b3159497 100644 --- a/docs/xmldocs/llama.native.llamaseqid.md +++ b/docs/xmldocs/llama.native.llamaseqid.md @@ -9,11 +9,11 @@ Namespace: LLama.Native ID for a sequence in a batch ```csharp -public struct LLamaSeqId +public record struct LLamaSeqId ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaSeqId](./llama.native.llamaseqid.md)
-Implements [IEquatable<LLamaSeqId>](https://docs.microsoft.com/en-us/dotnet/api/system.iequatable-1) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaSeqId](./llama.native.llamaseqid.md)
+Implements [IEquatable<LLamaSeqId>](https://learn.microsoft.com/en-us/dotnet/api/system.iequatable-1) ## Fields @@ -33,55 +33,39 @@ LLamaSeqId with value 0 public static LLamaSeqId Zero; ``` -## Methods +## Operators -### **ToString()** +### **explicit operator int(LLamaSeqId)** -```csharp -string ToString() -``` - -#### Returns - -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
- -### **GetHashCode()** - -```csharp -int GetHashCode() -``` - -#### Returns - -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -### **Equals(Object)** +Convert a LLamaSeqId into an integer (extract the raw value) ```csharp -bool Equals(object obj) +public static explicit operator int(LLamaSeqId pos) ``` #### Parameters -`obj` [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object)
+`pos` [LLamaSeqId](./llama.native.llamaseqid.md)
#### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **explicit operator LLamaSeqId(Int32)** -### **Equals(LLamaSeqId)** +Convert an integer into a LLamaSeqId ```csharp -bool Equals(LLamaSeqId other) +public static explicit operator LLamaSeqId(int value) ``` #### Parameters -`other` [LLamaSeqId](./llama.native.llamaseqid.md)
+`value` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
#### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[LLamaSeqId](./llama.native.llamaseqid.md)
--- diff --git a/docs/xmldocs/llama.native.llamatoken.md b/docs/xmldocs/llama.native.llamatoken.md index 06297a2d9..4f544c8bb 100644 --- a/docs/xmldocs/llama.native.llamatoken.md +++ b/docs/xmldocs/llama.native.llamatoken.md @@ -9,12 +9,12 @@ Namespace: LLama.Native A single token ```csharp -public struct LLamaToken +public readonly record struct LLamaToken ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaToken](./llama.native.llamatoken.md)
-Implements [IEquatable<LLamaToken>](https://docs.microsoft.com/en-us/dotnet/api/system.iequatable-1)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute), [IsReadOnlyAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.isreadonlyattribute), [DebuggerDisplayAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.debuggerdisplayattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaToken](./llama.native.llamatoken.md)
+Implements [IEquatable<LLamaToken>](https://learn.microsoft.com/en-us/dotnet/api/system.iequatable-1)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute), [IsReadOnlyAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.isreadonlyattribute), [DebuggerDisplayAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.debuggerdisplayattribute) ## Fields @@ -33,7 +33,7 @@ public static LLamaToken InvalidToken; Get attributes for this token ```csharp -LLamaTokenAttr GetAttributes(SafeLlamaModelHandle model) +public LLamaTokenAttr GetAttributes(SafeLlamaModelHandle model) ``` #### Parameters @@ -49,7 +49,7 @@ LLamaTokenAttr GetAttributes(SafeLlamaModelHandle model) Get attributes for this token ```csharp -LLamaTokenAttr GetAttributes(Vocabulary vocab) +public LLamaTokenAttr GetAttributes(Vocabulary vocab) ``` #### Parameters @@ -65,7 +65,7 @@ LLamaTokenAttr GetAttributes(Vocabulary vocab) Get score for this token ```csharp -float GetScore(Vocabulary vocab) +public float GetScore(Vocabulary vocab) ``` #### Parameters @@ -74,14 +74,14 @@ float GetScore(Vocabulary vocab) #### Returns -[Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+[Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
### **IsControl(SafeLlamaModelHandle)** Check if this is a control token ```csharp -bool IsControl(SafeLlamaModelHandle model) +public bool IsControl(SafeLlamaModelHandle model) ``` #### Parameters @@ -90,14 +90,14 @@ bool IsControl(SafeLlamaModelHandle model) #### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **IsControl(Vocabulary)** Check if this is a control token ```csharp -bool IsControl(Vocabulary vocab) +public bool IsControl(Vocabulary vocab) ``` #### Parameters @@ -106,14 +106,14 @@ bool IsControl(Vocabulary vocab) #### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **IsEndOfGeneration(SafeLlamaModelHandle)** Check if this token should end generation ```csharp -bool IsEndOfGeneration(SafeLlamaModelHandle model) +public bool IsEndOfGeneration(SafeLlamaModelHandle model) ``` #### Parameters @@ -122,14 +122,14 @@ bool IsEndOfGeneration(SafeLlamaModelHandle model) #### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **IsEndOfGeneration(Vocabulary)** Check if this token should end generation ```csharp -bool IsEndOfGeneration(Vocabulary vocab) +public bool IsEndOfGeneration(Vocabulary vocab) ``` #### Parameters @@ -138,55 +138,41 @@ bool IsEndOfGeneration(Vocabulary vocab) #### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
-### **ToString()** +## Operators -```csharp -string ToString() -``` - -#### Returns +### **explicit operator int(LLamaToken)** -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
- -### **GetHashCode()** +Convert a LLamaToken into an integer (extract the raw value) ```csharp -int GetHashCode() -``` - -#### Returns - -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -### **Equals(Object)** - -```csharp -bool Equals(object obj) +public static explicit operator int(LLamaToken pos) ``` #### Parameters -`obj` [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object)
+`pos` [LLamaToken](./llama.native.llamatoken.md)
#### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **implicit operator LLamaToken(Int32)** -### **Equals(LLamaToken)** +Convert an integer into a LLamaToken ```csharp -bool Equals(LLamaToken other) +public static implicit operator LLamaToken(int value) ``` #### Parameters -`other` [LLamaToken](./llama.native.llamatoken.md)
+`value` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
#### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[LLamaToken](./llama.native.llamatoken.md)
--- diff --git a/docs/xmldocs/llama.native.llamatokenattr.md b/docs/xmldocs/llama.native.llamatokenattr.md index fc73029ee..964bbce0a 100644 --- a/docs/xmldocs/llama.native.llamatokenattr.md +++ b/docs/xmldocs/llama.native.llamatokenattr.md @@ -12,9 +12,9 @@ Token attributes public enum LLamaTokenAttr ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://docs.microsoft.com/en-us/dotnet/api/system.enum) → [LLamaTokenAttr](./llama.native.llamatokenattr.md)
-Implements [IComparable](https://docs.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://docs.microsoft.com/en-us/dotnet/api/system.iconvertible)
-Attributes [FlagsAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.flagsattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://learn.microsoft.com/en-us/dotnet/api/system.enum) → [LLamaTokenAttr](./llama.native.llamatokenattr.md)
+Implements [IComparable](https://learn.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://learn.microsoft.com/en-us/dotnet/api/system.iconvertible)
+Attributes [FlagsAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.flagsattribute) **Remarks:** diff --git a/docs/xmldocs/llama.native.llamatokendata.md b/docs/xmldocs/llama.native.llamatokendata.md index b6ae94f09..d753f077a 100644 --- a/docs/xmldocs/llama.native.llamatokendata.md +++ b/docs/xmldocs/llama.native.llamatokendata.md @@ -12,7 +12,7 @@ A single token along with probability of this token being selected public struct LLamaTokenData ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaTokenData](./llama.native.llamatokendata.md) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaTokenData](./llama.native.llamatokendata.md) ## Fields @@ -47,16 +47,16 @@ public float Probability; Create a new LLamaTokenData ```csharp -LLamaTokenData(LLamaToken id, float logit, float probability) +public LLamaTokenData(LLamaToken id, float logit, float probability) ``` #### Parameters `id` [LLamaToken](./llama.native.llamatoken.md)
-`logit` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`logit` [Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
-`probability` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`probability` [Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
--- diff --git a/docs/xmldocs/llama.native.llamatokendataarray.md b/docs/xmldocs/llama.native.llamatokendataarray.md index 8a3277c24..cb713fb71 100644 --- a/docs/xmldocs/llama.native.llamatokendataarray.md +++ b/docs/xmldocs/llama.native.llamatokendataarray.md @@ -12,7 +12,7 @@ Contains an array of LLamaTokenData, potentially sorted. public struct LLamaTokenDataArray ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaTokenDataArray](./llama.native.llamatokendataarray.md) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaTokenDataArray](./llama.native.llamatokendataarray.md) ## Fields @@ -39,14 +39,14 @@ public bool Sorted; Create a new LLamaTokenDataArray ```csharp -LLamaTokenDataArray(Memory tokens, bool isSorted) +public LLamaTokenDataArray(Memory tokens, bool isSorted = false) ``` #### Parameters -`tokens` [Memory<LLamaTokenData>](https://docs.microsoft.com/en-us/dotnet/api/system.memory-1)
+`tokens` [Memory<LLamaTokenData>](https://learn.microsoft.com/en-us/dotnet/api/system.memory-1)
-`isSorted` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`isSorted` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
## Methods @@ -55,12 +55,12 @@ LLamaTokenDataArray(Memory tokens, bool isSorted) Create a new LLamaTokenDataArray, copying the data from the given logits ```csharp -LLamaTokenDataArray Create(ReadOnlySpan logits) +public static LLamaTokenDataArray Create(ReadOnlySpan logits) ``` #### Parameters -`logits` [ReadOnlySpan<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+`logits` [ReadOnlySpan<Single>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
#### Returns @@ -71,14 +71,14 @@ LLamaTokenDataArray Create(ReadOnlySpan logits) Create a new LLamaTokenDataArray, copying the data from the given logits into temporary memory. ```csharp -LLamaTokenDataArray Create(ReadOnlySpan logits, Memory buffer) +public static LLamaTokenDataArray Create(ReadOnlySpan logits, Memory buffer) ``` #### Parameters -`logits` [ReadOnlySpan<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+`logits` [ReadOnlySpan<Single>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
-`buffer` [Memory<LLamaTokenData>](https://docs.microsoft.com/en-us/dotnet/api/system.memory-1)
+`buffer` [Memory<LLamaTokenData>](https://learn.microsoft.com/en-us/dotnet/api/system.memory-1)
Temporary memory which will be used to work on these logits. Must be at least as large as logits array #### Returns @@ -89,17 +89,17 @@ Temporary memory which will be used to work on these logits. Must be at least as The memory must not be modified while this [LLamaTokenDataArray](./llama.native.llamatokendataarray.md) is in use. -### **OverwriteLogits(ReadOnlySpan<ValueTuple<LLamaToken, Single>>)** +### **OverwriteLogits(ReadOnlySpan<(LLamaToken, Single)>)** Overwrite the logit values for all given tokens ```csharp -void OverwriteLogits(ReadOnlySpan> values) +public void OverwriteLogits(ReadOnlySpan<(LLamaToken token, float logit)> values) ``` #### Parameters -`values` [ReadOnlySpan<ValueTuple<LLamaToken, Single>>](https://docs.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+`values` [ReadOnlySpan<(LLamaToken, Single)>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
tuples of token and logit value to overwrite ### **Softmax()** @@ -107,7 +107,7 @@ tuples of token and logit value to overwrite Sorts candidate tokens by their logits in descending order and calculate probabilities based on logits. ```csharp -void Softmax() +public void Softmax() ``` --- diff --git a/docs/xmldocs/llama.native.llamatokendataarraynative.md b/docs/xmldocs/llama.native.llamatokendataarraynative.md index 639f5ed85..36ec7c644 100644 --- a/docs/xmldocs/llama.native.llamatokendataarraynative.md +++ b/docs/xmldocs/llama.native.llamatokendataarraynative.md @@ -12,7 +12,7 @@ Contains a pointer to an array of LLamaTokenData which is pinned in memory. public struct LLamaTokenDataArrayNative ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaTokenDataArrayNative](./llama.native.llamatokendataarraynative.md) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLamaTokenDataArrayNative](./llama.native.llamatokendataarraynative.md) **Remarks:** @@ -30,7 +30,7 @@ public Span Data { get; } #### Property Value -[Span<LLamaTokenData>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1)
+[Span<LLamaTokenData>](https://learn.microsoft.com/en-us/dotnet/api/system.span-1)
### **Sorted** @@ -42,7 +42,7 @@ public bool Sorted { get; set; } #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **Selected** @@ -54,7 +54,7 @@ public long Selected { get; set; } #### Property Value -[Int64](https://docs.microsoft.com/en-us/dotnet/api/system.int64)
+[Int64](https://learn.microsoft.com/en-us/dotnet/api/system.int64)
### **Size** @@ -66,16 +66,16 @@ public ulong Size { get; set; } #### Property Value -[UInt64](https://docs.microsoft.com/en-us/dotnet/api/system.uint64)
+[UInt64](https://learn.microsoft.com/en-us/dotnet/api/system.uint64)
## Methods -### **Create(LLamaTokenDataArray, LLamaTokenDataArrayNative&)** +### **Create(LLamaTokenDataArray, out LLamaTokenDataArrayNative)** Create a new LLamaTokenDataArrayNative around the data in the LLamaTokenDataArray ```csharp -MemoryHandle Create(LLamaTokenDataArray array, LLamaTokenDataArrayNative& native) +public static MemoryHandle Create(LLamaTokenDataArray array, out LLamaTokenDataArrayNative native) ``` #### Parameters @@ -83,12 +83,12 @@ MemoryHandle Create(LLamaTokenDataArray array, LLamaTokenDataArrayNative& native `array` [LLamaTokenDataArray](./llama.native.llamatokendataarray.md)
Data source -`native` [LLamaTokenDataArrayNative&](./llama.native.llamatokendataarraynative&.md)
+`out` `native` [LLamaTokenDataArrayNative](./llama.native.llamatokendataarraynative.md)
Created native array #### Returns -[MemoryHandle](https://docs.microsoft.com/en-us/dotnet/api/system.buffers.memoryhandle)
+[MemoryHandle](https://learn.microsoft.com/en-us/dotnet/api/system.buffers.memoryhandle)
A memory handle, pinning the data in place until disposed --- diff --git a/docs/xmldocs/llama.native.llamavocabtype.md b/docs/xmldocs/llama.native.llamavocabtype.md index 5cadd2b63..9d413b87b 100644 --- a/docs/xmldocs/llama.native.llamavocabtype.md +++ b/docs/xmldocs/llama.native.llamavocabtype.md @@ -12,8 +12,8 @@ Namespace: LLama.Native public enum LLamaVocabType ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://docs.microsoft.com/en-us/dotnet/api/system.enum) → [LLamaVocabType](./llama.native.llamavocabtype.md)
-Implements [IComparable](https://docs.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://docs.microsoft.com/en-us/dotnet/api/system.iconvertible) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://learn.microsoft.com/en-us/dotnet/api/system.enum) → [LLamaVocabType](./llama.native.llamavocabtype.md)
+Implements [IComparable](https://learn.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://learn.microsoft.com/en-us/dotnet/api/system.iconvertible) **Remarks:** @@ -29,6 +29,7 @@ llama_vocab_type | WordPiece | 3 | BERT tokenizer based on WordPiece | | Unigram | 4 | T5 tokenizer based on Unigram | | RWKV | 5 | RWKV tokenizer based on greedy tokenization | +| PLAMO2 | 6 | PLaMo-2 tokenizer based on Aho-Corasick with dynamic programming | --- diff --git a/docs/xmldocs/llama.native.llavaimageembed.md b/docs/xmldocs/llama.native.llavaimageembed.md deleted file mode 100644 index 9afc23413..000000000 --- a/docs/xmldocs/llama.native.llavaimageembed.md +++ /dev/null @@ -1,41 +0,0 @@ -[`< Back`](./) - ---- - -# LLavaImageEmbed - -Namespace: LLama.Native - -LLaVa Image embeddings - -```csharp -public struct LLavaImageEmbed -``` - -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [LLavaImageEmbed](./llama.native.llavaimageembed.md) - -**Remarks:** - -llava_image_embed - -## Fields - -### **embed** - -The embeddings of the embedded image. - -```csharp -public Single* embed; -``` - -### **n_image_pos** - -The position of the image's tokens. - -```csharp -public int n_image_pos; -``` - ---- - -[`< Back`](./) diff --git a/docs/xmldocs/llama.native.loraadapter.md b/docs/xmldocs/llama.native.loraadapter.md index 5dfa34a0c..755658501 100644 --- a/docs/xmldocs/llama.native.loraadapter.md +++ b/docs/xmldocs/llama.native.loraadapter.md @@ -12,8 +12,8 @@ A LoRA adapter which can be applied to a context for a specific model public class LoraAdapter ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [LoraAdapter](./llama.native.loraadapter.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [LoraAdapter](./llama.native.loraadapter.md)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties @@ -39,7 +39,7 @@ public string Path { get; } #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
## Methods diff --git a/docs/xmldocs/llama.native.mtmdcontextparams.md b/docs/xmldocs/llama.native.mtmdcontextparams.md new file mode 100644 index 000000000..8ef0c3c82 --- /dev/null +++ b/docs/xmldocs/llama.native.mtmdcontextparams.md @@ -0,0 +1,164 @@ +[`< Back`](./) + +--- + +# MtmdContextParams + +Namespace: LLama.Native + +Managed representation of the native `mtmd_context_params` structure used to configure multimodal helpers. + +```csharp +public class MtmdContextParams +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [MtmdContextParams](./llama.native.mtmdcontextparams.md)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) + +## Fields + +### **BatchMaxTokens** + +maximum number of output tokens in a batch + (note: this is not a hard-limit, the first image will always be added even if it exceeds this limit) + (default: 1024) + +```csharp +public int BatchMaxTokens; +``` + +## Properties + +### **UseGpu** + +Whether GPU acceleration should be requested when available. + +```csharp +public bool UseGpu { get; set; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **PrintTimings** + +Whether timing information should be emitted by the native helper. + +```csharp +public bool PrintTimings { get; set; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **NThreads** + +Number of worker threads to dedicate to preprocessing and tokenization. + +```csharp +public int NThreads { get; set; } +``` + +#### Property Value + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **ImageMarker** + +Marker token inserted into the text stream to reference an image embedding (deprecated by mtmd). + +```csharp +public string? ImageMarker { get; set; } +``` + +#### Property Value + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **MediaMarker** + +Marker token inserted into the text stream to reference a generic media embedding. + +```csharp +public string? MediaMarker { get; set; } +``` + +#### Property Value + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **FlashAttentionType** + +Flash attention policy forwarded to mtmd encoders. + +```csharp +public LLamaFlashAttentionType FlashAttentionType { get; set; } +``` + +#### Property Value + +[LLamaFlashAttentionType](./llama.native.llamaflashattentiontype.md)
+ +### **Warmup** + +Whether to run a warmup encode pass after initialization. + +```csharp +public bool Warmup { get; set; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **ImageMinTokens** + +Minimum number of image tokens for dynamic resolution (use -1 to read metadata). + +```csharp +public int ImageMinTokens { get; set; } +``` + +#### Property Value + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **ImageMaxTokens** + +Maximum number of image tokens for dynamic resolution (use -1 to read metadata). + +```csharp +public int ImageMaxTokens { get; set; } +``` + +#### Property Value + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +## Constructors + +### **MtmdContextParams()** + +```csharp +public MtmdContextParams() +``` + +## Methods + +### **Default()** + +Create a managed copy of the native defaults returned by [NativeApi.mtmd_context_params_default()](./llama.native.nativeapi.md#mtmd_context_params_default). + +```csharp +public static MtmdContextParams Default() +``` + +#### Returns + +[MtmdContextParams](./llama.native.mtmdcontextparams.md)
+ +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.native.nativeapi.md b/docs/xmldocs/llama.native.nativeapi.md index 7dab89db7..df91a03f4 100644 --- a/docs/xmldocs/llama.native.nativeapi.md +++ b/docs/xmldocs/llama.native.nativeapi.md @@ -12,11 +12,43 @@ Direct translation of the llama.cpp API public static class NativeApi ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [NativeApi](./llama.native.nativeapi.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [NativeApi](./llama.native.nativeapi.md)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Methods +### **llama_load_mode_name(LLamaLoadMode)** + +Get the canonical name of a particular load mode + +```csharp +public static string llama_load_mode_name(LLamaLoadMode load_mode) +``` + +#### Parameters + +`load_mode` [LLamaLoadMode](./llama.native.llamaloadmode.md)
+ +#### Returns + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **llama_load_mode_from_str(String)** + +Parse a load mode from a string + +```csharp +public static LLamaLoadMode llama_load_mode_from_str(string str) +``` + +#### Parameters + +`str` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +#### Returns + +[LLamaLoadMode](./llama.native.llamaloadmode.md)
+ ### **llama_empty_call()** A method that does nothing. This is a native method, calling it will force the llama native dependencies to be loaded. @@ -43,7 +75,29 @@ public static long llama_max_devices() #### Returns -[Int64](https://docs.microsoft.com/en-us/dotnet/api/system.int64)
+[Int64](https://learn.microsoft.com/en-us/dotnet/api/system.int64)
+ +### **llama_max_tensor_buft_overrides()** + +```csharp +public static IntPtr llama_max_tensor_buft_overrides() +``` + +#### Returns + +[IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
+ +### **llama_max_parallel_sequences()** + +Maximum number of parallel sequences + +```csharp +public static long llama_max_parallel_sequences() +``` + +#### Returns + +[Int64](https://learn.microsoft.com/en-us/dotnet/api/system.int64)
### **llama_supports_mmap()** @@ -55,7 +109,7 @@ public static bool llama_supports_mmap() #### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **llama_supports_mlock()** @@ -67,7 +121,7 @@ public static bool llama_supports_mlock() #### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **llama_supports_gpu_offload()** @@ -79,7 +133,7 @@ public static bool llama_supports_gpu_offload() #### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **llama_supports_rpc()** @@ -91,31 +145,31 @@ public static bool llama_supports_rpc() #### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
-### **llama_state_load_file(SafeLLamaContextHandle, String, LLamaToken[], UInt64, UInt64&)** +### **llama_state_load_file(SafeLLamaContextHandle, String, LLamaToken[], UInt64, out UInt64)** Load session file ```csharp -public static bool llama_state_load_file(SafeLLamaContextHandle ctx, string path_session, LLamaToken[] tokens_out, ulong n_token_capacity, UInt64& n_token_count_out) +public static bool llama_state_load_file(SafeLLamaContextHandle ctx, string path_session, LLamaToken[] tokens_out, ulong n_token_capacity, out ulong n_token_count_out) ``` #### Parameters `ctx` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
-`path_session` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`path_session` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
`tokens_out` [LLamaToken[]](./llama.native.llamatoken.md)
-`n_token_capacity` [UInt64](https://docs.microsoft.com/en-us/dotnet/api/system.uint64)
+`n_token_capacity` [UInt64](https://learn.microsoft.com/en-us/dotnet/api/system.uint64)
-`n_token_count_out` [UInt64&](https://docs.microsoft.com/en-us/dotnet/api/system.uint64&)
+`out` `n_token_count_out` [UInt64](https://learn.microsoft.com/en-us/dotnet/api/system.uint64)
#### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **llama_state_save_file(SafeLLamaContextHandle, String, LLamaToken[], UInt64)** @@ -129,19 +183,19 @@ public static bool llama_state_save_file(SafeLLamaContextHandle ctx, string path `ctx` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
-`path_session` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`path_session` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
`tokens` [LLamaToken[]](./llama.native.llamatoken.md)
-`n_token_count` [UInt64](https://docs.microsoft.com/en-us/dotnet/api/system.uint64)
+`n_token_count` [UInt64](https://learn.microsoft.com/en-us/dotnet/api/system.uint64)
#### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **llama_state_seq_save_file(SafeLLamaContextHandle, String, LLamaSeqId, LLamaToken*, UIntPtr)** -Saves the specified sequence as a file on specified filepath. Can later be loaded via [NativeApi.llama_state_load_file(SafeLLamaContextHandle, String, LLamaToken[], UInt64, UInt64&)](./llama.native.nativeapi.md#llama_state_load_filesafellamacontexthandle-string-llamatoken-uint64-uint64&) +Saves the specified sequence as a file on specified filepath. Can later be loaded via [NativeApi.llama_state_load_file(SafeLLamaContextHandle, String, LLamaToken[], UInt64, out UInt64)](./llama.native.nativeapi.md#llama_state_load_filesafellamacontexthandle-string-llamatoken-uint64-out-uint64) ```csharp public static UIntPtr llama_state_seq_save_file(SafeLLamaContextHandle ctx, string filepath, LLamaSeqId seq_id, LLamaToken* tokens, UIntPtr n_token_count) @@ -151,104 +205,59 @@ public static UIntPtr llama_state_seq_save_file(SafeLLamaContextHandle ctx, stri `ctx` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
-`filepath` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`filepath` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
`seq_id` [LLamaSeqId](./llama.native.llamaseqid.md)
`tokens` [LLamaToken*](./llama.native.llamatoken*.md)
-`n_token_count` [UIntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.uintptr)
+`n_token_count` [UIntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.uintptr)
#### Returns -[UIntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.uintptr)
+[UIntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.uintptr)
-### **llama_state_seq_load_file(SafeLLamaContextHandle, String, LLamaSeqId, LLamaToken*, UIntPtr, UIntPtr&)** +### **llama_state_seq_load_file(SafeLLamaContextHandle, String, LLamaSeqId, LLamaToken*, UIntPtr, out UIntPtr)** Loads a sequence saved as a file via [NativeApi.llama_state_save_file(SafeLLamaContextHandle, String, LLamaToken[], UInt64)](./llama.native.nativeapi.md#llama_state_save_filesafellamacontexthandle-string-llamatoken-uint64) into the specified sequence ```csharp -public static UIntPtr llama_state_seq_load_file(SafeLLamaContextHandle ctx, string filepath, LLamaSeqId dest_seq_id, LLamaToken* tokens_out, UIntPtr n_token_capacity, UIntPtr& n_token_count_out) +public static UIntPtr llama_state_seq_load_file(SafeLLamaContextHandle ctx, string filepath, LLamaSeqId dest_seq_id, LLamaToken* tokens_out, UIntPtr n_token_capacity, out UIntPtr n_token_count_out) ``` #### Parameters `ctx` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
-`filepath` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`filepath` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
`dest_seq_id` [LLamaSeqId](./llama.native.llamaseqid.md)
`tokens_out` [LLamaToken*](./llama.native.llamatoken*.md)
-`n_token_capacity` [UIntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.uintptr)
+`n_token_capacity` [UIntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.uintptr)
-`n_token_count_out` [UIntPtr&](https://docs.microsoft.com/en-us/dotnet/api/system.uintptr&)
+`out` `n_token_count_out` [UIntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.uintptr)
#### Returns -[UIntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.uintptr)
- -### **llama_set_causal_attn(SafeLLamaContextHandle, Boolean)** - -Set whether to use causal attention or not. If set to true, the model will only attend to the past tokens - -```csharp -public static void llama_set_causal_attn(SafeLLamaContextHandle ctx, bool causalAttn) -``` - -#### Parameters - -`ctx` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
- -`causalAttn` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -### **llama_set_embeddings(SafeLLamaContextHandle, Boolean)** +[UIntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.uintptr)
-Set whether the model is in embeddings mode or not. - -```csharp -public static void llama_set_embeddings(SafeLLamaContextHandle ctx, bool embeddings) -``` - -#### Parameters - -`ctx` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
- -`embeddings` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
-If true, embeddings will be returned but logits will not - -### **llama_set_abort_callback(SafeLlamaModelHandle, IntPtr, IntPtr)** +### **llama_set_abort_callback(SafeLLamaContextHandle, IntPtr, IntPtr)** Set abort callback ```csharp -public static void llama_set_abort_callback(SafeLlamaModelHandle ctx, IntPtr abortCallback, IntPtr abortCallbackData) -``` - -#### Parameters - -`ctx` [SafeLlamaModelHandle](./llama.native.safellamamodelhandle.md)
- -`abortCallback` [IntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.intptr)
- -`abortCallbackData` [IntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.intptr)
- -### **llama_n_seq_max(SafeLLamaContextHandle)** - -Get the n_seq_max for this context - -```csharp -public static uint llama_n_seq_max(SafeLLamaContextHandle ctx) +public static void llama_set_abort_callback(SafeLLamaContextHandle ctx, IntPtr abortCallback, IntPtr abortCallbackData) ``` #### Parameters `ctx` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
-#### Returns +`abortCallback` [IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
-[UInt32](https://docs.microsoft.com/en-us/dotnet/api/system.uint32)
+`abortCallbackData` [IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
### **llama_get_embeddings(SafeLLamaContextHandle)** @@ -268,11 +277,14 @@ public static Single* llama_get_embeddings(SafeLLamaContextHandle ctx) #### Returns -[Single*](https://docs.microsoft.com/en-us/dotnet/api/system.single*)
+[Single*](https://learn.microsoft.com/en-us/dotnet/api/system.single*)
### **llama_chat_apply_template(Byte*, LLamaChatMessage*, UIntPtr, Boolean, Byte*, Int32)** Apply chat template. Inspired by hf apply_chat_template() on python. +
+ NOTE: This function does not use a jinja parser. It only support a pre-defined list of template. + See more: https://github.com/ggml-org/llama.cpp/wiki/Templates-supported-by-llama_chat_apply_template ```csharp public static int llama_chat_apply_template(Byte* tmpl, LLamaChatMessage* chat, UIntPtr n_msg, bool add_ass, Byte* buf, int length) @@ -280,27 +292,27 @@ public static int llama_chat_apply_template(Byte* tmpl, LLamaChatMessage* chat, #### Parameters -`tmpl` [Byte*](https://docs.microsoft.com/en-us/dotnet/api/system.byte*)
-A Jinja template to use for this chat. If this is nullptr, the model’s default chat template will be used instead. +`tmpl` [Byte*](https://learn.microsoft.com/en-us/dotnet/api/system.byte*)
+A Jinja template to use for this chat. `chat` [LLamaChatMessage*](./llama.native.llamachatmessage*.md)
Pointer to a list of multiple llama_chat_message -`n_msg` [UIntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.uintptr)
+`n_msg` [UIntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.uintptr)
Number of llama_chat_message in this chat -`add_ass` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`add_ass` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
Whether to end the prompt with the token(s) that indicate the start of an assistant message. -`buf` [Byte*](https://docs.microsoft.com/en-us/dotnet/api/system.byte*)
+`buf` [Byte*](https://learn.microsoft.com/en-us/dotnet/api/system.byte*)
A buffer to hold the output formatted prompt. The recommended alloc size is 2 * (total number of characters of all messages) -`length` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`length` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
The size of the allocated buffer #### Returns -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
The total number of bytes of the formatted prompt. If is it larger than the size of buffer, you may need to re-alloc it and then re-apply the template. ### **llama_chat_builtin_templates(Char**, UIntPtr)** @@ -313,13 +325,13 @@ public static int llama_chat_builtin_templates(Char** output, UIntPtr len) #### Parameters -`output` [Char**](https://docs.microsoft.com/en-us/dotnet/api/system.char**)
+`output` [Char**](https://learn.microsoft.com/en-us/dotnet/api/system.char**)
-`len` [UIntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.uintptr)
+`len` [UIntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.uintptr)
#### Returns -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **llama_print_timings(SafeLLamaContextHandle)** @@ -343,7 +355,7 @@ public static IntPtr llama_print_system_info() #### Returns -[IntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.intptr)
+[IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
### **llama_token_to_piece(Vocabulary, LLamaToken, Span<Byte>, Int32, Boolean)** @@ -359,18 +371,18 @@ public static int llama_token_to_piece(Vocabulary vocab, LLamaToken llamaToken, `llamaToken` [LLamaToken](./llama.native.llamatoken.md)
-`buffer` [Span<Byte>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1)
+`buffer` [Span<Byte>](https://learn.microsoft.com/en-us/dotnet/api/system.span-1)
buffer to write string into -`lstrip` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`lstrip` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
User can skip up to 'lstrip' leading spaces before copying (useful when encoding/decoding multiple tokens with 'add_space_prefix') -`special` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`special` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
If true, special tokens are rendered in the output #### Returns -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
The length written, or if the buffer is too small a negative that indicates the length required ### **llama_log_set(LLamaLogCallback)** @@ -391,29 +403,6 @@ public static void llama_log_set(LLamaLogCallback logCallback) `logCallback` [LLamaLogCallback](./llama.native.nativelogconfig.llamalogcallback.md)
-### **llama_kv_self_seq_rm(SafeLLamaContextHandle, LLamaSeqId, LLamaPos, LLamaPos)** - -Removes all tokens that belong to the specified sequence and have positions in [p0, p1) - -```csharp -public static bool llama_kv_self_seq_rm(SafeLLamaContextHandle ctx, LLamaSeqId seq, LLamaPos p0, LLamaPos p1) -``` - -#### Parameters - -`ctx` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
- -`seq` [LLamaSeqId](./llama.native.llamaseqid.md)
- -`p0` [LLamaPos](./llama.native.llamapos.md)
- -`p1` [LLamaPos](./llama.native.llamapos.md)
- -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
-Returns false if a partial sequence cannot be removed. Removing a whole sequence never fails - ### **llama_batch_init(Int32, Int32, Int32)** Allocates a batch of tokens on the heap @@ -430,11 +419,11 @@ public static LLamaNativeBatch llama_batch_init(int n_tokens, int embd, int n_se #### Parameters -`n_tokens` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`n_tokens` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
-`embd` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`embd` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
-`n_seq_max` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`n_seq_max` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
Each token can be assigned up to n_seq_max sequence ids #### Returns @@ -453,7 +442,7 @@ public static void llama_batch_free(LLamaNativeBatch batch) `batch` [LLamaNativeBatch](./llama.native.llamanativebatch.md)
-### **llama_apply_adapter_cvec(SafeLLamaContextHandle, Single*, UIntPtr, Int32, Int32, Int32)** +### **llama_set_adapter_cvec(SafeLLamaContextHandle, Single*, UIntPtr, Int32, Int32, Int32)** Apply a loaded control vector to a llama_context, or if data is NULL, clear the currently loaded vector. @@ -463,78 +452,134 @@ Apply a loaded control vector to a llama_context, or if data is NULL, clear See llama_control_vector_load in common to load a control vector. ```csharp -public static int llama_apply_adapter_cvec(SafeLLamaContextHandle ctx, Single* data, UIntPtr len, int n_embd, int il_start, int il_end) +public static int llama_set_adapter_cvec(SafeLLamaContextHandle ctx, Single* data, UIntPtr len, int n_embd, int il_start, int il_end) ``` #### Parameters `ctx` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
-`data` [Single*](https://docs.microsoft.com/en-us/dotnet/api/system.single*)
+`data` [Single*](https://learn.microsoft.com/en-us/dotnet/api/system.single*)
-`len` [UIntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.uintptr)
+`len` [UIntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.uintptr)
-`n_embd` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`n_embd` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
-`il_start` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`il_start` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
-`il_end` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`il_end` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
#### Returns -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
-### **llama_split_path(String, UIntPtr, String, Int32, Int32)** +### **llama_split_path(Span<Byte>, String, Int32, Int32)** -Build a split GGUF final path for this chunk. - llama_split_path(split_path, sizeof(split_path), "/models/ggml-model-q4_0", 2, 4) => split_path = "/models/ggml-model-q4_0-00002-of-00004.gguf" +Build the fully-qualified path for a specific split file in a GGUF shard set. ```csharp -public static int llama_split_path(string split_path, UIntPtr maxlen, string path_prefix, int split_no, int split_count) +public static int llama_split_path(Span splitPathBuffer, string pathPrefix, int splitNo, int splitCount) ``` #### Parameters -`split_path` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`splitPathBuffer` [Span<Byte>](https://learn.microsoft.com/en-us/dotnet/api/system.span-1)
+Writable buffer that receives the UTF-8 encoded path. + +`pathPrefix` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+Base path (e.g. "/models/ggml-model-q4_0"). -`maxlen` [UIntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.uintptr)
+`splitNo` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Zero-based split index. -`path_prefix` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`splitCount` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Total number of splits. -`split_no` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+#### Returns -`split_count` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Number of bytes written to `splitPathBuffer`. + +### **llama_split_path(String, Int32, Int32, Int32)** + +Build the fully-qualified path for a specific split file in a GGUF shard set. + +```csharp +public static string llama_split_path(string pathPrefix, int splitNo, int splitCount, int maxLength = 1024) +``` + +#### Parameters + +`pathPrefix` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+Base path (e.g. "/models/ggml-model-q4_0"). + +`splitNo` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Zero-based split index. + +`splitCount` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Total number of splits. + +`maxLength` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Maximum number of bytes to allocate for the resulting UTF-8 string. #### Returns -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
-Returns the split_path length. +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+UTF-8 decoded split path. -### **llama_split_prefix(String, UIntPtr, String, Int32, Int32)** +### **llama_split_prefix(Span<Byte>, String, Int32, Int32)** -Extract the path prefix from the split_path if and only if the split_no and split_count match. - llama_split_prefix(split_prefix, 64, "/models/ggml-model-q4_0-00002-of-00004.gguf", 2, 4) => split_prefix = "/models/ggml-model-q4_0" +Extract the shard prefix from a GGUF split path when the split metadata matches. ```csharp -public static int llama_split_prefix(string split_prefix, UIntPtr maxlen, string split_path, int split_no, int split_count) +public static int llama_split_prefix(Span splitPrefixBuffer, string splitPath, int splitNo, int splitCount) ``` #### Parameters -`split_prefix` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`splitPrefixBuffer` [Span<Byte>](https://learn.microsoft.com/en-us/dotnet/api/system.span-1)
+Writable buffer that receives the UTF-8 encoded prefix. + +`splitPath` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+Full path to a shard file. + +`splitNo` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Zero-based split index. + +`splitCount` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Total number of splits. + +#### Returns + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Number of bytes written to `splitPrefixBuffer`. + +### **llama_split_prefix(String, Int32, Int32, Int32)** -`maxlen` [UIntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.uintptr)
+Extract the shard prefix from a GGUF split path when the split metadata matches. -`split_path` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+```csharp +public static string llama_split_prefix(string splitPath, int splitNo, int splitCount, int maxLength = 1024) +``` -`split_no` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+#### Parameters -`split_count` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`splitPath` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+Full path to a shard file. + +`splitNo` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Zero-based split index. + +`splitCount` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Total number of splits. + +`maxLength` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Maximum number of bytes to allocate for the resulting UTF-8 string. #### Returns -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
-Returns the split_prefix length. +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+UTF-8 decoded split prefix. ### **ggml_backend_dev_count()** @@ -546,7 +591,7 @@ public static UIntPtr ggml_backend_dev_count() #### Returns -[UIntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.uintptr)
+[UIntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.uintptr)
Count of available backend devices ### **ggml_backend_dev_get(UIntPtr)** @@ -559,14 +604,32 @@ public static IntPtr ggml_backend_dev_get(UIntPtr i) #### Parameters -`i` [UIntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.uintptr)
+`i` [UIntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.uintptr)
Device index #### Returns -[IntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.intptr)
+[IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
Pointer to the backend device +### **ggml_backend_dev_name(IntPtr)** + +Get the name of a backend device (e.g. "CPU", "Vulkan0", "CUDA1") + +```csharp +public static IntPtr ggml_backend_dev_name(IntPtr dev) +``` + +#### Parameters + +`dev` [IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
+Backend device pointer + +#### Returns + +[IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
+Pointer to a null terminated UTF-8 string, owned by the device + ### **ggml_backend_dev_buffer_type(IntPtr)** Get the buffer type for a backend device @@ -577,12 +640,12 @@ public static IntPtr ggml_backend_dev_buffer_type(IntPtr dev) #### Parameters -`dev` [IntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.intptr)
+`dev` [IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
Backend device pointer #### Returns -[IntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.intptr)
+[IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
Pointer to the buffer type ### **ggml_backend_buft_name(IntPtr)** @@ -595,165 +658,145 @@ public static IntPtr ggml_backend_buft_name(IntPtr buft) #### Parameters -`buft` [IntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.intptr)
+`buft` [IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
Buffer type pointer #### Returns -[IntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.intptr)
+[IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
Name of the buffer type -### **llava_validate_embed_size(SafeLLamaContextHandle, SafeLlavaModelHandle)** - -Sanity check for clip <-> llava embed size match +### **llama_time_us()** ```csharp -public static bool llava_validate_embed_size(SafeLLamaContextHandle ctxLlama, SafeLlavaModelHandle ctxClip) +public static long llama_time_us() ``` -#### Parameters - -`ctxLlama` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
-LLama Context - -`ctxClip` [SafeLlavaModelHandle](./llama.native.safellavamodelhandle.md)
-Llava Model - #### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
-True if validate successfully +[Int64](https://learn.microsoft.com/en-us/dotnet/api/system.int64)
-### **llava_image_embed_make_with_bytes(SafeLlavaModelHandle, Int32, Byte[], Int32)** +### **GetLoadedNativeLibrary(NativeLibraryName)** -Build an image embed from image file bytes +Get the loaded native library. If you are using netstandard2.0, it will always return null. ```csharp -public static SafeLlavaImageEmbedHandle llava_image_embed_make_with_bytes(SafeLlavaModelHandle ctx_clip, int n_threads, Byte[] image_bytes, int image_bytes_length) +public static INativeLibrary? GetLoadedNativeLibrary(NativeLibraryName name) ``` #### Parameters -`ctx_clip` [SafeLlavaModelHandle](./llama.native.safellavamodelhandle.md)
-SafeHandle to the Clip Model +`name` [NativeLibraryName](./llama.native.nativelibraryname.md)
-`n_threads` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
-Number of threads +#### Returns -`image_bytes` [Byte[]](https://docs.microsoft.com/en-us/dotnet/api/system.byte)
-Binary image in jpeg format +[INativeLibrary](./llama.abstractions.inativelibrary.md)?
-`image_bytes_length` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
-Bytes length of the image +#### Exceptions -#### Returns +[ArgumentException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentexception)
-[SafeLlavaImageEmbedHandle](./llama.native.safellavaimageembedhandle.md)
-SafeHandle to the Embeddings +### **llama_memory_clear(IntPtr, Boolean)** -### **llava_image_embed_make_with_filename(SafeLlavaModelHandle, Int32, String)** +Clear the memory contents. If data == true, the data buffers will also be cleared together with the metadata -Build an image embed from a path to an image filename +```csharp +public static void llama_memory_clear(IntPtr mem, bool data) +``` + +#### Parameters + +`mem` [IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
+ +`data` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **llama_memory_seq_rm(IntPtr, LLamaSeqId, LLamaPos, LLamaPos)** + +Removes all tokens that belong to the specified sequence and have positions in [p0, p1) ```csharp -public static SafeLlavaImageEmbedHandle llava_image_embed_make_with_filename(SafeLlavaModelHandle ctx_clip, int n_threads, string image_path) +public static bool llama_memory_seq_rm(IntPtr mem, LLamaSeqId seq, LLamaPos p0, LLamaPos p1) ``` #### Parameters -`ctx_clip` [SafeLlavaModelHandle](./llama.native.safellavamodelhandle.md)
-SafeHandle to the Clip Model +`mem` [IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
+ +`seq` [LLamaSeqId](./llama.native.llamaseqid.md)
-`n_threads` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
-Number of threads +`p0` [LLamaPos](./llama.native.llamapos.md)
-`image_path` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
-Image filename (jpeg) to generate embeddings +`p1` [LLamaPos](./llama.native.llamapos.md)
#### Returns -[SafeLlavaImageEmbedHandle](./llama.native.safellavaimageembedhandle.md)
-SafeHandle to the embeddings +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+Returns false if a partial sequence cannot be removed. Removing a whole sequence never fails -### **llava_image_embed_free(IntPtr)** +### **MtmdDefaultMarker()** -Free an embedding made with llava_image_embed_make_* +Retrieve the default multimodal marker text. ```csharp -public static void llava_image_embed_free(IntPtr embed) +public static string? MtmdDefaultMarker() ``` -#### Parameters +#### Returns -`embed` [IntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.intptr)
-Embeddings to release +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)?
-### **llava_eval_image_embed(SafeLLamaContextHandle, SafeLlavaImageEmbedHandle, Int32, Int32&)** +### **mtmd_get_marker(SafeMtmdModelHandle)** -Write the image represented by embed into the llama context with batch size n_batch, starting at context - pos n_past. on completion, n_past points to the next position in the context after the image embed. +get the current marker string ```csharp -public static bool llava_eval_image_embed(SafeLLamaContextHandle ctx_llama, SafeLlavaImageEmbedHandle embed, int n_batch, Int32& n_past) +public static string mtmd_get_marker(SafeMtmdModelHandle ctx) ``` #### Parameters -`ctx_llama` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
-Llama Context - -`embed` [SafeLlavaImageEmbedHandle](./llama.native.safellavaimageembedhandle.md)
-Embedding handle - -`n_batch` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -`n_past` [Int32&](https://docs.microsoft.com/en-us/dotnet/api/system.int32&)
+`ctx` [SafeMtmdModelHandle](./llama.native.safemtmdmodelhandle.md)
#### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
-True on success +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
-### **GetLoadedNativeLibrary(NativeLibraryName)** +### **llama_model_quantize(String, String, ref LLamaModelQuantizeParams)** -Get the loaded native library. If you are using netstandard2.0, it will always return null. +Returns 0 on success ```csharp -public static INativeLibrary GetLoadedNativeLibrary(NativeLibraryName name) +public static uint llama_model_quantize(string fname_inp, string fname_out, ref LLamaModelQuantizeParams param) ``` #### Parameters -`name` [NativeLibraryName](./llama.native.nativelibraryname.md)
+`fname_inp` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
-#### Returns +`fname_out` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
-[INativeLibrary](./llama.abstractions.inativelibrary.md)
+`ref` `param` [LLamaModelQuantizeParams](./llama.native.llamamodelquantizeparams.md)
-#### Exceptions +#### Returns -[ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentexception)
+[UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
+Returns 0 on success -### **llama_model_quantize(String, String, LLamaModelQuantizeParams&)** +### **llama_ftype_name(LLamaFtype)** -Returns 0 on success +Get the model file type (quantization) as a string, e.g. "Q8_0" or "Q4_K - Medium" ```csharp -public static uint llama_model_quantize(string fname_inp, string fname_out, LLamaModelQuantizeParams& param) +public static string llama_ftype_name(LLamaFtype ftype) ``` #### Parameters -`fname_inp` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
- -`fname_out` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
- -`param` [LLamaModelQuantizeParams&](./llama.native.llamamodelquantizeparams&.md)
+`ftype` [LLamaFtype](./llama.native.llamaftype.md)
#### Returns -[UInt32](https://docs.microsoft.com/en-us/dotnet/api/system.uint32)
-Returns 0 on success +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
--- diff --git a/docs/xmldocs/llama.native.nativelibraryconfig.description.md b/docs/xmldocs/llama.native.nativelibraryconfig.description.md new file mode 100644 index 000000000..bf046ddb0 --- /dev/null +++ b/docs/xmldocs/llama.native.nativelibraryconfig.description.md @@ -0,0 +1,157 @@ +[`< Back`](./) + +--- + +# Description + +Namespace: LLama.Native + +The description of the native library configurations that's already specified. + +```csharp +internal record class Description : System.IEquatable`1[[LLama.Native.NativeLibraryConfig+Description, LLamaSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [Description](./llama.native.nativelibraryconfig.description.md)
+Implements [IEquatable<Description>](https://learn.microsoft.com/en-us/dotnet/api/system.iequatable-1)
+Attributes [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) + +## Properties + +### **Path** + + + +```csharp +public string? Path { get; init; } +``` + +#### Property Value + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **Library** + + + +```csharp +public NativeLibraryName Library { get; init; } +``` + +#### Property Value + +[NativeLibraryName](./llama.native.nativelibraryname.md)
+ +### **UseCuda** + + + +```csharp +public bool UseCuda { get; init; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **UseVulkan** + + + +```csharp +public bool UseVulkan { get; init; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **AvxLevel** + + + +```csharp +public AvxLevel AvxLevel { get; init; } +``` + +#### Property Value + +[AvxLevel](./llama.native.avxlevel.md)
+ +### **AllowFallback** + + + +```csharp +public bool AllowFallback { get; init; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **SkipCheck** + + + +```csharp +public bool SkipCheck { get; init; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **SearchDirectories** + + + +```csharp +public String[] SearchDirectories { get; init; } +``` + +#### Property Value + +[String[]](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +## Constructors + +### **Description(String, NativeLibraryName, Boolean, Boolean, AvxLevel, Boolean, Boolean, String[])** + +The description of the native library configurations that's already specified. + +```csharp +public Description(string? Path, NativeLibraryName Library, bool UseCuda, bool UseVulkan, AvxLevel AvxLevel, bool AllowFallback, bool SkipCheck, String[] SearchDirectories) +``` + +#### Parameters + +`Path` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)?
+ +`Library` [NativeLibraryName](./llama.native.nativelibraryname.md)
+ +`UseCuda` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +`UseVulkan` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +`AvxLevel` [AvxLevel](./llama.native.avxlevel.md)
+ +`AllowFallback` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +`SkipCheck` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +`SearchDirectories` [String[]](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **Description(Description)** + +```csharp +protected Description(Description original) +``` + +#### Parameters + +`original` [Description](./llama.native.nativelibraryconfig.description.md)
+ +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.native.nativelibraryconfig.md b/docs/xmldocs/llama.native.nativelibraryconfig.md index 471e1367d..5d07a87ec 100644 --- a/docs/xmldocs/llama.native.nativelibraryconfig.md +++ b/docs/xmldocs/llama.native.nativelibraryconfig.md @@ -13,8 +13,8 @@ Allows configuration of the native llama.cpp libraries to load and use. public sealed class NativeLibraryConfig ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [NativeLibraryConfig](./llama.native.nativelibraryconfig.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [NativeLibraryConfig](./llama.native.nativelibraryconfig.md)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties @@ -22,11 +22,11 @@ Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/ap #### Caution -Please use NativeLibraryConfig.All instead, or set configurations for NativeLibraryConfig.LLama and NativeLibraryConfig.LLavaShared respectively. +Please use NativeLibraryConfig.All instead, or set configurations for NativeLibraryConfig.LLama and NativeLibraryConfig.Mtmd respectively. --- -Set configurations for all the native libraries, including LLama and LLava +Set configurations for all the native libraries, including LLama and Multimodal ```csharp public static NativeLibraryConfigContainer Instance { get; } @@ -38,7 +38,7 @@ public static NativeLibraryConfigContainer Instance { get; } ### **All** -Set configurations for all the native libraries, including LLama and LLava +Set configurations for all the native libraries, including LLama and Multimodal ```csharp public static NativeLibraryConfigContainer All { get; } @@ -60,12 +60,12 @@ public static NativeLibraryConfig LLama { get; } [NativeLibraryConfig](./llama.native.nativelibraryconfig.md)
-### **LLava** +### **Mtmd** -Configuration for LLava native library +Configuration for Mtmd native library ```csharp -public static NativeLibraryConfig LLava { get; } +public static NativeLibraryConfig Mtmd { get; } ``` #### Property Value @@ -82,7 +82,7 @@ public bool LibraryHasLoaded { get; internal set; } #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
## Methods @@ -92,12 +92,12 @@ Load a specified native library as backend for LLamaSharp. When this method is called, all the other configurations will be ignored. ```csharp -public NativeLibraryConfig WithLibrary(string libraryPath) +public NativeLibraryConfig WithLibrary(string? libraryPath) ``` #### Parameters -`libraryPath` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`libraryPath` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)?
The full path to the native library to load. #### Returns @@ -106,7 +106,7 @@ The full path to the native library to load. #### Exceptions -[InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
+[InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
Thrown if `LibraryHasLoaded` is true. ### **WithCuda(Boolean)** @@ -114,12 +114,12 @@ Thrown if `LibraryHasLoaded` is true. Configure whether to use cuda backend if possible. Default is true. ```csharp -public NativeLibraryConfig WithCuda(bool enable) +public NativeLibraryConfig WithCuda(bool enable = true) ``` #### Parameters -`enable` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`enable` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
#### Returns @@ -127,7 +127,7 @@ public NativeLibraryConfig WithCuda(bool enable) #### Exceptions -[InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
+[InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
Thrown if `LibraryHasLoaded` is true. ### **WithVulkan(Boolean)** @@ -135,12 +135,12 @@ Thrown if `LibraryHasLoaded` is true. Configure whether to use vulkan backend if possible. Default is true. ```csharp -public NativeLibraryConfig WithVulkan(bool enable) +public NativeLibraryConfig WithVulkan(bool enable = true) ``` #### Parameters -`enable` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`enable` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
#### Returns @@ -148,12 +148,12 @@ public NativeLibraryConfig WithVulkan(bool enable) #### Exceptions -[InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
+[InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
Thrown if `LibraryHasLoaded` is true. ### **WithAvx(AvxLevel)** -Configure the prefferred avx support level of the backend. +Configure the preferred AVX support level of the backend. Default value is detected automatically due to your operating system. ```csharp @@ -170,7 +170,7 @@ public NativeLibraryConfig WithAvx(AvxLevel level) #### Exceptions -[InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
+[InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
Thrown if `LibraryHasLoaded` is true. ### **WithAutoFallback(Boolean)** @@ -178,12 +178,12 @@ Thrown if `LibraryHasLoaded` is true. Configure whether to allow fallback when there's no match for preferred settings. Default is true. ```csharp -public NativeLibraryConfig WithAutoFallback(bool enable) +public NativeLibraryConfig WithAutoFallback(bool enable = true) ``` #### Parameters -`enable` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`enable` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
#### Returns @@ -191,7 +191,7 @@ public NativeLibraryConfig WithAutoFallback(bool enable) #### Exceptions -[InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
+[InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
Thrown if `LibraryHasLoaded` is true. ### **SkipCheck(Boolean)** @@ -201,12 +201,12 @@ Whether to skip the check when you don't allow fallback. This option you have your cublas configured but LLamaSharp take it as invalid by mistake. Default is false; ```csharp -public NativeLibraryConfig SkipCheck(bool enable) +public NativeLibraryConfig SkipCheck(bool enable = true) ``` #### Parameters -`enable` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`enable` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
#### Returns @@ -214,7 +214,7 @@ public NativeLibraryConfig SkipCheck(bool enable) #### Exceptions -[InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
+[InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
Thrown if `LibraryHasLoaded` is true. ### **WithSearchDirectories(IEnumerable<String>)** @@ -229,7 +229,7 @@ public NativeLibraryConfig WithSearchDirectories(IEnumerable directories #### Parameters -`directories` [IEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
+`directories` [IEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
#### Returns @@ -247,7 +247,7 @@ public NativeLibraryConfig WithSearchDirectory(string directory) #### Parameters -`directory` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`directory` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
#### Returns @@ -275,12 +275,12 @@ public NativeLibraryConfig WithSelectingPolicy(INativeLibrarySelectingPolicy pol Set the log callback that will be used for all llama.cpp log messages ```csharp -public NativeLibraryConfig WithLogCallback(LLamaLogCallback callback) +public NativeLibraryConfig WithLogCallback(LLamaLogCallback? callback) ``` #### Parameters -`callback` [LLamaLogCallback](./llama.native.nativelogconfig.llamalogcallback.md)
+`callback` [LLamaLogCallback](./llama.native.nativelogconfig.llamalogcallback.md)?
#### Returns @@ -288,29 +288,11 @@ public NativeLibraryConfig WithLogCallback(LLamaLogCallback callback) #### Exceptions -[NotImplementedException](https://docs.microsoft.com/en-us/dotnet/api/system.notimplementedexception)
+[NotImplementedException](https://learn.microsoft.com/en-us/dotnet/api/system.notimplementedexception)
-### **WithLogCallback(ILogger)** +### **WithLogCallback** -Set the log callback that will be used for all llama.cpp log messages - -```csharp -public NativeLibraryConfig WithLogCallback(ILogger logger) -``` - -#### Parameters - -`logger` ILogger
- -#### Returns - -[NativeLibraryConfig](./llama.native.nativelibraryconfig.md)
- -#### Exceptions - -[NotImplementedException](https://docs.microsoft.com/en-us/dotnet/api/system.notimplementedexception)
- -### **DryRun(INativeLibrary&)** +### **DryRun(out INativeLibrary)** Try to load the native library with the current configurations, but do not actually set it to [NativeApi](./llama.native.nativeapi.md). @@ -318,18 +300,18 @@ Try to load the native library with the current configurations, You can still modify the configuration after this calling but only before any call from [NativeApi](./llama.native.nativeapi.md). ```csharp -public bool DryRun(INativeLibrary& loadedLibrary) +public bool DryRun(out INativeLibrary loadedLibrary) ``` #### Parameters -`loadedLibrary` [INativeLibrary&](./llama.abstractions.inativelibrary&.md)
+`out` `loadedLibrary` [INativeLibrary](./llama.abstractions.inativelibrary.md)
The loaded livrary. When the loading failed, this will be null. However if you are using .NET standard2.0, this will never return null. #### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
Whether the running is successful. --- diff --git a/docs/xmldocs/llama.native.nativelibraryconfigcontainer.md b/docs/xmldocs/llama.native.nativelibraryconfigcontainer.md index c3d607853..21bf8974e 100644 --- a/docs/xmldocs/llama.native.nativelibraryconfigcontainer.md +++ b/docs/xmldocs/llama.native.nativelibraryconfigcontainer.md @@ -12,8 +12,8 @@ A class to set same configurations to multiple libraries at the same time. public sealed class NativeLibraryConfigContainer ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [NativeLibraryConfigContainer](./llama.native.nativelibraryconfigcontainer.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [NativeLibraryConfigContainer](./llama.native.nativelibraryconfigcontainer.md)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Methods @@ -27,7 +27,7 @@ public void ForEach(Action action) #### Parameters -`action` [Action<NativeLibraryConfig>](https://docs.microsoft.com/en-us/dotnet/api/system.action-1)
+`action` [Action<NativeLibraryConfig>](https://learn.microsoft.com/en-us/dotnet/api/system.action-1)
### **WithLibrary(String, String)** @@ -35,16 +35,16 @@ Load a specified native library as backend for LLamaSharp. When this method is called, all the other configurations will be ignored. ```csharp -public NativeLibraryConfigContainer WithLibrary(string llamaPath, string llavaPath) +public NativeLibraryConfigContainer WithLibrary(string? llamaPath, string? mtmdPath) ``` #### Parameters -`llamaPath` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`llamaPath` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)?
The full path to the llama library to load. -`llavaPath` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
-The full path to the llava library to load. +`mtmdPath` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)?
+The full path to the mtmd library to load. #### Returns @@ -52,7 +52,7 @@ The full path to the llava library to load. #### Exceptions -[InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
+[InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
Thrown if `LibraryHasLoaded` is true. ### **WithCuda(Boolean)** @@ -60,12 +60,12 @@ Thrown if `LibraryHasLoaded` is true. Configure whether to use cuda backend if possible. ```csharp -public NativeLibraryConfigContainer WithCuda(bool enable) +public NativeLibraryConfigContainer WithCuda(bool enable = true) ``` #### Parameters -`enable` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`enable` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
#### Returns @@ -73,7 +73,7 @@ public NativeLibraryConfigContainer WithCuda(bool enable) #### Exceptions -[InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
+[InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
Thrown if `LibraryHasLoaded` is true. ### **WithVulkan(Boolean)** @@ -81,12 +81,12 @@ Thrown if `LibraryHasLoaded` is true. Configure whether to use vulkan backend if possible. ```csharp -public NativeLibraryConfigContainer WithVulkan(bool enable) +public NativeLibraryConfigContainer WithVulkan(bool enable = true) ``` #### Parameters -`enable` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`enable` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
#### Returns @@ -94,12 +94,12 @@ public NativeLibraryConfigContainer WithVulkan(bool enable) #### Exceptions -[InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
+[InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
Thrown if `LibraryHasLoaded` is true. ### **WithAvx(AvxLevel)** -Configure the prefferred avx support level of the backend. +Configure the preferred AVX support level of the backend. ```csharp public NativeLibraryConfigContainer WithAvx(AvxLevel level) @@ -115,7 +115,7 @@ public NativeLibraryConfigContainer WithAvx(AvxLevel level) #### Exceptions -[InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
+[InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
Thrown if `LibraryHasLoaded` is true. ### **WithAutoFallback(Boolean)** @@ -123,12 +123,12 @@ Thrown if `LibraryHasLoaded` is true. Configure whether to allow fallback when there's no match for preferred settings. ```csharp -public NativeLibraryConfigContainer WithAutoFallback(bool enable) +public NativeLibraryConfigContainer WithAutoFallback(bool enable = true) ``` #### Parameters -`enable` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`enable` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
#### Returns @@ -136,7 +136,7 @@ public NativeLibraryConfigContainer WithAutoFallback(bool enable) #### Exceptions -[InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
+[InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
Thrown if `LibraryHasLoaded` is true. ### **SkipCheck(Boolean)** @@ -146,12 +146,12 @@ Whether to skip the check when you don't allow fallback. This option you have your cublas configured but LLamaSharp take it as invalid by mistake. ```csharp -public NativeLibraryConfigContainer SkipCheck(bool enable) +public NativeLibraryConfigContainer SkipCheck(bool enable = true) ``` #### Parameters -`enable` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`enable` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
#### Returns @@ -159,7 +159,7 @@ public NativeLibraryConfigContainer SkipCheck(bool enable) #### Exceptions -[InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
+[InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
Thrown if `LibraryHasLoaded` is true. ### **WithSearchDirectories(IEnumerable<String>)** @@ -174,7 +174,7 @@ public NativeLibraryConfigContainer WithSearchDirectories(IEnumerable di #### Parameters -`directories` [IEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
+`directories` [IEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
#### Returns @@ -192,7 +192,7 @@ public NativeLibraryConfigContainer WithSearchDirectory(string directory) #### Parameters -`directory` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`directory` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
#### Returns @@ -220,12 +220,12 @@ public NativeLibraryConfigContainer WithSelectingPolicy(INativeLibrarySelectingP Set the log callback that will be used for all llama.cpp log messages ```csharp -public NativeLibraryConfigContainer WithLogCallback(LLamaLogCallback callback) +public NativeLibraryConfigContainer WithLogCallback(LLamaLogCallback? callback) ``` #### Parameters -`callback` [LLamaLogCallback](./llama.native.nativelogconfig.llamalogcallback.md)
+`callback` [LLamaLogCallback](./llama.native.nativelogconfig.llamalogcallback.md)?
#### Returns @@ -233,29 +233,11 @@ public NativeLibraryConfigContainer WithLogCallback(LLamaLogCallback callback) #### Exceptions -[NotImplementedException](https://docs.microsoft.com/en-us/dotnet/api/system.notimplementedexception)
+[NotImplementedException](https://learn.microsoft.com/en-us/dotnet/api/system.notimplementedexception)
-### **WithLogCallback(ILogger)** +### **WithLogCallback** -Set the log callback that will be used for all llama.cpp log messages - -```csharp -public NativeLibraryConfigContainer WithLogCallback(ILogger logger) -``` - -#### Parameters - -`logger` ILogger
- -#### Returns - -[NativeLibraryConfigContainer](./llama.native.nativelibraryconfigcontainer.md)
- -#### Exceptions - -[NotImplementedException](https://docs.microsoft.com/en-us/dotnet/api/system.notimplementedexception)
- -### **DryRun(INativeLibrary&, INativeLibrary&)** +### **DryRun(out INativeLibrary, out INativeLibrary)** Try to load the native library with the current configurations, but do not actually set it to [NativeApi](./llama.native.nativeapi.md). @@ -263,18 +245,18 @@ Try to load the native library with the current configurations, You can still modify the configuration after this calling but only before any call from [NativeApi](./llama.native.nativeapi.md). ```csharp -public bool DryRun(INativeLibrary& loadedLLamaNativeLibrary, INativeLibrary& loadedLLavaNativeLibrary) +public bool DryRun(out INativeLibrary loadedLLamaNativeLibrary, out INativeLibrary loadedMtmdNativeLibrary) ``` #### Parameters -`loadedLLamaNativeLibrary` [INativeLibrary&](./llama.abstractions.inativelibrary&.md)
+`out` `loadedLLamaNativeLibrary` [INativeLibrary](./llama.abstractions.inativelibrary.md)
-`loadedLLavaNativeLibrary` [INativeLibrary&](./llama.abstractions.inativelibrary&.md)
+`out` `loadedMtmdNativeLibrary` [INativeLibrary](./llama.abstractions.inativelibrary.md)
#### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
Whether the running is successful. --- diff --git a/docs/xmldocs/llama.native.nativelibraryfrompath.md b/docs/xmldocs/llama.native.nativelibraryfrompath.md index dbe079119..6c70cf80b 100644 --- a/docs/xmldocs/llama.native.nativelibraryfrompath.md +++ b/docs/xmldocs/llama.native.nativelibraryfrompath.md @@ -12,16 +12,18 @@ A native library specified with a local file path. public class NativeLibraryFromPath : LLama.Abstractions.INativeLibrary ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [NativeLibraryFromPath](./llama.native.nativelibraryfrompath.md)
+Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [NativeLibraryFromPath](./llama.native.nativelibraryfrompath.md)
Implements [INativeLibrary](./llama.abstractions.inativelibrary.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties ### **Metadata** +Metadata of this library. + ```csharp -public NativeLibraryMetadata Metadata { get; } +public NativeLibraryMetadata? Metadata { get; } ``` #### Property Value @@ -40,25 +42,31 @@ public NativeLibraryFromPath(string path) #### Parameters -`path` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`path` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
## Methods ### **Prepare(SystemInfo, LLamaLogCallback)** +Prepare the native library file and returns the local path of it. + If it's a relative path, LLamaSharp will search the path in the search directies you set. + ```csharp -public IEnumerable Prepare(SystemInfo systemInfo, LLamaLogCallback logCallback) +public IEnumerable Prepare(SystemInfo systemInfo, LLamaLogCallback? logCallback) ``` #### Parameters `systemInfo` [SystemInfo](./llama.native.systeminfo.md)
+The system information of the current machine. -`logCallback` [LLamaLogCallback](./llama.native.nativelogconfig.llamalogcallback.md)
+`logCallback` [LLamaLogCallback](./llama.native.nativelogconfig.llamalogcallback.md)?
+The log callback. #### Returns -[IEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
+[IEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
+The relative paths of the library. You could return multiple paths to try them one by one. If no file is available, please return an empty array. --- diff --git a/docs/xmldocs/llama.native.nativelibrarymetadata.md b/docs/xmldocs/llama.native.nativelibrarymetadata.md index 6e21f6acf..dfa52bf2d 100644 --- a/docs/xmldocs/llama.native.nativelibrarymetadata.md +++ b/docs/xmldocs/llama.native.nativelibrarymetadata.md @@ -9,31 +9,21 @@ Namespace: LLama.Native Information of a native library file. ```csharp -public class NativeLibraryMetadata : System.IEquatable`1[[LLama.Native.NativeLibraryMetadata, LLamaSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] +public record class NativeLibraryMetadata : System.IEquatable`1[[LLama.Native.NativeLibraryMetadata, LLamaSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [NativeLibraryMetadata](./llama.native.nativelibrarymetadata.md)
-Implements [IEquatable<NativeLibraryMetadata>](https://docs.microsoft.com/en-us/dotnet/api/system.iequatable-1)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [NativeLibraryMetadata](./llama.native.nativelibrarymetadata.md)
+Implements [IEquatable<NativeLibraryMetadata>](https://learn.microsoft.com/en-us/dotnet/api/system.iequatable-1)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties -### **EqualityContract** - -```csharp -protected Type EqualityContract { get; } -``` - -#### Property Value - -[Type](https://docs.microsoft.com/en-us/dotnet/api/system.type)
- ### **NativeLibraryName** Which kind of library it is. ```csharp -public NativeLibraryName NativeLibraryName { get; set; } +public NativeLibraryName NativeLibraryName { get; init; } ``` #### Property Value @@ -45,31 +35,31 @@ public NativeLibraryName NativeLibraryName { get; set; } Whether it's compiled with cublas. ```csharp -public bool UseCuda { get; set; } +public bool UseCuda { get; init; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **UseVulkan** Whether it's compiled with vulkan. ```csharp -public bool UseVulkan { get; set; } +public bool UseVulkan { get; init; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **AvxLevel** Which AvxLevel it's compiled with. ```csharp -public AvxLevel AvxLevel { get; set; } +public AvxLevel AvxLevel { get; init; } ``` #### Property Value @@ -91,10 +81,10 @@ public NativeLibraryMetadata(NativeLibraryName NativeLibraryName, bool UseCuda, `NativeLibraryName` [NativeLibraryName](./llama.native.nativelibraryname.md)
Which kind of library it is. -`UseCuda` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`UseCuda` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
Whether it's compiled with cublas. -`UseVulkan` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`UseVulkan` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
Whether it's compiled with vulkan. `AvxLevel` [AvxLevel](./llama.native.avxlevel.md)
@@ -110,96 +100,6 @@ protected NativeLibraryMetadata(NativeLibraryMetadata original) `original` [NativeLibraryMetadata](./llama.native.nativelibrarymetadata.md)
-## Methods - -### **ToString()** - -```csharp -public string ToString() -``` - -#### Returns - -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
- -### **PrintMembers(StringBuilder)** - -```csharp -protected bool PrintMembers(StringBuilder builder) -``` - -#### Parameters - -`builder` [StringBuilder](https://docs.microsoft.com/en-us/dotnet/api/system.text.stringbuilder)
- -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -### **GetHashCode()** - -```csharp -public int GetHashCode() -``` - -#### Returns - -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -### **Equals(Object)** - -```csharp -public bool Equals(object obj) -``` - -#### Parameters - -`obj` [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object)
- -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -### **Equals(NativeLibraryMetadata)** - -```csharp -public bool Equals(NativeLibraryMetadata other) -``` - -#### Parameters - -`other` [NativeLibraryMetadata](./llama.native.nativelibrarymetadata.md)
- -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -### **<Clone>$()** - -```csharp -public NativeLibraryMetadata $() -``` - -#### Returns - -[NativeLibraryMetadata](./llama.native.nativelibrarymetadata.md)
- -### **Deconstruct(NativeLibraryName&, Boolean&, Boolean&, AvxLevel&)** - -```csharp -public void Deconstruct(NativeLibraryName& NativeLibraryName, Boolean& UseCuda, Boolean& UseVulkan, AvxLevel& AvxLevel) -``` - -#### Parameters - -`NativeLibraryName` [NativeLibraryName&](./llama.native.nativelibraryname&.md)
- -`UseCuda` [Boolean&](https://docs.microsoft.com/en-us/dotnet/api/system.boolean&)
- -`UseVulkan` [Boolean&](https://docs.microsoft.com/en-us/dotnet/api/system.boolean&)
- -`AvxLevel` [AvxLevel&](./llama.native.avxlevel&.md)
- --- [`< Back`](./) diff --git a/docs/xmldocs/llama.native.nativelibraryname.md b/docs/xmldocs/llama.native.nativelibraryname.md index ef555cfa9..953eaf3a3 100644 --- a/docs/xmldocs/llama.native.nativelibraryname.md +++ b/docs/xmldocs/llama.native.nativelibraryname.md @@ -12,15 +12,15 @@ The name of the native library public enum NativeLibraryName ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://docs.microsoft.com/en-us/dotnet/api/system.enum) → [NativeLibraryName](./llama.native.nativelibraryname.md)
-Implements [IComparable](https://docs.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://docs.microsoft.com/en-us/dotnet/api/system.iconvertible) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://learn.microsoft.com/en-us/dotnet/api/system.enum) → [NativeLibraryName](./llama.native.nativelibraryname.md)
+Implements [IComparable](https://learn.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://learn.microsoft.com/en-us/dotnet/api/system.iconvertible) ## Fields | Name | Value | Description | | --- | --: | --- | | LLama | 0 | The native library compiled from llama.cpp. | -| LLava | 1 | The native library compiled from the LLaVA example of llama.cpp. | +| Mtmd | 1 | The native library compiled from the MTMD library of llama.cpp. | --- diff --git a/docs/xmldocs/llama.native.nativelibrarywithavx.md b/docs/xmldocs/llama.native.nativelibrarywithavx.md index 812327489..667ccc740 100644 --- a/docs/xmldocs/llama.native.nativelibrarywithavx.md +++ b/docs/xmldocs/llama.native.nativelibrarywithavx.md @@ -12,16 +12,18 @@ A native library compiled with avx support but without cuda/cublas. public class NativeLibraryWithAvx : LLama.Abstractions.INativeLibrary ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [NativeLibraryWithAvx](./llama.native.nativelibrarywithavx.md)
+Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [NativeLibraryWithAvx](./llama.native.nativelibrarywithavx.md)
Implements [INativeLibrary](./llama.abstractions.inativelibrary.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties ### **Metadata** +Metadata of this library. + ```csharp -public NativeLibraryMetadata Metadata { get; } +public NativeLibraryMetadata? Metadata { get; } ``` #### Property Value @@ -44,25 +46,31 @@ public NativeLibraryWithAvx(NativeLibraryName libraryName, AvxLevel avxLevel, bo `avxLevel` [AvxLevel](./llama.native.avxlevel.md)
-`skipCheck` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`skipCheck` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
## Methods ### **Prepare(SystemInfo, LLamaLogCallback)** +Prepare the native library file and returns the local path of it. + If it's a relative path, LLamaSharp will search the path in the search directies you set. + ```csharp -public IEnumerable Prepare(SystemInfo systemInfo, LLamaLogCallback logCallback) +public IEnumerable Prepare(SystemInfo systemInfo, LLamaLogCallback? logCallback) ``` #### Parameters `systemInfo` [SystemInfo](./llama.native.systeminfo.md)
+The system information of the current machine. -`logCallback` [LLamaLogCallback](./llama.native.nativelogconfig.llamalogcallback.md)
+`logCallback` [LLamaLogCallback](./llama.native.nativelogconfig.llamalogcallback.md)?
+The log callback. #### Returns -[IEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
+[IEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
+The relative paths of the library. You could return multiple paths to try them one by one. If no file is available, please return an empty array. --- diff --git a/docs/xmldocs/llama.native.nativelibrarywithcuda.md b/docs/xmldocs/llama.native.nativelibrarywithcuda.md index 06b2e20bd..7a224f471 100644 --- a/docs/xmldocs/llama.native.nativelibrarywithcuda.md +++ b/docs/xmldocs/llama.native.nativelibrarywithcuda.md @@ -12,16 +12,18 @@ A native library compiled with cublas/cuda. public class NativeLibraryWithCuda : LLama.Abstractions.INativeLibrary ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [NativeLibraryWithCuda](./llama.native.nativelibrarywithcuda.md)
+Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [NativeLibraryWithCuda](./llama.native.nativelibrarywithcuda.md)
Implements [INativeLibrary](./llama.abstractions.inativelibrary.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties ### **Metadata** +Metadata of this library. + ```csharp -public NativeLibraryMetadata Metadata { get; } +public NativeLibraryMetadata? Metadata { get; } ``` #### Property Value @@ -40,31 +42,37 @@ public NativeLibraryWithCuda(int majorCudaVersion, NativeLibraryName libraryName #### Parameters -`majorCudaVersion` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`majorCudaVersion` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
`libraryName` [NativeLibraryName](./llama.native.nativelibraryname.md)
`avxLevel` [AvxLevel](./llama.native.avxlevel.md)
-`skipCheck` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`skipCheck` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
## Methods ### **Prepare(SystemInfo, LLamaLogCallback)** +Prepare the native library file and returns the local path of it. + If it's a relative path, LLamaSharp will search the path in the search directies you set. + ```csharp -public IEnumerable Prepare(SystemInfo systemInfo, LLamaLogCallback logCallback) +public IEnumerable Prepare(SystemInfo systemInfo, LLamaLogCallback? logCallback) ``` #### Parameters `systemInfo` [SystemInfo](./llama.native.systeminfo.md)
+The system information of the current machine. -`logCallback` [LLamaLogCallback](./llama.native.nativelogconfig.llamalogcallback.md)
+`logCallback` [LLamaLogCallback](./llama.native.nativelogconfig.llamalogcallback.md)?
+The log callback. #### Returns -[IEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
+[IEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
+The relative paths of the library. You could return multiple paths to try them one by one. If no file is available, please return an empty array. --- diff --git a/docs/xmldocs/llama.native.nativelibrarywithmacorfallback.md b/docs/xmldocs/llama.native.nativelibrarywithmacorfallback.md index 9871e0890..c5690ab09 100644 --- a/docs/xmldocs/llama.native.nativelibrarywithmacorfallback.md +++ b/docs/xmldocs/llama.native.nativelibrarywithmacorfallback.md @@ -12,14 +12,16 @@ A native library compiled on Mac, or fallbacks from all other libraries in the s public class NativeLibraryWithMacOrFallback : LLama.Abstractions.INativeLibrary ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [NativeLibraryWithMacOrFallback](./llama.native.nativelibrarywithmacorfallback.md)
+Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [NativeLibraryWithMacOrFallback](./llama.native.nativelibrarywithmacorfallback.md)
Implements [INativeLibrary](./llama.abstractions.inativelibrary.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties ### **Metadata** +Metadata of this library. + ```csharp public NativeLibraryMetadata Metadata { get; } ``` @@ -46,19 +48,25 @@ public NativeLibraryWithMacOrFallback(NativeLibraryName libraryName) ### **Prepare(SystemInfo, LLamaLogCallback)** +Prepare the native library file and returns the local path of it. + If it's a relative path, LLamaSharp will search the path in the search directies you set. + ```csharp -public IEnumerable Prepare(SystemInfo systemInfo, LLamaLogCallback logCallback) +public IEnumerable Prepare(SystemInfo systemInfo, LLamaLogCallback? logCallback) ``` #### Parameters `systemInfo` [SystemInfo](./llama.native.systeminfo.md)
+The system information of the current machine. -`logCallback` [LLamaLogCallback](./llama.native.nativelogconfig.llamalogcallback.md)
+`logCallback` [LLamaLogCallback](./llama.native.nativelogconfig.llamalogcallback.md)?
+The log callback. #### Returns -[IEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
+[IEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
+The relative paths of the library. You could return multiple paths to try them one by one. If no file is available, please return an empty array. --- diff --git a/docs/xmldocs/llama.native.nativelibrarywithvulkan.md b/docs/xmldocs/llama.native.nativelibrarywithvulkan.md index dc997ec51..556e17a08 100644 --- a/docs/xmldocs/llama.native.nativelibrarywithvulkan.md +++ b/docs/xmldocs/llama.native.nativelibrarywithvulkan.md @@ -12,16 +12,18 @@ A native library compiled with vulkan. public class NativeLibraryWithVulkan : LLama.Abstractions.INativeLibrary ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [NativeLibraryWithVulkan](./llama.native.nativelibrarywithvulkan.md)
+Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [NativeLibraryWithVulkan](./llama.native.nativelibrarywithvulkan.md)
Implements [INativeLibrary](./llama.abstractions.inativelibrary.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties ### **Metadata** +Metadata of this library. + ```csharp -public NativeLibraryMetadata Metadata { get; } +public NativeLibraryMetadata? Metadata { get; } ``` #### Property Value @@ -35,36 +37,42 @@ public NativeLibraryMetadata Metadata { get; } ```csharp -public NativeLibraryWithVulkan(string vulkanVersion, NativeLibraryName libraryName, AvxLevel avxLevel, bool skipCheck) +public NativeLibraryWithVulkan(string? vulkanVersion, NativeLibraryName libraryName, AvxLevel avxLevel, bool skipCheck) ``` #### Parameters -`vulkanVersion` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`vulkanVersion` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)?
`libraryName` [NativeLibraryName](./llama.native.nativelibraryname.md)
`avxLevel` [AvxLevel](./llama.native.avxlevel.md)
-`skipCheck` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`skipCheck` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
## Methods ### **Prepare(SystemInfo, LLamaLogCallback)** +Prepare the native library file and returns the local path of it. + If it's a relative path, LLamaSharp will search the path in the search directies you set. + ```csharp -public IEnumerable Prepare(SystemInfo systemInfo, LLamaLogCallback logCallback) +public IEnumerable Prepare(SystemInfo systemInfo, LLamaLogCallback? logCallback) ``` #### Parameters `systemInfo` [SystemInfo](./llama.native.systeminfo.md)
+The system information of the current machine. -`logCallback` [LLamaLogCallback](./llama.native.nativelogconfig.llamalogcallback.md)
+`logCallback` [LLamaLogCallback](./llama.native.nativelogconfig.llamalogcallback.md)?
+The log callback. #### Returns -[IEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
+[IEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
+The relative paths of the library. You could return multiple paths to try them one by one. If no file is available, please return an empty array. --- diff --git a/docs/xmldocs/llama.native.nativelogconfig.md b/docs/xmldocs/llama.native.nativelogconfig.md index a5ac92c5c..1ba613333 100644 --- a/docs/xmldocs/llama.native.nativelogconfig.md +++ b/docs/xmldocs/llama.native.nativelogconfig.md @@ -12,8 +12,8 @@ Configure llama.cpp logging public static class NativeLogConfig ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [NativeLogConfig](./llama.native.nativelogconfig.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [NativeLogConfig](./llama.native.nativelogconfig.md)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Methods @@ -22,24 +22,14 @@ Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/ap Register a callback to receive llama log messages ```csharp -public static void llama_log_set(LLamaLogCallback logCallback) +public static void llama_log_set(LLamaLogCallback? logCallback) ``` #### Parameters -`logCallback` [LLamaLogCallback](./llama.native.nativelogconfig.llamalogcallback.md)
+`logCallback` [LLamaLogCallback](./llama.native.nativelogconfig.llamalogcallback.md)?
-### **llama_log_set(ILogger)** - -Register a callback to receive llama log messages - -```csharp -public static void llama_log_set(ILogger logger) -``` - -#### Parameters - -`logger` ILogger
+### **llama_log_set** --- diff --git a/docs/xmldocs/llama.native.ropescalingtype.md b/docs/xmldocs/llama.native.ropescalingtype.md index a68d95768..257847012 100644 --- a/docs/xmldocs/llama.native.ropescalingtype.md +++ b/docs/xmldocs/llama.native.ropescalingtype.md @@ -12,8 +12,8 @@ RoPE scaling type. public enum RopeScalingType ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://docs.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://docs.microsoft.com/en-us/dotnet/api/system.enum) → [RopeScalingType](./llama.native.ropescalingtype.md)
-Implements [IComparable](https://docs.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://docs.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://docs.microsoft.com/en-us/dotnet/api/system.iconvertible) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://learn.microsoft.com/en-us/dotnet/api/system.enum) → [RopeScalingType](./llama.native.ropescalingtype.md)
+Implements [IComparable](https://learn.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://learn.microsoft.com/en-us/dotnet/api/system.iconvertible) **Remarks:** diff --git a/docs/xmldocs/llama.native.safellamacontexthandle.md b/docs/xmldocs/llama.native.safellamacontexthandle.md index 8ea66954f..58b6ed236 100644 --- a/docs/xmldocs/llama.native.safellamacontexthandle.md +++ b/docs/xmldocs/llama.native.safellamacontexthandle.md @@ -12,9 +12,9 @@ A safe wrapper around a llama_context public sealed class SafeLLamaContextHandle : SafeLLamaHandleBase, System.IDisposable ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [CriticalFinalizerObject](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.constrainedexecution.criticalfinalizerobject) → [SafeHandle](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.safehandle) → [SafeLLamaHandleBase](./llama.native.safellamahandlebase.md) → [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
-Implements [IDisposable](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [CriticalFinalizerObject](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.constrainedexecution.criticalfinalizerobject) → [SafeHandle](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.safehandle) → [SafeLLamaHandleBase](./llama.native.safellamahandlebase.md) → [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
+Implements [IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Fields @@ -36,7 +36,7 @@ public uint ContextSize { get; } #### Property Value -[UInt32](https://docs.microsoft.com/en-us/dotnet/api/system.uint32)
+[UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
### **EmbeddingSize** @@ -48,7 +48,7 @@ public int EmbeddingSize { get; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **BatchSize** @@ -60,7 +60,7 @@ public uint BatchSize { get; } #### Property Value -[UInt32](https://docs.microsoft.com/en-us/dotnet/api/system.uint32)
+[UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
### **UBatchSize** @@ -72,7 +72,31 @@ public uint UBatchSize { get; } #### Property Value -[UInt32](https://docs.microsoft.com/en-us/dotnet/api/system.uint32)
+[UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
+ +### **MaxSeq** + +Get the number of maximum sequences allowed + +```csharp +public uint MaxSeq { get; } +``` + +#### Property Value + +[UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
+ +### **RecurrentRollbackSnapshots** + +Get the number of recurrent-state snapshots per seq for rollback + +```csharp +public uint RecurrentRollbackSnapshots { get; } +``` + +#### Property Value + +[UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
### **GenerationThreads** @@ -84,7 +108,7 @@ public int GenerationThreads { get; set; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **BatchThreads** @@ -96,7 +120,7 @@ public int BatchThreads { get; set; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **PoolingType** @@ -134,27 +158,27 @@ public Vocabulary Vocab { get; } [Vocabulary](./llama.native.safellamamodelhandle.vocabulary.md)
-### **KvCacheCanShift** +### **MemoryCanShift** -Check if the context supports KV cache shifting +Check if the context supports memory shifting ```csharp -public bool KvCacheCanShift { get; } +public bool MemoryCanShift { get; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **IsInvalid** ```csharp -public bool IsInvalid { get; } +public override bool IsInvalid { get; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **IsClosed** @@ -164,7 +188,7 @@ public bool IsClosed { get; } #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
## Constructors @@ -179,12 +203,12 @@ public SafeLLamaContextHandle() ### **ReleaseHandle()** ```csharp -protected bool ReleaseHandle() +protected override bool ReleaseHandle() ``` #### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **Create(SafeLlamaModelHandle, LLamaContextParams)** @@ -208,50 +232,46 @@ public static SafeLLamaContextHandle Create(SafeLlamaModelHandle model, LLamaCon [RuntimeError](./llama.exceptions.runtimeerror.md)
-### **AddLoraAdapter(LoraAdapter, Single)** +### **SetCausalAttention(Boolean)** -Add a LoRA adapter to this context +Set whether to use causal attention or not. If set to true, the model will only attend to the past tokens ```csharp -public void AddLoraAdapter(LoraAdapter lora, float scale) +public void SetCausalAttention(bool value) ``` #### Parameters -`lora` [LoraAdapter](./llama.native.loraadapter.md)
+`value` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
-`scale` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+### **SetEmbeddings(Boolean)** -#### Exceptions +Set whether the context outputs embeddings or not -[ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentexception)
+```csharp +public void SetEmbeddings(bool value) +``` -[RuntimeError](./llama.exceptions.runtimeerror.md)
+#### Parameters + +`value` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+If true, embeddings will be returned but logits will not -### **RemoveLoraAdapter(LoraAdapter)** +### **SetLoraAdapters(Span<(LoraAdapter, Single)>)** -Remove a LoRA adapter from this context +Set the LoRa adapters on the context ```csharp -public bool RemoveLoraAdapter(LoraAdapter lora) +public void SetLoraAdapters(Span<(LoraAdapter Adapter, float Scale)> adapters) ``` #### Parameters -`lora` [LoraAdapter](./llama.native.loraadapter.md)
- -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
-Indicates if the lora was in this context and was remove +`adapters` [Span<(LoraAdapter, Single)>](https://learn.microsoft.com/en-us/dotnet/api/system.span-1)
-### **ClearLoraAdapters()** +#### Exceptions -Remove all LoRA adapters from this context - -```csharp -public void ClearLoraAdapters() -``` +[ArgumentException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentexception)
### **GetLogits(Int32)** @@ -263,19 +283,19 @@ Token logits obtained from the last call to llama_decode. Cols: n_vocab ```csharp -public Span GetLogits(int numTokens) +public Span GetLogits(int numTokens = 1) ``` #### Parameters -`numTokens` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`numTokens` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
The amount of tokens whose logits should be retrieved, in [numTokens X n_vocab] format.
Tokens' order is based on their order in the LlamaBatch (so, first tokens are first, etc).
This is helpful when requesting logits for many tokens in a sequence, or want to decode multiple sequences in one go. #### Returns -[Span<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1)
+[Span<Single>](https://learn.microsoft.com/en-us/dotnet/api/system.span-1)
### **GetLogitsIth(Int32)** @@ -287,11 +307,11 @@ public Span GetLogitsIth(int i) #### Parameters -`i` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`i` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
#### Returns -[Span<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1)
+[Span<Single>](https://learn.microsoft.com/en-us/dotnet/api/system.span-1)
### **GetEmbeddingsIth(LLamaPos)** @@ -308,7 +328,7 @@ public Span GetEmbeddingsIth(LLamaPos pos) #### Returns -[Span<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1)
+[Span<Single>](https://learn.microsoft.com/en-us/dotnet/api/system.span-1)
A pointer to the first float in an embedding, length = ctx.EmbeddingSize ### **GetEmbeddingsSeq(LLamaSeqId)** @@ -326,7 +346,7 @@ public Span GetEmbeddingsSeq(LLamaSeqId seq) #### Returns -[Span<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1)
+[Span<Single>](https://learn.microsoft.com/en-us/dotnet/api/system.span-1)
A pointer to the first float in an embedding, length = ctx.EmbeddingSize ### **Tokenize(String, Boolean, Boolean, Encoding)** @@ -339,16 +359,16 @@ public LLamaToken[] Tokenize(string text, bool add_bos, bool special, Encoding e #### Parameters -`text` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`text` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
The text to tokenize -`add_bos` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`add_bos` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
Whether the "BOS" token should be added -`special` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`special` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
Allow tokenizing special and/or control tokens which otherwise are not exposed and treated as plaintext. -`encoding` [Encoding](https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding)
+`encoding` [Encoding](https://learn.microsoft.com/en-us/dotnet/api/system.text.encoding)
Encoding to use for the text #### Returns @@ -372,12 +392,12 @@ public uint TokenToSpan(LLamaToken token, Span dest) `token` [LLamaToken](./llama.native.llamatoken.md)
Token to decode -`dest` [Span<Byte>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1)
+`dest` [Span<Byte>](https://learn.microsoft.com/en-us/dotnet/api/system.span-1)
A span to attempt to write into. If this is too small nothing will be written #### Returns -[UInt32](https://docs.microsoft.com/en-us/dotnet/api/system.uint32)
+[UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
The size of this token. **nothing will be written** if this is larger than `dest` ### **Synchronize()** @@ -405,11 +425,22 @@ public DecodeResult Encode(LLamaBatch batch) #### Returns [DecodeResult](./llama.native.decoderesult.md)
-0 = success
< 0 = error (the KV cache state is restored to the state before this call) +0 = success
< 0 = error (the memory state is restored to the state before this call) ### **Decode(LLamaBatch)** - +Process a batch of tokens. + Requires the context to have a memory. + For encode-decoder contexts, processes the batch using the decoder. + Positive return values does not mean a fatal error, but rather a warning. + Upon fatal-error or abort, the ubatches that managed to be been processed will remain in the memory state of the context + To handle this correctly, query the memory state using llama_memory_seq_pos_min() and llama_memory_seq_pos_max() + Upon other return values, the memory state is restored to the state before this call + 0 - success + 1 - could not find a memory slot for the batch (try reducing the size of the batch or increase the context) + 2 - aborted (processed ubatches will remain in the context's memory) + -1 - invalid input batch + < -1 - fatal error (processed ubatches will remain in the context's memory) ```csharp public DecodeResult Decode(LLamaBatch batch) @@ -422,14 +453,21 @@ public DecodeResult Decode(LLamaBatch batch) #### Returns [DecodeResult](./llama.native.decoderesult.md)
-Positive return values does not mean a fatal error, but rather a warning:
- - 0: success
- - 1: could not find a KV slot for the batch (try reducing the size of the batch or increase the context)
- - < 0: error (the KV cache state is restored to the state before this call)
### **Decode(LLamaBatchEmbeddings)** - +Process a batch of tokens. + Requires the context to have a memory. + For encode-decoder contexts, processes the batch using the decoder. + Positive return values does not mean a fatal error, but rather a warning. + Upon fatal-error or abort, the ubatches that managed to be been processed will remain in the memory state of the context + To handle this correctly, query the memory state using llama_memory_seq_pos_min() and llama_memory_seq_pos_max() + Upon other return values, the memory state is restored to the state before this call + 0 - success + 1 - could not find a memory slot for the batch (try reducing the size of the batch or increase the context) + 2 - aborted (processed ubatches will remain in the context's memory) + -1 - invalid input batch + < -1 - fatal error (processed ubatches will remain in the context's memory) ```csharp public DecodeResult Decode(LLamaBatchEmbeddings batch) @@ -442,10 +480,6 @@ public DecodeResult Decode(LLamaBatchEmbeddings batch) #### Returns [DecodeResult](./llama.native.decoderesult.md)
-Positive return values does not mean a fatal error, but rather a warning:
- - 0: success
- - 1: could not find a KV slot for the batch (try reducing the size of the batch or increase the context)
- - < 0: error
### **GetStateSize()** @@ -457,11 +491,11 @@ public UIntPtr GetStateSize() #### Returns -[UIntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.uintptr)
+[UIntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.uintptr)
### **GetStateSize(LLamaSeqId)** -Get the size of the KV cache for a single sequence ID, when saved as bytes +Get the size of the memory state for a single sequence ID, when saved as bytes ```csharp public UIntPtr GetStateSize(LLamaSeqId sequence) @@ -473,7 +507,7 @@ public UIntPtr GetStateSize(LLamaSeqId sequence) #### Returns -[UIntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.uintptr)
+[UIntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.uintptr)
### **GetState(Byte*, UIntPtr)** @@ -485,20 +519,20 @@ public UIntPtr GetState(Byte* dest, UIntPtr size) #### Parameters -`dest` [Byte*](https://docs.microsoft.com/en-us/dotnet/api/system.byte*)
+`dest` [Byte*](https://learn.microsoft.com/en-us/dotnet/api/system.byte*)
Destination to write to -`size` [UIntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.uintptr)
+`size` [UIntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.uintptr)
Number of bytes available to write to in dest (check required size with `GetStateSize()`) #### Returns -[UIntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.uintptr)
+[UIntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.uintptr)
The number of bytes written to dest #### Exceptions -[ArgumentOutOfRangeException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentoutofrangeexception)
+[ArgumentOutOfRangeException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentoutofrangeexception)
Thrown if dest is too small ### **GetState(Byte*, UIntPtr, LLamaSeqId)** @@ -511,10 +545,10 @@ public UIntPtr GetState(Byte* dest, UIntPtr size, LLamaSeqId sequence) #### Parameters -`dest` [Byte*](https://docs.microsoft.com/en-us/dotnet/api/system.byte*)
+`dest` [Byte*](https://learn.microsoft.com/en-us/dotnet/api/system.byte*)
Destination to write to -`size` [UIntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.uintptr)
+`size` [UIntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.uintptr)
Number of bytes available to write to in dest (check required size with `GetStateSize()`) `sequence` [LLamaSeqId](./llama.native.llamaseqid.md)
@@ -522,7 +556,7 @@ The sequence to get state data for #### Returns -[UIntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.uintptr)
+[UIntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.uintptr)
The number of bytes written to dest ### **SetState(Byte*, UIntPtr)** @@ -535,15 +569,15 @@ public UIntPtr SetState(Byte* src, UIntPtr size) #### Parameters -`src` [Byte*](https://docs.microsoft.com/en-us/dotnet/api/system.byte*)
+`src` [Byte*](https://learn.microsoft.com/en-us/dotnet/api/system.byte*)
The pointer to read the state from -`size` [UIntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.uintptr)
+`size` [UIntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.uintptr)
Number of bytes that can be safely read from the pointer #### Returns -[UIntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.uintptr)
+[UIntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.uintptr)
Number of bytes read from the src pointer ### **SetState(Byte*, UIntPtr, LLamaSeqId)** @@ -556,10 +590,10 @@ public UIntPtr SetState(Byte* src, UIntPtr size, LLamaSeqId sequence) #### Parameters -`src` [Byte*](https://docs.microsoft.com/en-us/dotnet/api/system.byte*)
+`src` [Byte*](https://learn.microsoft.com/en-us/dotnet/api/system.byte*)
The pointer to read the state from -`size` [UIntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.uintptr)
+`size` [UIntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.uintptr)
Number of bytes that can be safely read from the pointer `sequence` [LLamaSeqId](./llama.native.llamaseqid.md)
@@ -567,7 +601,7 @@ Sequence ID to set #### Returns -[UIntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.uintptr)
+[UIntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.uintptr)
Number of bytes read from the src pointer ### **GetTimings()** @@ -590,79 +624,25 @@ Reset all performance information for this context public void ResetTimings() ``` -### **KvCacheUpdate()** - -Apply KV cache updates (such as K-shifts, defragmentation, etc.) - -```csharp -public void KvCacheUpdate() -``` - -### **KvCacheDefrag()** - -Defragment the KV cache. This will be applied: - - lazily on next llama_decode() - - explicitly with llama_kv_self_update() - -```csharp -public void KvCacheDefrag() -``` - -### **KvCacheGetDebugView(Int32)** +### **MemoryClear(Boolean)** -Get a new KV cache view that can be used to debug the KV cache +Clear the memory ```csharp -public LLamaKvCacheViewSafeHandle KvCacheGetDebugView(int maxSequences) +public void MemoryClear(bool data = true) ``` #### Parameters -`maxSequences` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -#### Returns - -[LLamaKvCacheViewSafeHandle](./llama.native.llamakvcacheviewsafehandle.md)
- -### **KvCacheCountCells()** - -Count the number of used cells in the KV cache (i.e. have at least one sequence assigned to them) - -```csharp -public int KvCacheCountCells() -``` - -#### Returns - -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -### **KvCacheCountTokens()** - -Returns the number of tokens in the KV cache (slow, use only for debug) - If a KV cell has multiple sequences assigned to it, it will be counted multiple times - -```csharp -public int KvCacheCountTokens() -``` - -#### Returns +`data` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+If true, the data buffers will also be cleared together with the metadata -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -### **KvCacheClear()** - -Clear the KV cache - both cell info is erased and KV data is zeroed - -```csharp -public void KvCacheClear() -``` - -### **KvCacheRemove(LLamaSeqId, LLamaPos, LLamaPos)** +### **MemorySequenceRemove(LLamaSeqId, LLamaPos, LLamaPos)** Removes all tokens that belong to the specified sequence and have positions in [p0, p1) ```csharp -public void KvCacheRemove(LLamaSeqId seq, LLamaPos p0, LLamaPos p1) +public void MemorySequenceRemove(LLamaSeqId seq, LLamaPos p0, LLamaPos p1) ``` #### Parameters @@ -673,14 +653,14 @@ public void KvCacheRemove(LLamaSeqId seq, LLamaPos p0, LLamaPos p1) `p1` [LLamaPos](./llama.native.llamapos.md)
-### **KvCacheSequenceCopy(LLamaSeqId, LLamaSeqId, LLamaPos, LLamaPos)** +### **MemorySequenceCopy(LLamaSeqId, LLamaSeqId, LLamaPos, LLamaPos)** Copy all tokens that belong to the specified sequence to another sequence. Note that - this does not allocate extra KV cache memory - it simply assigns the tokens to the + this does not allocate extra memory - it simply assigns the tokens to the new sequence ```csharp -public void KvCacheSequenceCopy(LLamaSeqId src, LLamaSeqId dest, LLamaPos p0, LLamaPos p1) +public void MemorySequenceCopy(LLamaSeqId src, LLamaSeqId dest, LLamaPos p0, LLamaPos p1) ``` #### Parameters @@ -693,26 +673,25 @@ public void KvCacheSequenceCopy(LLamaSeqId src, LLamaSeqId dest, LLamaPos p0, LL `p1` [LLamaPos](./llama.native.llamapos.md)
-### **KvCacheSequenceKeep(LLamaSeqId)** +### **MemorySequenceKeep(LLamaSeqId)** Removes all tokens that do not belong to the specified sequence ```csharp -public void KvCacheSequenceKeep(LLamaSeqId seq) +public void MemorySequenceKeep(LLamaSeqId seq) ``` #### Parameters `seq` [LLamaSeqId](./llama.native.llamaseqid.md)
-### **KvCacheSequenceAdd(LLamaSeqId, LLamaPos, LLamaPos, Int32)** +### **MemorySequenceAdd(LLamaSeqId, LLamaPos, LLamaPos, Int32)** Adds relative position "delta" to all tokens that belong to the specified sequence - and have positions in [p0, p1. If the KV cache is RoPEd, the KV data is updated - accordingly + and have positions in [p0, p1) ```csharp -public void KvCacheSequenceAdd(LLamaSeqId seq, LLamaPos p0, LLamaPos p1, int delta) +public void MemorySequenceAdd(LLamaSeqId seq, LLamaPos p0, LLamaPos p1, int delta) ``` #### Parameters @@ -723,17 +702,16 @@ public void KvCacheSequenceAdd(LLamaSeqId seq, LLamaPos p0, LLamaPos p1, int del `p1` [LLamaPos](./llama.native.llamapos.md)
-`delta` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`delta` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
-### **KvCacheSequenceDivide(LLamaSeqId, LLamaPos, LLamaPos, Int32)** +### **MemorySequenceDivide(LLamaSeqId, LLamaPos, LLamaPos, Int32)** -Integer division of the positions by factor of `d > 1`. - If the KV cache is RoPEd, the KV data is updated accordingly.
+Integer division of the positions by factor of `d > 1`.
p0 < 0 : [0, p1]
p1 < 0 : [p0, inf) ```csharp -public void KvCacheSequenceDivide(LLamaSeqId seq, LLamaPos p0, LLamaPos p1, int divisor) +public void MemorySequenceDivide(LLamaSeqId seq, LLamaPos p0, LLamaPos p1, int divisor) ``` #### Parameters @@ -744,14 +722,30 @@ public void KvCacheSequenceDivide(LLamaSeqId seq, LLamaPos p0, LLamaPos p1, int `p1` [LLamaPos](./llama.native.llamapos.md)
-`divisor` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`divisor` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **MemorySequenceMinPosition(LLamaSeqId)** + +Returns the smallest position present in memory for the specified sequence + +```csharp +public LLamaPos MemorySequenceMinPosition(LLamaSeqId seq) +``` + +#### Parameters + +`seq` [LLamaSeqId](./llama.native.llamaseqid.md)
+ +#### Returns + +[LLamaPos](./llama.native.llamapos.md)
-### **KvCacheMaxPosition(LLamaSeqId)** +### **MemorySequenceMaxPosition(LLamaSeqId)** -Returns the largest position present in the KV cache for the specified sequence +Returns the largest position present in memory for the specified sequence ```csharp -public LLamaPos KvCacheMaxPosition(LLamaSeqId seq) +public LLamaPos MemorySequenceMaxPosition(LLamaSeqId seq) ``` #### Parameters diff --git a/docs/xmldocs/llama.native.safellamahandlebase.md b/docs/xmldocs/llama.native.safellamahandlebase.md index ab0622dfd..38d7e222d 100644 --- a/docs/xmldocs/llama.native.safellamahandlebase.md +++ b/docs/xmldocs/llama.native.safellamahandlebase.md @@ -12,8 +12,8 @@ Base class for all llama handles to native resources public abstract class SafeLLamaHandleBase : System.Runtime.InteropServices.SafeHandle, System.IDisposable ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [CriticalFinalizerObject](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.constrainedexecution.criticalfinalizerobject) → [SafeHandle](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.safehandle) → [SafeLLamaHandleBase](./llama.native.safellamahandlebase.md)
-Implements [IDisposable](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [CriticalFinalizerObject](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.constrainedexecution.criticalfinalizerobject) → [SafeHandle](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.safehandle) → [SafeLLamaHandleBase](./llama.native.safellamahandlebase.md)
+Implements [IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable) ## Fields @@ -28,12 +28,12 @@ protected IntPtr handle; ### **IsInvalid** ```csharp -public bool IsInvalid { get; } +public override bool IsInvalid { get; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **IsClosed** @@ -43,19 +43,19 @@ public bool IsClosed { get; } #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
## Methods ### **ToString()** ```csharp -public string ToString() +public override string ToString() ``` #### Returns -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
--- diff --git a/docs/xmldocs/llama.native.safellamamodelhandle.md b/docs/xmldocs/llama.native.safellamamodelhandle.md index 7276357e2..385071303 100644 --- a/docs/xmldocs/llama.native.safellamamodelhandle.md +++ b/docs/xmldocs/llama.native.safellamamodelhandle.md @@ -12,9 +12,9 @@ A reference to a set of llama model weights public sealed class SafeLlamaModelHandle : SafeLLamaHandleBase, System.IDisposable ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [CriticalFinalizerObject](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.constrainedexecution.criticalfinalizerobject) → [SafeHandle](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.safehandle) → [SafeLLamaHandleBase](./llama.native.safellamahandlebase.md) → [SafeLlamaModelHandle](./llama.native.safellamamodelhandle.md)
-Implements [IDisposable](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [CriticalFinalizerObject](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.constrainedexecution.criticalfinalizerobject) → [SafeHandle](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.safehandle) → [SafeLLamaHandleBase](./llama.native.safellamahandlebase.md) → [SafeLlamaModelHandle](./llama.native.safellamamodelhandle.md)
+Implements [IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Fields @@ -48,7 +48,7 @@ public int ContextSize { get; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **RopeFrequency** @@ -60,7 +60,7 @@ public float RopeFrequency { get; } #### Property Value -[Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+[Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
### **EmbeddingSize** @@ -72,7 +72,7 @@ public int EmbeddingSize { get; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **SizeInBytes** @@ -84,7 +84,7 @@ public ulong SizeInBytes { get; } #### Property Value -[UInt64](https://docs.microsoft.com/en-us/dotnet/api/system.uint64)
+[UInt64](https://learn.microsoft.com/en-us/dotnet/api/system.uint64)
### **ParameterCount** @@ -96,7 +96,7 @@ public ulong ParameterCount { get; } #### Property Value -[UInt64](https://docs.microsoft.com/en-us/dotnet/api/system.uint64)
+[UInt64](https://learn.microsoft.com/en-us/dotnet/api/system.uint64)
### **LayerCount** @@ -108,7 +108,19 @@ public int LayerCount { get; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **LayerCountMtp** + +Get the number of MTP layers in this model + +```csharp +public int LayerCountMtp { get; } +``` + +#### Property Value + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **HeadCount** @@ -120,7 +132,7 @@ public int HeadCount { get; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **KVHeadCount** @@ -132,7 +144,19 @@ public int KVHeadCount { get; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **SWACount** + +Get the number of SWA in this model + +```csharp +public int SWACount { get; } +``` + +#### Property Value + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **HasEncoder** @@ -144,7 +168,7 @@ public bool HasEncoder { get; } #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **HasDecoder** @@ -156,7 +180,7 @@ public bool HasDecoder { get; } #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **IsRecurrent** @@ -168,7 +192,19 @@ public bool IsRecurrent { get; } #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **IsDiffusion** + +Returns true if the model is diffusion based (like LLaDA , Dream etc ) + +```csharp +public bool IsDiffusion { get; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **Description** @@ -180,7 +216,19 @@ public string Description { get; } #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **FileType** + +Get the file quantisation type of this model + +```csharp +public LLamaFtype FileType { get; } +``` + +#### Property Value + +[LLamaFtype](./llama.native.llamaftype.md)
### **MetadataCount** @@ -192,7 +240,7 @@ public int MetadataCount { get; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **Vocab** @@ -209,12 +257,12 @@ public Vocabulary Vocab { get; } ### **IsInvalid** ```csharp -public bool IsInvalid { get; } +public override bool IsInvalid { get; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **IsClosed** @@ -224,7 +272,7 @@ public bool IsClosed { get; } #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
## Constructors @@ -239,12 +287,12 @@ public SafeLlamaModelHandle() ### **ReleaseHandle()** ```csharp -protected bool ReleaseHandle() +protected override bool ReleaseHandle() ``` #### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **LoadFromFile(String, LLamaModelParams)** @@ -256,7 +304,7 @@ public static SafeLlamaModelHandle LoadFromFile(string modelPath, LLamaModelPara #### Parameters -`modelPath` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`modelPath` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
`lparams` [LLamaModelParams](./llama.native.llamamodelparams.md)
@@ -268,6 +316,18 @@ public static SafeLlamaModelHandle LoadFromFile(string modelPath, LLamaModelPara [RuntimeError](./llama.exceptions.runtimeerror.md)
+### **SaveToFile(String)** + +Save this model to a file + +```csharp +public void SaveToFile(string modelPath) +``` + +#### Parameters + +`modelPath` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ ### **LoadLoraFromFile(String)** Load a LoRA adapter from file. The adapter will be associated with this model but will not be applied @@ -278,7 +338,7 @@ public LoraAdapter LoadLoraFromFile(string path) #### Parameters -`path` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`path` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
#### Returns @@ -286,14 +346,14 @@ public LoraAdapter LoadLoraFromFile(string path) #### Exceptions -[InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
+[InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
### **TokenToSpan(LLamaToken, Span<Byte>, Int32, Boolean)** Convert a single llama token into bytes ```csharp -public uint TokenToSpan(LLamaToken token, Span dest, int lstrip, bool special) +public uint TokenToSpan(LLamaToken token, Span dest, int lstrip = 0, bool special = false) ``` #### Parameters @@ -301,18 +361,18 @@ public uint TokenToSpan(LLamaToken token, Span dest, int lstrip, bool spec `token` [LLamaToken](./llama.native.llamatoken.md)
Token to decode -`dest` [Span<Byte>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1)
+`dest` [Span<Byte>](https://learn.microsoft.com/en-us/dotnet/api/system.span-1)
A span to attempt to write into. If this is too small nothing will be written -`lstrip` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`lstrip` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
User can skip up to 'lstrip' leading spaces before copying (useful when encoding/decoding multiple tokens with 'add_space_prefix') -`special` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`special` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
If true, special characters will be converted to text. If false they will be invisible. #### Returns -[UInt32](https://docs.microsoft.com/en-us/dotnet/api/system.uint32)
+[UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
The size of this token. **nothing will be written** if this is larger than `dest` ### **Tokenize(String, Boolean, Boolean, Encoding)** @@ -325,14 +385,14 @@ public LLamaToken[] Tokenize(string text, bool addBos, bool special, Encoding en #### Parameters -`text` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`text` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
-`addBos` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`addBos` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
-`special` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`special` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
Allow tokenizing special and/or control tokens which otherwise are not exposed and treated as plaintext. -`encoding` [Encoding](https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding)
+`encoding` [Encoding](https://learn.microsoft.com/en-us/dotnet/api/system.text.encoding)
#### Returns @@ -359,17 +419,17 @@ public SafeLLamaContextHandle CreateContext(LLamaContextParams params) Get the metadata value for the given key ```csharp -public Nullable> MetadataValueByKey(string key) +public Memory? MetadataValueByKey(string key) ``` #### Parameters -`key` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`key` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
The key to fetch #### Returns -[Nullable<Memory<Byte>>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[Memory<Byte>?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
The value, null if there is no such key ### **MetadataKeyByIndex(Int32)** @@ -377,17 +437,17 @@ The value, null if there is no such key Get the metadata key for the given index ```csharp -public Nullable> MetadataKeyByIndex(int index) +public Memory? MetadataKeyByIndex(int index) ``` #### Parameters -`index` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`index` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
The index to get #### Returns -[Nullable<Memory<Byte>>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[Memory<Byte>?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
The key, null if there is no such key or if the buffer was too small ### **MetadataValueByIndex(Int32)** @@ -395,17 +455,17 @@ The key, null if there is no such key or if the buffer was too small Get the metadata value for the given index ```csharp -public Nullable> MetadataValueByIndex(int index) +public Memory? MetadataValueByIndex(int index) ``` #### Parameters -`index` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`index` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
The index to get #### Returns -[Nullable<Memory<Byte>>](https://docs.microsoft.com/en-us/dotnet/api/system.nullable-1)
+[Memory<Byte>?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
The value, null if there is no such value or if the buffer was too small ### **GetTemplate(String, Boolean)** @@ -414,20 +474,20 @@ Get the default chat template. Returns nullptr if not available If name is NULL, returns the default chat template ```csharp -public string GetTemplate(string name, bool strict) +public string? GetTemplate(string? name = null, bool strict = true) ``` #### Parameters -`name` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`name` [String](https://learn.microsoft.com/en-us/dotnet/api/system.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](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`strict` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
Setting this to true will cause the call to throw if no valid templates are found. #### Returns -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)?
--- diff --git a/docs/xmldocs/llama.native.safellamamodelhandle.vocabulary.md b/docs/xmldocs/llama.native.safellamamodelhandle.vocabulary.md new file mode 100644 index 000000000..3851cc720 --- /dev/null +++ b/docs/xmldocs/llama.native.safellamamodelhandle.vocabulary.md @@ -0,0 +1,259 @@ +[`< Back`](./) + +--- + +# Vocabulary + +Namespace: LLama.Native + +Get tokens for a model + +```csharp +internal sealed class Vocabulary +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [Vocabulary](./llama.native.safellamamodelhandle.vocabulary.md)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute) + +## Properties + +### **Count** + +Total number of tokens in this vocabulary + +```csharp +public int Count { get; } +``` + +#### Property Value + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **Type** + +Get the type of this vocabulary + +```csharp +public LLamaVocabType Type { get; } +``` + +#### Property Value + +[LLamaVocabType](./llama.native.llamavocabtype.md)
+ +### **BOS** + +Get the Beginning of Sentence token for this model + +```csharp +public LLamaToken? BOS { get; } +``` + +#### Property Value + +[LLamaToken?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
+ +### **EOS** + +Get the End of Sentence token for this model + +```csharp +public LLamaToken? EOS { get; } +``` + +#### Property Value + +[LLamaToken?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
+ +### **Newline** + +Get the newline token for this model + +```csharp +public LLamaToken? Newline { get; } +``` + +#### Property Value + +[LLamaToken?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
+ +### **Pad** + +Get the padding token for this model + +```csharp +public LLamaToken? Pad { get; } +``` + +#### Property Value + +[LLamaToken?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
+ +### **Mask** + +Get the masking token for this model + +```csharp +public LLamaToken? Mask { get; } +``` + +#### Property Value + +[LLamaToken?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
+ +### **SEP** + +Get the sentence separator token for this model + +```csharp +public LLamaToken? SEP { get; } +``` + +#### Property Value + +[LLamaToken?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
+ +### **InfillPrefix** + +Codellama beginning of infill prefix + +```csharp +public LLamaToken? InfillPrefix { get; } +``` + +#### Property Value + +[LLamaToken?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
+ +### **InfillMiddle** + +Codellama beginning of infill middle + +```csharp +public LLamaToken? InfillMiddle { get; } +``` + +#### Property Value + +[LLamaToken?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
+ +### **InfillSuffix** + +Codellama beginning of infill suffix + +```csharp +public LLamaToken? InfillSuffix { get; } +``` + +#### Property Value + +[LLamaToken?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
+ +### **InfillPad** + +Codellama pad + +```csharp +public LLamaToken? InfillPad { get; } +``` + +#### Property Value + +[LLamaToken?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
+ +### **InfillRep** + +Codellama rep + +```csharp +public LLamaToken? InfillRep { get; } +``` + +#### Property Value + +[LLamaToken?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
+ +### **InfillSep** + +Codellama rep + +```csharp +public LLamaToken? InfillSep { get; } +``` + +#### Property Value + +[LLamaToken?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
+ +### **EOT** + +end-of-turn token + +```csharp +public LLamaToken? EOT { get; } +``` + +#### Property Value + +[LLamaToken?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
+ +### **DecoderStartToken** + +For encoder-decoder models, this function returns id of the token that must be provided + to the decoder to start generating output sequence. + +```csharp +public LLamaToken? DecoderStartToken { get; } +``` + +#### Property Value + +[LLamaToken?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
+ +### **ShouldAddBOS** + +Check if the current model requires a BOS token added + +```csharp +public bool ShouldAddBOS { get; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **ShouldAddEOS** + +Check if the current model requires a EOS token added + +```csharp +public bool ShouldAddEOS { get; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +## Methods + +### **LLamaTokenToString(LLamaToken?, Boolean)** + +Translate LLamaToken to String + +```csharp +public string? LLamaTokenToString(LLamaToken? token, bool isSpecialToken) +``` + +#### Parameters + +`token` [LLamaToken?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
+ +`isSpecialToken` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +#### Returns + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)?
+ +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.native.safellamasamplerchainhandle.md b/docs/xmldocs/llama.native.safellamasamplerchainhandle.md index 7eece9ec7..e83429878 100644 --- a/docs/xmldocs/llama.native.safellamasamplerchainhandle.md +++ b/docs/xmldocs/llama.native.safellamasamplerchainhandle.md @@ -12,9 +12,9 @@ A chain of sampler stages that can be used to select tokens from logits. public sealed class SafeLLamaSamplerChainHandle : SafeLLamaHandleBase, System.IDisposable ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [CriticalFinalizerObject](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.constrainedexecution.criticalfinalizerobject) → [SafeHandle](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.safehandle) → [SafeLLamaHandleBase](./llama.native.safellamahandlebase.md) → [SafeLLamaSamplerChainHandle](./llama.native.safellamasamplerchainhandle.md)
-Implements [IDisposable](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [CriticalFinalizerObject](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.constrainedexecution.criticalfinalizerobject) → [SafeHandle](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.safehandle) → [SafeLLamaHandleBase](./llama.native.safellamahandlebase.md) → [SafeLLamaSamplerChainHandle](./llama.native.safellamasamplerchainhandle.md)
+Implements [IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) **Remarks:** @@ -40,17 +40,17 @@ public int Count { get; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **IsInvalid** ```csharp -public bool IsInvalid { get; } +public override bool IsInvalid { get; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **IsClosed** @@ -60,7 +60,7 @@ public bool IsClosed { get; } #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
## Constructors @@ -75,24 +75,24 @@ public SafeLLamaSamplerChainHandle() ### **ReleaseHandle()** ```csharp -protected bool ReleaseHandle() +protected override bool ReleaseHandle() ``` #### Returns -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
-### **Apply(LLamaTokenDataArrayNative&)** +### **Apply(ref LLamaTokenDataArrayNative)** Apply this sampler to a set of candidates ```csharp -public void Apply(LLamaTokenDataArrayNative& candidates) +public void Apply(ref LLamaTokenDataArrayNative candidates) ``` #### Parameters -`candidates` [LLamaTokenDataArrayNative&](./llama.native.llamatokendataarraynative&.md)
+`ref` `candidates` [LLamaTokenDataArrayNative](./llama.native.llamatokendataarraynative.md)
### **Sample(SafeLLamaContextHandle, Int32)** @@ -116,7 +116,7 @@ public LLamaToken Sample(SafeLLamaContextHandle context, int index) `context` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
-`index` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`index` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
#### Returns @@ -152,11 +152,11 @@ public string GetName(int index) #### Parameters -`index` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`index` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
#### Returns -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **GetSeed(Int32)** @@ -168,11 +168,11 @@ public uint GetSeed(int index) #### Parameters -`index` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`index` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
#### Returns -[UInt32](https://docs.microsoft.com/en-us/dotnet/api/system.uint32)
+[UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
### **Create(LLamaSamplerChainParams)** @@ -203,7 +203,7 @@ public void AddClone(SafeLLamaSamplerChainHandle src, int index) `src` [SafeLLamaSamplerChainHandle](./llama.native.safellamasamplerchainhandle.md)
The chain to clone a stage from -`index` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`index` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
The index of the stage to clone ### **Remove(Int32)** @@ -216,18 +216,18 @@ public void Remove(int index) #### Parameters -`index` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`index` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
#### Exceptions -[ArgumentOutOfRangeException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentoutofrangeexception)
+[ArgumentOutOfRangeException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentoutofrangeexception)
### **AddCustom<TSampler>(TSampler)** Add a custom sampler stage ```csharp -public void AddCustom(TSampler sampler) +public void AddCustom(TSampler sampler) where TSampler : class, ICustomSampler ``` #### Type Parameters @@ -256,7 +256,7 @@ public void AddDistributionSampler(uint seed) #### Parameters -`seed` [UInt32](https://docs.microsoft.com/en-us/dotnet/api/system.uint32)
+`seed` [UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
### **AddMirostat1Sampler(Int32, UInt32, Single, Single, Int32)** @@ -268,17 +268,17 @@ public void AddMirostat1Sampler(int vocabCount, uint seed, float tau, float eta, #### Parameters -`vocabCount` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`vocabCount` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
-`seed` [UInt32](https://docs.microsoft.com/en-us/dotnet/api/system.uint32)
+`seed` [UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
-`tau` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`tau` [Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
The target cross-entropy (or surprise) value you want to achieve for the generated text. A higher value corresponds to more surprising or less predictable text, while a lower value corresponds to less surprising or more predictable text. -`eta` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`eta` [Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
The learning rate used to update `mu` based on the error between the target and observed surprisal of the sampled word. A larger learning rate will cause `mu` to be updated more quickly, while a smaller learning rate will result in slower updates. -`m` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`m` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
The number of tokens considered in the estimation of `s_hat`. This is an arbitrary value that is used to calculate `s_hat`, which in turn helps to calculate the value of `k`. In the paper, they use `m = 100`, but you can experiment with different values to see how it affects the performance of the algorithm. ### **AddMirostat2Sampler(UInt32, Single, Single)** @@ -291,12 +291,12 @@ public void AddMirostat2Sampler(uint seed, float tau, float eta) #### Parameters -`seed` [UInt32](https://docs.microsoft.com/en-us/dotnet/api/system.uint32)
+`seed` [UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
-`tau` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`tau` [Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
The target cross-entropy (or surprise) value you want to achieve for the generated text. A higher value corresponds to more surprising or less predictable text, while a lower value corresponds to less surprising or more predictable text. -`eta` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`eta` [Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
The learning rate used to update `mu` based on the error between the target and observed surprisal of the sampled word. A larger learning rate will cause `mu` to be updated more quickly, while a smaller learning rate will result in slower updates. ### **AddTopK(Int32)** @@ -309,7 +309,7 @@ public void AddTopK(int k) #### Parameters -`k` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`k` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
**Remarks:** @@ -325,7 +325,7 @@ public void AddTopNSigma(float n) #### Parameters -`n` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`n` [Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
### **AddTopP(Single, IntPtr)** @@ -337,9 +337,9 @@ public void AddTopP(float p, IntPtr minKeep) #### Parameters -`p` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`p` [Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
-`minKeep` [IntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.intptr)
+`minKeep` [IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
### **AddMinP(Single, IntPtr)** @@ -351,9 +351,9 @@ public void AddMinP(float p, IntPtr minKeep) #### Parameters -`p` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`p` [Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
-`minKeep` [IntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.intptr)
+`minKeep` [IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
### **AddTypical(Single, IntPtr)** @@ -365,9 +365,9 @@ public void AddTypical(float p, IntPtr minKeep) #### Parameters -`p` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`p` [Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
-`minKeep` [IntPtr](https://docs.microsoft.com/en-us/dotnet/api/system.intptr)
+`minKeep` [IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
### **AddTemperature(Single)** @@ -380,7 +380,7 @@ public void AddTemperature(float t) #### Parameters -`t` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`t` [Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
### **AddDynamicTemperature(Single, Single, Single)** @@ -392,11 +392,11 @@ public void AddDynamicTemperature(float t, float delta, float exponent) #### Parameters -`t` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`t` [Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
-`delta` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`delta` [Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
-`exponent` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`exponent` [Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
### **AddXTC(Single, Single, Int32, UInt32)** @@ -408,13 +408,13 @@ public void AddXTC(float p, float t, int minKeep, uint seed) #### Parameters -`p` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`p` [Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
-`t` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`t` [Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
-`minKeep` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`minKeep` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
-`seed` [UInt32](https://docs.microsoft.com/en-us/dotnet/api/system.uint32)
+`seed` [UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
### **AddFillInMiddleInfill(SafeLlamaModelHandle)** @@ -455,9 +455,9 @@ public void AddGrammar(SafeLlamaModelHandle model, string grammar, string root) `model` [SafeLlamaModelHandle](./llama.native.safellamamodelhandle.md)
The model that this grammar will be used with -`grammar` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`grammar` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
-`root` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`root` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
Root rule of the grammar ### **AddGrammar(Vocabulary, String, String)** @@ -473,9 +473,9 @@ public void AddGrammar(Vocabulary vocab, string grammar, string root) `vocab` [Vocabulary](./llama.native.safellamamodelhandle.vocabulary.md)
The vocabulary that this grammar will be used with -`grammar` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`grammar` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
-`root` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`root` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
Root rule of the grammar ### **AddLazyGrammar(SafeLlamaModelHandle, String, String, ReadOnlySpan<String>, ReadOnlySpan<LLamaToken>)** @@ -490,16 +490,16 @@ public void AddLazyGrammar(SafeLlamaModelHandle model, string grammar, string ro `model` [SafeLlamaModelHandle](./llama.native.safellamamodelhandle.md)
-`grammar` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`grammar` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
Grammar in GBNF form -`root` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`root` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
Root rule of the grammar -`patterns` [ReadOnlySpan<String>](https://docs.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+`patterns` [ReadOnlySpan<String>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
A list of patterns that will trigger the grammar sampler. Pattern will be matched from the start of the generation output, and grammar sampler will be fed content starting from its first match group. -`triggerTokens` [ReadOnlySpan<LLamaToken>](https://docs.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+`triggerTokens` [ReadOnlySpan<LLamaToken>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
A list of tokens that will trigger the grammar sampler. Grammar sampler will be fed content starting from the trigger token included.. ### **AddPenalties(Int32, Single, Single, Single)** @@ -514,16 +514,16 @@ public void AddPenalties(int penaltyCount, float repeat, float freq, float prese #### Parameters -`penaltyCount` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`penaltyCount` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
How many tokens of history to consider when calculating penalties -`repeat` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`repeat` [Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
Repetition penalty -`freq` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`freq` [Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
Frequency penalty -`presence` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`presence` [Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
Presence penalty ### **AddDry(SafeLlamaModelHandle, ReadOnlySpan<String>, Single, Single, Int32, Int32)** @@ -532,7 +532,7 @@ DRY sampler, designed by p-e-w, as described in: https://github.com/oobabooga/te Porting Koboldcpp implementation authored by pi6am: https://github.com/LostRuins/koboldcpp/pull/982 ```csharp -public void AddDry(SafeLlamaModelHandle model, ReadOnlySpan sequenceBreakers, float multiplier, float base, int allowedLength, int penaltyLastN) +public void AddDry(SafeLlamaModelHandle model, ReadOnlySpan sequenceBreakers, float multiplier = 0.8f, float base = 1.75f, int allowedLength = 2, int penaltyLastN = 0) ``` #### Parameters @@ -540,20 +540,55 @@ public void AddDry(SafeLlamaModelHandle model, ReadOnlySpan sequenceBrea `model` [SafeLlamaModelHandle](./llama.native.safellamamodelhandle.md)
The model this sampler will be used with -`sequenceBreakers` [ReadOnlySpan<String>](https://docs.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+`sequenceBreakers` [ReadOnlySpan<String>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
-`multiplier` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`multiplier` [Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
penalty multiplier, 0.0 = disabled -`base` [Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+`base` [Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
exponential base -`allowedLength` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`allowedLength` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
repeated sequences longer than this are penalized -`penaltyLastN` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`penaltyLastN` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
how many tokens to scan for repetitions (0 = entire context) +### **AddAdaptiveP(Single, Single, UInt32)** + +Adaptive-p: select tokens near a configurable target probability over time. +

+ the adaptive-p sampler transforms the token probability distribution to favor tokens + that fall near a user-configurable probability target. +

+ internally, the sampler maintains an exponential moving average of the *ORIGINAL* + probabilities of selected tokens at each sampling step. it uses this EMA to compute an + adapted target probability at each sampling step, thus maintaining the desired target + probability over time. +

+ adaptive-p selects a token ID rather than just mutating candidates, so it must be last + in the sampler chain (like mirostat, dist, greedy). +

+ only mild truncation before this sampler is recommended. we suggest applying min-p + before adaptive-p as the only other active sampler in the chain. +

+ ref: https://github.com/ggml-org/llama.cpp/pull/17927 + +```csharp +public void AddAdaptiveP(float target, float decay, uint seed) +``` + +#### Parameters + +`target` [Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
+select tokens near this probability (valid range 0.0 to 1.0; negative = disabled) + +`decay` [Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
+EMA decay for adaptation; history ≈ 1/(1-decay) tokens (valid range 0.0 - 0.99) + +`seed` [UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
+RNG seed + ### **AddLogitBias(Int32, Span<LLamaLogitBias>)** Create a sampler that applies a bias directly to the logits @@ -564,9 +599,9 @@ public void AddLogitBias(int vocabSize, Span biases) #### Parameters -`vocabSize` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`vocabSize` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
-`biases` [Span<LLamaLogitBias>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1)
+`biases` [Span<LLamaLogitBias>](https://learn.microsoft.com/en-us/dotnet/api/system.span-1)
--- diff --git a/docs/xmldocs/llama.native.safellavaimageembedhandle.md b/docs/xmldocs/llama.native.safellavaimageembedhandle.md deleted file mode 100644 index 7da2ff7c3..000000000 --- a/docs/xmldocs/llama.native.safellavaimageembedhandle.md +++ /dev/null @@ -1,233 +0,0 @@ -[`< Back`](./) - ---- - -# SafeLlavaImageEmbedHandle - -Namespace: LLama.Native - -A Reference to a llava Image Embed handle - -```csharp -public sealed class SafeLlavaImageEmbedHandle : SafeLLamaHandleBase, System.IDisposable -``` - -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [CriticalFinalizerObject](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.constrainedexecution.criticalfinalizerobject) → [SafeHandle](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.safehandle) → [SafeLLamaHandleBase](./llama.native.safellamahandlebase.md) → [SafeLlavaImageEmbedHandle](./llama.native.safellavaimageembedhandle.md)
-Implements [IDisposable](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) - -## Fields - -### **handle** - -```csharp -protected IntPtr handle; -``` - -## Properties - -### **Model** - -Get the model used to create this image embedding - -```csharp -public SafeLlavaModelHandle Model { get; private set; } -``` - -#### Property Value - -[SafeLlavaModelHandle](./llama.native.safellavamodelhandle.md)
- -### **EmbeddingDimensions** - -Get the number of dimensions in an embedding - -```csharp -public int EmbeddingDimensions { get; } -``` - -#### Property Value - -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -### **PatchCount** - -Get the number of "patches" in an image embedding - -```csharp -public int PatchCount { get; } -``` - -#### Property Value - -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -### **IsInvalid** - -```csharp -public bool IsInvalid { get; } -``` - -#### Property Value - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -### **IsClosed** - -```csharp -public bool IsClosed { get; } -``` - -#### Property Value - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -## Constructors - -### **SafeLlavaImageEmbedHandle()** - -```csharp -public SafeLlavaImageEmbedHandle() -``` - -## Methods - -### **CreateFromFileName(SafeLlavaModelHandle, LLamaContext, String)** - -Create an image embed from an image file - -```csharp -public static SafeLlavaImageEmbedHandle CreateFromFileName(SafeLlavaModelHandle clip, LLamaContext ctx, string image) -``` - -#### Parameters - -`clip` [SafeLlavaModelHandle](./llama.native.safellavamodelhandle.md)
- -`ctx` [LLamaContext](./llama.llamacontext.md)
- -`image` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
-Path to the image file. Supported formats: - -- -- -- -- - -#### Returns - -[SafeLlavaImageEmbedHandle](./llama.native.safellavaimageembedhandle.md)
- -#### Exceptions - -[InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
- -### **CreateFromFileName(SafeLlavaModelHandle, String, Int32)** - -Create an image embed from an image file - -```csharp -public static SafeLlavaImageEmbedHandle CreateFromFileName(SafeLlavaModelHandle clip, string image, int threads) -``` - -#### Parameters - -`clip` [SafeLlavaModelHandle](./llama.native.safellavamodelhandle.md)
- -`image` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
-Path to the image file. Supported formats: - -- -- -- -- - -`threads` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -#### Returns - -[SafeLlavaImageEmbedHandle](./llama.native.safellavaimageembedhandle.md)
- -#### Exceptions - -[InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
- -### **CreateFromMemory(SafeLlavaModelHandle, LLamaContext, Byte[])** - -Create an image embed from the bytes of an image. - -```csharp -public static SafeLlavaImageEmbedHandle CreateFromMemory(SafeLlavaModelHandle clip, LLamaContext ctx, Byte[] image) -``` - -#### Parameters - -`clip` [SafeLlavaModelHandle](./llama.native.safellavamodelhandle.md)
- -`ctx` [LLamaContext](./llama.llamacontext.md)
- -`image` [Byte[]](https://docs.microsoft.com/en-us/dotnet/api/system.byte)
-Image bytes. Supported formats: - -- -- -- -- - -#### Returns - -[SafeLlavaImageEmbedHandle](./llama.native.safellavaimageembedhandle.md)
- -### **CreateFromMemory(SafeLlavaModelHandle, Byte[], Int32)** - -Create an image embed from the bytes of an image. - -```csharp -public static SafeLlavaImageEmbedHandle CreateFromMemory(SafeLlavaModelHandle clip, Byte[] image, int threads) -``` - -#### Parameters - -`clip` [SafeLlavaModelHandle](./llama.native.safellavamodelhandle.md)
- -`image` [Byte[]](https://docs.microsoft.com/en-us/dotnet/api/system.byte)
-Image bytes. Supported formats: - -- -- -- -- - -`threads` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -#### Returns - -[SafeLlavaImageEmbedHandle](./llama.native.safellavaimageembedhandle.md)
- -### **ReleaseHandle()** - -```csharp -protected bool ReleaseHandle() -``` - -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -### **GetEmbedding(Span<Single>, Int32)** - -Copy the embeddings data to the destination span - -```csharp -public void GetEmbedding(Span dest, int index) -``` - -#### Parameters - -`dest` [Span<Single>](https://docs.microsoft.com/en-us/dotnet/api/system.span-1)
- -`index` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- ---- - -[`< Back`](./) diff --git a/docs/xmldocs/llama.native.safellavamodelhandle.md b/docs/xmldocs/llama.native.safellavamodelhandle.md deleted file mode 100644 index 3778e9aa4..000000000 --- a/docs/xmldocs/llama.native.safellavamodelhandle.md +++ /dev/null @@ -1,229 +0,0 @@ -[`< Back`](./) - ---- - -# SafeLlavaModelHandle - -Namespace: LLama.Native - -A reference to a set of llava model weights. - -```csharp -public sealed class SafeLlavaModelHandle : SafeLLamaHandleBase, System.IDisposable -``` - -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [CriticalFinalizerObject](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.constrainedexecution.criticalfinalizerobject) → [SafeHandle](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.safehandle) → [SafeLLamaHandleBase](./llama.native.safellamahandlebase.md) → [SafeLlavaModelHandle](./llama.native.safellavamodelhandle.md)
-Implements [IDisposable](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) - -## Fields - -### **handle** - -```csharp -protected IntPtr handle; -``` - -## Properties - -### **EmbeddingDimensions** - -Get the number of dimensions in an embedding - -```csharp -public int EmbeddingDimensions { get; } -``` - -#### Property Value - -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -### **PatchCount** - -Get the number of "patches" in an image embedding - -```csharp -public int PatchCount { get; } -``` - -#### Property Value - -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -### **IsInvalid** - -```csharp -public bool IsInvalid { get; } -``` - -#### Property Value - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -### **IsClosed** - -```csharp -public bool IsClosed { get; } -``` - -#### Property Value - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -## Constructors - -### **SafeLlavaModelHandle()** - -```csharp -public SafeLlavaModelHandle() -``` - -## Methods - -### **ReleaseHandle()** - -```csharp -protected bool ReleaseHandle() -``` - -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -### **LoadFromFile(String, Int32)** - -Load a model from the given file path into memory - -```csharp -public static SafeLlavaModelHandle LoadFromFile(string modelPath, int verbosity) -``` - -#### Parameters - -`modelPath` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
-MMP File (Multi-Modal Projections) - -`verbosity` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
-Verbosity level - -#### Returns - -[SafeLlavaModelHandle](./llama.native.safellavamodelhandle.md)
-SafeHandle of the Clip Model - -#### Exceptions - -[InvalidOperationException](https://docs.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
- -[LoadWeightsFailedException](./llama.exceptions.loadweightsfailedexception.md)
- -### **CreateImageEmbeddings(LLamaContext, String)** - -Create the Image Embeddings. - -```csharp -public SafeLlavaImageEmbedHandle CreateImageEmbeddings(LLamaContext ctxLlama, string image) -``` - -#### Parameters - -`ctxLlama` [LLamaContext](./llama.llamacontext.md)
-LLama Context - -`image` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
-Image filename (it supports jpeg format only) - -#### Returns - -[SafeLlavaImageEmbedHandle](./llama.native.safellavaimageembedhandle.md)
-return the SafeHandle of these embeddings - -### **CreateImageEmbeddings(String, Int32)** - -Create the Image Embeddings. - -```csharp -public SafeLlavaImageEmbedHandle CreateImageEmbeddings(string image, int threads) -``` - -#### Parameters - -`image` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
-Image in binary format (it supports jpeg format only) - -`threads` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
-Number of threads to use - -#### Returns - -[SafeLlavaImageEmbedHandle](./llama.native.safellavaimageembedhandle.md)
-return the SafeHandle of these embeddings - -### **CreateImageEmbeddings(LLamaContext, Byte[])** - -Create the Image Embeddings. - -```csharp -public SafeLlavaImageEmbedHandle CreateImageEmbeddings(LLamaContext ctxLlama, Byte[] image) -``` - -#### Parameters - -`ctxLlama` [LLamaContext](./llama.llamacontext.md)
-LLama Context - -`image` [Byte[]](https://docs.microsoft.com/en-us/dotnet/api/system.byte)
-Image in binary format (it supports jpeg format only) - -#### Returns - -[SafeLlavaImageEmbedHandle](./llama.native.safellavaimageembedhandle.md)
-return the SafeHandle of these embeddings - -### **CreateImageEmbeddings(Byte[], Int32)** - -Create the Image Embeddings. - -```csharp -public SafeLlavaImageEmbedHandle CreateImageEmbeddings(Byte[] image, int threads) -``` - -#### Parameters - -`image` [Byte[]](https://docs.microsoft.com/en-us/dotnet/api/system.byte)
-Image in binary format (it supports jpeg format only) - -`threads` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
-Number of threads to use - -#### Returns - -[SafeLlavaImageEmbedHandle](./llama.native.safellavaimageembedhandle.md)
-return the SafeHandle of these embeddings - -### **EvalImageEmbed(LLamaContext, SafeLlavaImageEmbedHandle, Int32&)** - -Evaluates the image embeddings. - -```csharp -public bool EvalImageEmbed(LLamaContext ctxLlama, SafeLlavaImageEmbedHandle imageEmbed, Int32& n_past) -``` - -#### Parameters - -`ctxLlama` [LLamaContext](./llama.llamacontext.md)
-Llama Context - -`imageEmbed` [SafeLlavaImageEmbedHandle](./llama.native.safellavaimageembedhandle.md)
-The current embeddings to evaluate - -`n_past` [Int32&](https://docs.microsoft.com/en-us/dotnet/api/system.int32&)
- -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
-True on success - ---- - -[`< Back`](./) diff --git a/docs/xmldocs/llama.native.safemtmdembed.iembeddata.md b/docs/xmldocs/llama.native.safemtmdembed.iembeddata.md new file mode 100644 index 000000000..3cc99b4fd --- /dev/null +++ b/docs/xmldocs/llama.native.safemtmdembed.iembeddata.md @@ -0,0 +1,50 @@ +[`< Back`](./) + +--- + +# IEmbedData + +Namespace: LLama.Native + +Accessor for the raw data of a [SafeMtmdEmbed](./llama.native.safemtmdembed.md) + +```csharp +internal interface IEmbedData : System.IDisposable +``` + +Implements [IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable) + +## Properties + +### **Data** + +Get the raw data. Access to this span is only guaranteed to be valid until this accessor is disposed. + +```csharp +ReadOnlySpan Data { get; } +``` + +#### Property Value + +[ReadOnlySpan<Byte>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+ +#### Exceptions + +[ObjectDisposedException](https://learn.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
+Thrown if this accessor has been disposed + +### **IsValid** + +Indicates if this accessor is still valid (i.e. not disposed) + +```csharp +bool IsValid { get; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.native.safemtmdembed.md b/docs/xmldocs/llama.native.safemtmdembed.md new file mode 100644 index 000000000..d3c97e124 --- /dev/null +++ b/docs/xmldocs/llama.native.safemtmdembed.md @@ -0,0 +1,251 @@ +[`< Back`](./) + +--- + +# SafeMtmdEmbed + +Namespace: LLama.Native + +Managed wrapper around `mtmd_bitmap*` resources. Instances own the native pointer + and ensure proper cleanup when disposed. + +```csharp +public sealed class SafeMtmdEmbed : SafeLLamaHandleBase, System.IDisposable +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [CriticalFinalizerObject](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.constrainedexecution.criticalfinalizerobject) → [SafeHandle](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.safehandle) → [SafeLLamaHandleBase](./llama.native.safellamahandlebase.md) → [SafeMtmdEmbed](./llama.native.safemtmdembed.md)
+Implements [IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable) + +## Fields + +### **handle** + +```csharp +protected IntPtr handle; +``` + +## Properties + +### **Nx** + +Width of the bitmap in pixels (or number of samples for audio embeddings). + +```csharp +public uint Nx { get; } +``` + +#### Property Value + +[UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
+ +### **Ny** + +Height of the bitmap in pixels. For audio embeddings this is typically `1`. + +```csharp +public uint Ny { get; } +``` + +#### Property Value + +[UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
+ +### **IsAudio** + +Indicates whether the embedding stores audio data instead of image pixels. + +```csharp +public bool IsAudio { get; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **ByteCount** + +Get the byte count of the raw bitmap/audio data in this embed + +```csharp +public ulong ByteCount { get; } +``` + +#### Property Value + +[UInt64](https://learn.microsoft.com/en-us/dotnet/api/system.uint64)
+ +### **Id** + +Optional identifier assigned to this embedding. + +```csharp +public string? Id { get; set; } +``` + +#### Property Value + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **IsInvalid** + +```csharp +public override bool IsInvalid { get; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **IsClosed** + +```csharp +public bool IsClosed { get; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +## Methods + +### **FromRgbBytes(UInt32, UInt32, ReadOnlySpan<Byte>)** + +Create an embedding from raw RGB bytes. + +```csharp +public static SafeMtmdEmbed? FromRgbBytes(uint nx, uint ny, ReadOnlySpan rgbData) +``` + +#### Parameters + +`nx` [UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
+Width of the bitmap in pixels. + +`ny` [UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
+Height of the bitmap in pixels. + +`rgbData` [ReadOnlySpan<Byte>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+Packed RGB data (3 bytes per pixel). + +#### Returns + +[SafeMtmdEmbed](./llama.native.safemtmdembed.md)?
+Managed wrapper when initialization succeeds; otherwise `null`. + +#### Exceptions + +[ArgumentNullException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentnullexception)
+The RGB buffer is null. + +### **FromAudioSamples(ReadOnlySpan<Single>)** + +Create an embedding from PCM audio samples. + +```csharp +public static SafeMtmdEmbed? FromAudioSamples(ReadOnlySpan samples) +``` + +#### Parameters + +`samples` [ReadOnlySpan<Single>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+Array of mono PCM samples in float format. + +#### Returns + +[SafeMtmdEmbed](./llama.native.safemtmdembed.md)?
+Managed wrapper when initialization succeeds; otherwise `null`. + +#### Exceptions + +[ArgumentNullException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentnullexception)
+The audio buffer is null. + +### **FromMediaFile(SafeMtmdModelHandle, String)** + +Create an embedding by decoding a media file using libmtmd helpers. + +```csharp +public static SafeMtmdEmbed? FromMediaFile(SafeMtmdModelHandle mtmdContext, string path) +``` + +#### Parameters + +`mtmdContext` [SafeMtmdModelHandle](./llama.native.safemtmdmodelhandle.md)
+Model context that provides the decoder configuration. + +`path` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+Path to the media file on disk. + +#### Returns + +[SafeMtmdEmbed](./llama.native.safemtmdembed.md)?
+Managed wrapper when decoding succeeds; otherwise `null`. + +#### Exceptions + +[ArgumentNullException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentnullexception)
+The context is null. + +[ArgumentException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentexception)
+The path is null or whitespace. + +[FileNotFoundException](https://learn.microsoft.com/en-us/dotnet/api/system.io.filenotfoundexception)
+The supplied file does not exist. + +### **FromMediaBuffer(SafeMtmdModelHandle, ReadOnlySpan<Byte>)** + +Create an embedding from an in-memory media buffer (image/audio/video). + +```csharp +public static SafeMtmdEmbed? FromMediaBuffer(SafeMtmdModelHandle mtmdContext, ReadOnlySpan data) +``` + +#### Parameters + +`mtmdContext` [SafeMtmdModelHandle](./llama.native.safemtmdmodelhandle.md)
+Model context that provides the decoder configuration. + +`data` [ReadOnlySpan<Byte>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+Binary buffer containing the encoded media. + +#### Returns + +[SafeMtmdEmbed](./llama.native.safemtmdembed.md)?
+Managed wrapper when decoding succeeds; otherwise `null`. + +#### Exceptions + +[ArgumentNullException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentnullexception)
+The context is null. + +[ArgumentException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentexception)
+The buffer is empty. + +### **GetData()** + +Provides safe zero-copy access to the underlying bitmap bytes. + +```csharp +public IEmbedData GetData() +``` + +#### Returns + +[IEmbedData](./llama.native.safemtmdembed.iembeddata.md)
+The data access is guaranteed to remain valid until this object is disposed. + +### **ReleaseHandle()** + +Release the underlying native bitmap. + +```csharp +protected override bool ReleaseHandle() +``` + +#### Returns + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.native.safemtmdinputchunk.md b/docs/xmldocs/llama.native.safemtmdinputchunk.md new file mode 100644 index 000000000..39aa83674 --- /dev/null +++ b/docs/xmldocs/llama.native.safemtmdinputchunk.md @@ -0,0 +1,180 @@ +[`< Back`](./) + +--- + +# SafeMtmdInputChunk + +Namespace: LLama.Native + +Managed wrapper around a single `mtmd_input_chunk`. Instances can either own the + underlying native pointer (when created via [SafeMtmdInputChunk.Copy()](./llama.native.safemtmdinputchunk.md#copy)) or act as non-owning views + produced by the tokenizer. + +```csharp +public sealed class SafeMtmdInputChunk : SafeLLamaHandleBase, System.IDisposable +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [CriticalFinalizerObject](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.constrainedexecution.criticalfinalizerobject) → [SafeHandle](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.safehandle) → [SafeLLamaHandleBase](./llama.native.safellamahandlebase.md) → [SafeMtmdInputChunk](./llama.native.safemtmdinputchunk.md)
+Implements [IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable) + +## Fields + +### **handle** + +```csharp +protected IntPtr handle; +``` + +## Properties + +### **NativePtr** + +Raw pointer to the native chunk structure. + +```csharp +public IntPtr NativePtr { get; } +``` + +#### Property Value + +[IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
+ +### **Type** + +Chunk modality reported by the native helper. + +```csharp +public SafeMtmdInputChunkType Type { get; } +``` + +#### Property Value + +[SafeMtmdInputChunkType](./llama.native.safemtmdinputchunk.safemtmdinputchunktype.md)
+ +### **NTokens** + +Number of tokens contained in this chunk. + +```csharp +public ulong NTokens { get; } +``` + +#### Property Value + +[UInt64](https://learn.microsoft.com/en-us/dotnet/api/system.uint64)
+ +### **Id** + +Identifier assigned by the tokenizer (if any). + +```csharp +public string Id { get; } +``` + +#### Property Value + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **NPos** + +Number of positional slots consumed by this chunk. + +```csharp +public long NPos { get; } +``` + +#### Property Value + +[Int64](https://learn.microsoft.com/en-us/dotnet/api/system.int64)
+ +### **IsInvalid** + +```csharp +public override bool IsInvalid { get; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **IsClosed** + +```csharp +public bool IsClosed { get; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +## Methods + +### **Wrap(IntPtr)** + +Wrap an existing chunk pointer without taking ownership. + +```csharp +public static SafeMtmdInputChunk? Wrap(IntPtr ptr) +``` + +#### Parameters + +`ptr` [IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
+Pointer returned by the native tokenizer. + +#### Returns + +[SafeMtmdInputChunk](./llama.native.safemtmdinputchunk.md)?
+Managed wrapper, or `null` when the pointer is null. + +### **Copy()** + +Create an owning copy of the current chunk. The caller becomes responsible for disposal. + +```csharp +public SafeMtmdInputChunk? Copy() +``` + +#### Returns + +[SafeMtmdInputChunk](./llama.native.safemtmdinputchunk.md)?
+Owning managed wrapper, or `null` if the native copy failed. + +#### Exceptions + +[ObjectDisposedException](https://learn.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
+Thrown when the current wrapper has been disposed. + +### **GetTextTokensSpan()** + +Zero-copy view over the chunk's token buffer. The span remains valid only while the native chunk is alive. + +```csharp +public ReadOnlySpan GetTextTokensSpan() +``` + +#### Returns + +[ReadOnlySpan<Int32>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+Read-only span exposing the chunk's tokens. + +#### Exceptions + +[ObjectDisposedException](https://learn.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
+Thrown when the wrapper has been disposed. + +### **ReleaseHandle()** + +Releases the native chunk when ownership is held by this instance. + +```csharp +protected override bool ReleaseHandle() +``` + +#### Returns + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.native.safemtmdinputchunk.safemtmdinputchunktype.md b/docs/xmldocs/llama.native.safemtmdinputchunk.safemtmdinputchunktype.md new file mode 100644 index 000000000..28e1b0023 --- /dev/null +++ b/docs/xmldocs/llama.native.safemtmdinputchunk.safemtmdinputchunktype.md @@ -0,0 +1,28 @@ +[`< Back`](./) + +--- + +# SafeMtmdInputChunkType + +Namespace: LLama.Native + +Chunk modality returned by the native tokenizer. + +```csharp +internal enum SafeMtmdInputChunkType +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://learn.microsoft.com/en-us/dotnet/api/system.enum) → [SafeMtmdInputChunkType](./llama.native.safemtmdinputchunk.safemtmdinputchunktype.md)
+Implements [IComparable](https://learn.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://learn.microsoft.com/en-us/dotnet/api/system.iconvertible) + +## Fields + +| Name | Value | Description | +| --- | --: | --- | +| Text | 0 | Chunk contains text | +| Image | 1 | Chunk contains an image | +| Audio | 2 | Chunk contains audio | + +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.native.safemtmdinputchunks.md b/docs/xmldocs/llama.native.safemtmdinputchunks.md new file mode 100644 index 000000000..376e94f7c --- /dev/null +++ b/docs/xmldocs/llama.native.safemtmdinputchunks.md @@ -0,0 +1,149 @@ +[`< Back`](./) + +--- + +# SafeMtmdInputChunks + +Namespace: LLama.Native + +Managed lifetime wrapper around a native `mtmd_input_chunks` collection returned by the tokenizer. + +```csharp +public sealed class SafeMtmdInputChunks : SafeLLamaHandleBase, System.IDisposable +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [CriticalFinalizerObject](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.constrainedexecution.criticalfinalizerobject) → [SafeHandle](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.safehandle) → [SafeLLamaHandleBase](./llama.native.safellamahandlebase.md) → [SafeMtmdInputChunks](./llama.native.safemtmdinputchunks.md)
+Implements [IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) + +## Fields + +### **handle** + +```csharp +protected IntPtr handle; +``` + +## Properties + +### **Size** + +Number of chunks currently held by the native collection. + +```csharp +public ulong Size { get; } +``` + +#### Property Value + +[UInt64](https://learn.microsoft.com/en-us/dotnet/api/system.uint64)
+ +### **IsInvalid** + +```csharp +public override bool IsInvalid { get; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **IsClosed** + +```csharp +public bool IsClosed { get; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +## Methods + +### **ReleaseHandle()** + +Releases the native chunk collection. + +```csharp +protected override bool ReleaseHandle() +``` + +#### Returns + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **CountTokens()** + +Get the number of tokens contained in this chunk collection. + +```csharp +public ulong CountTokens() +``` + +#### Returns + +[UInt64](https://learn.microsoft.com/en-us/dotnet/api/system.uint64)
+Total token count. + +### **CountPositions()** + +Get the number of positions contained in this chunk collection. + +```csharp +public long CountPositions() +``` + +#### Returns + +[Int64](https://learn.microsoft.com/en-us/dotnet/api/system.int64)
+Total number of positional slots consumed. + +### **GetChunkPtr(UInt64)** + +Get a raw pointer to a chunk. The returned [IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr) is the `mtmd_input_chunk*`. + Use [SafeMtmdInputChunk.Wrap(IntPtr)](./llama.native.safemtmdinputchunk.md#wrapintptr) to create a managed wrapper if desired. + +```csharp +public IntPtr GetChunkPtr(ulong index) +``` + +#### Parameters + +`index` [UInt64](https://learn.microsoft.com/en-us/dotnet/api/system.uint64)
+Zero-based index of the chunk to retrieve. + +#### Returns + +[IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
+Pointer to the requested chunk. + +#### Exceptions + +[ObjectDisposedException](https://learn.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
+The collection has already been disposed. + +[IndexOutOfRangeException](https://learn.microsoft.com/en-us/dotnet/api/system.indexoutofrangeexception)
+The requested index is outside of the valid range. + +### **Enumerate()** + +Enumerate the contained chunks as non-owning wrappers. Callers should dispose the returned chunk + if they create a copy. + +```csharp +public IEnumerable Enumerate() +``` + +#### Returns + +[IEnumerable<SafeMtmdInputChunk>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
+Enumeration of chunk wrappers backed by the native collection. + +#### Exceptions + +[ObjectDisposedException](https://learn.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
+The collection has already been disposed. + +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.native.safemtmdmodelhandle.md b/docs/xmldocs/llama.native.safemtmdmodelhandle.md new file mode 100644 index 000000000..6e132549a --- /dev/null +++ b/docs/xmldocs/llama.native.safemtmdmodelhandle.md @@ -0,0 +1,417 @@ +[`< Back`](./) + +--- + +# SafeMtmdModelHandle + +Namespace: LLama.Native + +Wrapper to the Multi Modal Weights handle. This wrapper manages the low level + operations. + +```csharp +public sealed class SafeMtmdModelHandle : SafeLLamaHandleBase, System.IDisposable +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [CriticalFinalizerObject](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.constrainedexecution.criticalfinalizerobject) → [SafeHandle](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.safehandle) → [SafeLLamaHandleBase](./llama.native.safellamahandlebase.md) → [SafeMtmdModelHandle](./llama.native.safemtmdmodelhandle.md)
+Implements [IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) + +## Fields + +### **handle** + +```csharp +protected IntPtr handle; +``` + +## Properties + +### **IsInvalid** + +```csharp +public override bool IsInvalid { get; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **IsClosed** + +```csharp +public bool IsClosed { get; } +``` + +#### Property Value + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +## Constructors + +### **SafeMtmdModelHandle()** + +```csharp +public SafeMtmdModelHandle() +``` + +## Methods + +### **ReleaseHandle()** + +```csharp +protected override bool ReleaseHandle() +``` + +#### Returns + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **LoadFromFile(String, LLamaWeights, MtmdContextParams)** + +Load a multimodal projection model from disk and bind it to the supplied text model. + +```csharp +public static SafeMtmdModelHandle LoadFromFile(string modelPath, LLamaWeights textModel, MtmdContextParams? mtmdCtxParams) +``` + +#### Parameters + +`modelPath` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+Path to the MMP (Multi-Modal Projections) file. + +`textModel` [LLamaWeights](./llama.llamaweights.md)
+Text model that provides tokenizer weights for the multimodal helper. + +`mtmdCtxParams` [MtmdContextParams](./llama.native.mtmdcontextparams.md)?
+Optional context parameters; defaults are used when `null`. + +#### Returns + +[SafeMtmdModelHandle](./llama.native.safemtmdmodelhandle.md)
+Safe handle for the MTMD model. + +#### Exceptions + +[InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception)
+The file exists but is not readable by the current process. + +[LoadWeightsFailedException](./llama.exceptions.loadweightsfailedexception.md)
+The native loader failed to initialize the MTMD model. + +### **LoadMediaFromFile(String)** + +Load media from disk and queue it for the next tokenize call. + +```csharp +public SafeMtmdEmbed LoadMediaFromFile(string path) +``` + +#### Parameters + +`path` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+Absolute or relative path to the media asset. + +#### Returns + +[SafeMtmdEmbed](./llama.native.safemtmdembed.md)
+Safe handle to the media embedding. + +#### Exceptions + +[ObjectDisposedException](https://learn.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
+The model handle has been disposed. + +[RuntimeError](./llama.exceptions.runtimeerror.md)
+The native loader failed to ingest the file. + +### **LoadMediaFromBuffer(ReadOnlySpan<Byte>)** + +Load media from an in-memory buffer and queue it for the next tokenize call. + +```csharp +public SafeMtmdEmbed LoadMediaFromBuffer(ReadOnlySpan buffer) +``` + +#### Parameters + +`buffer` [ReadOnlySpan<Byte>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+Binary buffer containing the encoded media data. + +#### Returns + +[SafeMtmdEmbed](./llama.native.safemtmdembed.md)
+Safe handle to the media embedding. + +#### Exceptions + +[ObjectDisposedException](https://learn.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
+The model handle has been disposed. + +[RuntimeError](./llama.exceptions.runtimeerror.md)
+The native loader failed to ingest the buffer contents. + +### **ClearMedia()** + +Disposes and clears any media buffers currently queued for tokenization. + +```csharp +public void ClearMedia() +``` + +### **Tokenize(String, Boolean, Boolean, out SafeMtmdInputChunks)** + +Tokenize a prompt alongside the pending media buffers. Pending media is cleared on success. + +```csharp +public int Tokenize(string text, bool addSpecial, bool parseSpecial, out SafeMtmdInputChunks chunks) +``` + +#### Parameters + +`text` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+Prompt text to tokenize. + +`addSpecial` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+Whether to append special tokens automatically. + +`parseSpecial` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+Whether special tokens should be treated as user-provided text. + +`out` `chunks` [SafeMtmdInputChunks](./llama.native.safemtmdinputchunks.md)
+Receives the native chunk collection when tokenization succeeds. + +#### Returns + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Zero on success; otherwise the native mtmd tokenize error code. + +#### Exceptions + +[ObjectDisposedException](https://learn.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
+The model handle has been disposed. + +### **Tokenize(String, Boolean, Boolean, ReadOnlySpan<SafeMtmdEmbed>, out SafeMtmdInputChunks)** + +Tokenize a prompt alongside the provided media embeddings. + The caller retains ownership of `embeds`. + +```csharp +public int Tokenize(string text, bool addSpecial, bool parseSpecial, ReadOnlySpan embeds, out SafeMtmdInputChunks chunks) +``` + +#### Parameters + +`text` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+Prompt text to tokenize. + +`addSpecial` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+Whether to append special tokens automatically. + +`parseSpecial` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+Whether special tokens should be treated as user-provided text. + +`embeds` [ReadOnlySpan<SafeMtmdEmbed>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+Media embeddings to include in the multimodal prompt. + +`out` `chunks` [SafeMtmdInputChunks](./llama.native.safemtmdinputchunks.md)
+Receives the native chunk collection when tokenization succeeds. + +#### Returns + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Zero on success; otherwise the native mtmd tokenize error code. + +#### Exceptions + +[ObjectDisposedException](https://learn.microsoft.com/en-us/dotnet/api/system.objectdisposedexception)
+The model handle has been disposed. + +[RuntimeError](./llama.exceptions.runtimeerror.md)
+The native tokenizer failed to allocate output chunks. + +### **EvaluateChunks(SafeMtmdInputChunks, SafeLLamaContextHandle, ref Int32, Int32, Int32, Boolean)** + +Evaluate a batch of chunks using the helper (mirrors mtmd-helper eval logic). + +```csharp +public int EvaluateChunks(SafeMtmdInputChunks chunks, SafeLLamaContextHandle llamaContext, ref int nPast, int seqId, int nBatch, bool logitsLast) +``` + +#### Parameters + +`chunks` [SafeMtmdInputChunks](./llama.native.safemtmdinputchunks.md)
+Chunk collection produced by [SafeMtmdModelHandle.Tokenize(String, Boolean, Boolean, out SafeMtmdInputChunks)](./llama.native.safemtmdmodelhandle.md#tokenizestring-boolean-boolean-out-safemtmdinputchunks). + +`llamaContext` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
+Context handle that receives the evaluated tokens. + +`ref` `nPast` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Number of past tokens; updated when evaluation succeeds. + +`seqId` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Sequence identifier used for KV cache management. + +`nBatch` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Maximum number of tokens to evaluate in a single batch. + +`logitsLast` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+Whether to request logits for the last token only. + +#### Returns + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Zero on success; otherwise the native helper error code. + +#### Exceptions + +[ArgumentNullException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentnullexception)
+Thrown when required handles are null. + +### **EvaluateChunk(IntPtr, SafeLLamaContextHandle, ref Int32, Int32, Int32, Boolean)** + +Evaluate a single chunk helper. + +```csharp +public int EvaluateChunk(IntPtr chunkPtr, SafeLLamaContextHandle llamaContext, ref int nPast, int seqId, int nBatch, bool logitsLast) +``` + +#### Parameters + +`chunkPtr` [IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
+Pointer to the chunk to evaluate. + +`llamaContext` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
+Context handle that receives the evaluated tokens. + +`ref` `nPast` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Number of past tokens; updated when evaluation succeeds. + +`seqId` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Sequence identifier used for KV cache management. + +`nBatch` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Maximum number of tokens to evaluate in a single batch. + +`logitsLast` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+Whether to request logits for the last token only. + +#### Returns + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Zero on success; otherwise the native helper error code. + +#### Exceptions + +[ArgumentNullException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentnullexception)
+Thrown when required handles are null. + +### **DecodeImageChunk(IntPtr, SafeLLamaContextHandle, IntPtr, ref Int32, Int32, Int32)** + +Decode a prepared image chunk whose embedding is already computed. + +```csharp +public int DecodeImageChunk(IntPtr chunkPtr, SafeLLamaContextHandle llamaContext, IntPtr encodedEmbeddings, ref int nPast, int seqId, int nBatch) +``` + +#### Parameters + +`chunkPtr` [IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
+Pointer to the chunk whose embedding should be decoded. + +`llamaContext` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
+Context handle used for decoding. + +`encodedEmbeddings` [IntPtr](https://learn.microsoft.com/en-us/dotnet/api/system.intptr)
+Pointer to the pre-computed embedding data. + +`ref` `nPast` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Number of past tokens; updated when evaluation succeeds. + +`seqId` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Sequence identifier used for KV cache management. + +`nBatch` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Maximum number of tokens to evaluate in a single batch. + +#### Returns + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Zero on success; otherwise the native helper error code. + +#### Exceptions + +[ArgumentNullException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentnullexception)
+Thrown when required handles are null. + +### **Finalize()** + +Finalizer to ensure native resources are released if Dispose was not called. + +```csharp +protected override void Finalize() +``` + +### **DecodeUseNonCausal()** + +Indicates whether the model decodes using the non-causal path. + +```csharp +public bool DecodeUseNonCausal() +``` + +#### Returns + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **DecodeUseMRope()** + +Indicates whether the model decodes using multi-scale RoPE. + +```csharp +public bool DecodeUseMRope() +``` + +#### Returns + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **SupportVision()** + +Indicates whether the model supports vision inputs. + +```csharp +public bool SupportVision() +``` + +#### Returns + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **SupportAudio()** + +Indicates whether the model supports audio inputs. + +```csharp +public bool SupportAudio() +``` + +#### Returns + +[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **GetAudioSampleRate()** + +Gets the audio bitrate advertised by the model. + +```csharp +public int GetAudioSampleRate() +``` + +#### Returns + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.native.systeminfo.md b/docs/xmldocs/llama.native.systeminfo.md index 666d55140..555e16adf 100644 --- a/docs/xmldocs/llama.native.systeminfo.md +++ b/docs/xmldocs/llama.native.systeminfo.md @@ -9,60 +9,50 @@ Namespace: LLama.Native Operating system information. ```csharp -public class SystemInfo : System.IEquatable`1[[LLama.Native.SystemInfo, LLamaSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] +public record class SystemInfo : System.IEquatable`1[[LLama.Native.SystemInfo, LLamaSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [SystemInfo](./llama.native.systeminfo.md)
-Implements [IEquatable<SystemInfo>](https://docs.microsoft.com/en-us/dotnet/api/system.iequatable-1)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [SystemInfo](./llama.native.systeminfo.md)
+Implements [IEquatable<SystemInfo>](https://learn.microsoft.com/en-us/dotnet/api/system.iequatable-1)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties -### **EqualityContract** - -```csharp -protected Type EqualityContract { get; } -``` - -#### Property Value - -[Type](https://docs.microsoft.com/en-us/dotnet/api/system.type)
- ### **OSPlatform** ```csharp -public OSPlatform OSPlatform { get; set; } +public OSPlatform OSPlatform { get; init; } ``` #### Property Value -[OSPlatform](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.osplatform)
+[OSPlatform](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.osplatform)
### **CudaMajorVersion** ```csharp -public int CudaMajorVersion { get; set; } +public int CudaMajorVersion { get; init; } ``` #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **VulkanVersion** ```csharp -public string VulkanVersion { get; set; } +public string? VulkanVersion { get; init; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
## Constructors @@ -71,16 +61,16 @@ public string VulkanVersion { get; set; } Operating system information. ```csharp -public SystemInfo(OSPlatform OSPlatform, int CudaMajorVersion, string VulkanVersion) +public SystemInfo(OSPlatform OSPlatform, int CudaMajorVersion, string? VulkanVersion) ``` #### Parameters -`OSPlatform` [OSPlatform](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.osplatform)
+`OSPlatform` [OSPlatform](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.osplatform)
-`CudaMajorVersion` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`CudaMajorVersion` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
-`VulkanVersion` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`VulkanVersion` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)?
### **SystemInfo(SystemInfo)** @@ -108,93 +98,7 @@ public static SystemInfo Get() #### Exceptions -[PlatformNotSupportedException](https://docs.microsoft.com/en-us/dotnet/api/system.platformnotsupportedexception)
- -### **ToString()** - -```csharp -public string ToString() -``` - -#### Returns - -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
- -### **PrintMembers(StringBuilder)** - -```csharp -protected bool PrintMembers(StringBuilder builder) -``` - -#### Parameters - -`builder` [StringBuilder](https://docs.microsoft.com/en-us/dotnet/api/system.text.stringbuilder)
- -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -### **GetHashCode()** - -```csharp -public int GetHashCode() -``` - -#### Returns - -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -### **Equals(Object)** - -```csharp -public bool Equals(object obj) -``` - -#### Parameters - -`obj` [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object)
- -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -### **Equals(SystemInfo)** - -```csharp -public bool Equals(SystemInfo other) -``` - -#### Parameters - -`other` [SystemInfo](./llama.native.systeminfo.md)
- -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -### **<Clone>$()** - -```csharp -public SystemInfo $() -``` - -#### Returns - -[SystemInfo](./llama.native.systeminfo.md)
- -### **Deconstruct(OSPlatform&, Int32&, String&)** - -```csharp -public void Deconstruct(OSPlatform& OSPlatform, Int32& CudaMajorVersion, String& VulkanVersion) -``` - -#### Parameters - -`OSPlatform` [OSPlatform&](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.interopservices.osplatform&)
- -`CudaMajorVersion` [Int32&](https://docs.microsoft.com/en-us/dotnet/api/system.int32&)
- -`VulkanVersion` [String&](https://docs.microsoft.com/en-us/dotnet/api/system.string&)
+[PlatformNotSupportedException](https://learn.microsoft.com/en-us/dotnet/api/system.platformnotsupportedexception)
--- diff --git a/docs/xmldocs/llama.native.unknownnativelibrary.md b/docs/xmldocs/llama.native.unknownnativelibrary.md index c39733fc9..e01926a4f 100644 --- a/docs/xmldocs/llama.native.unknownnativelibrary.md +++ b/docs/xmldocs/llama.native.unknownnativelibrary.md @@ -7,21 +7,23 @@ Namespace: LLama.Native When you are using .NET standard2.0, dynamic native library loading is not supported. - This class will be returned in [NativeLibraryConfig.DryRun(INativeLibrary&)](./llama.native.nativelibraryconfig.md#dryruninativelibrary&). + This class will be returned in [NativeLibraryConfig.DryRun(out INativeLibrary)](./llama.native.nativelibraryconfig.md#dryrunout-inativelibrary). ```csharp public class UnknownNativeLibrary : LLama.Abstractions.INativeLibrary ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [UnknownNativeLibrary](./llama.native.unknownnativelibrary.md)
+Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [UnknownNativeLibrary](./llama.native.unknownnativelibrary.md)
Implements [INativeLibrary](./llama.abstractions.inativelibrary.md) ## Properties ### **Metadata** +Metadata of this library. + ```csharp -public NativeLibraryMetadata Metadata { get; } +public NativeLibraryMetadata? Metadata { get; } ``` #### Property Value @@ -40,19 +42,25 @@ public UnknownNativeLibrary() ### **Prepare(SystemInfo, LLamaLogCallback)** +Prepare the native library file and returns the local path of it. + If it's a relative path, LLamaSharp will search the path in the search directies you set. + ```csharp -public IEnumerable Prepare(SystemInfo systemInfo, LLamaLogCallback logCallback) +public IEnumerable Prepare(SystemInfo systemInfo, LLamaLogCallback? logCallback = null) ``` #### Parameters `systemInfo` [SystemInfo](./llama.native.systeminfo.md)
+The system information of the current machine. -`logCallback` [LLamaLogCallback](./llama.native.nativelogconfig.llamalogcallback.md)
+`logCallback` [LLamaLogCallback](./llama.native.nativelogconfig.llamalogcallback.md)?
+The log callback. #### Returns -[IEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
+[IEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1)
+The relative paths of the library. You could return multiple paths to try them one by one. If no file is available, please return an empty array. --- diff --git a/docs/xmldocs/llama.sampling.basesamplingpipeline.md b/docs/xmldocs/llama.sampling.basesamplingpipeline.md index 498c258f9..3549a2c77 100644 --- a/docs/xmldocs/llama.sampling.basesamplingpipeline.md +++ b/docs/xmldocs/llama.sampling.basesamplingpipeline.md @@ -6,13 +6,15 @@ Namespace: LLama.Sampling +Convert a span of logits into a single sampled token. This interface can be implemented to completely customise the sampling process. + ```csharp public abstract class BaseSamplingPipeline : ISamplingPipeline, System.IDisposable ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [BaseSamplingPipeline](./llama.sampling.basesamplingpipeline.md)
-Implements [ISamplingPipeline](./llama.sampling.isamplingpipeline.md), [IDisposable](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [BaseSamplingPipeline](./llama.sampling.basesamplingpipeline.md)
+Implements [ISamplingPipeline](./llama.sampling.isamplingpipeline.md), [IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Constructors @@ -45,20 +47,24 @@ protected abstract SafeLLamaSamplerChainHandle CreateChain(SafeLLamaContextHandl ### **Dispose()** ```csharp -public void Dispose() +public virtual void Dispose() ``` ### **Sample(SafeLLamaContextHandle, Int32)** +Sample a single token from the given context at the given position + ```csharp -public LLamaToken Sample(SafeLLamaContextHandle ctx, int index) +public virtual LLamaToken Sample(SafeLLamaContextHandle ctx, int index) ``` #### Parameters `ctx` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
+The context being sampled from -`index` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`index` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Position to sample logits from #### Returns @@ -66,8 +72,10 @@ public LLamaToken Sample(SafeLLamaContextHandle ctx, int index) ### **Apply(SafeLLamaContextHandle, LLamaTokenDataArray)** +Apply this pipeline to a set of token data + ```csharp -public void Apply(SafeLLamaContextHandle ctx, LLamaTokenDataArray data) +public virtual void Apply(SafeLLamaContextHandle ctx, LLamaTokenDataArray data) ``` #### Parameters @@ -76,30 +84,34 @@ public void Apply(SafeLLamaContextHandle ctx, LLamaTokenDataArray data) `data` [LLamaTokenDataArray](./llama.native.llamatokendataarray.md)
-### **Apply(SafeLLamaContextHandle, LLamaTokenDataArrayNative&)** +### **Apply(SafeLLamaContextHandle, ref LLamaTokenDataArrayNative)** Apply this sampling chain to a LLamaTokenDataArrayNative ```csharp -public void Apply(SafeLLamaContextHandle ctx, LLamaTokenDataArrayNative& data) +public virtual void Apply(SafeLLamaContextHandle ctx, ref LLamaTokenDataArrayNative data) ``` #### Parameters `ctx` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
-`data` [LLamaTokenDataArrayNative&](./llama.native.llamatokendataarraynative&.md)
+`ref` `data` [LLamaTokenDataArrayNative](./llama.native.llamatokendataarraynative.md)
### **Reset()** +Reset all internal state of the sampling pipeline + ```csharp -public void Reset() +public virtual void Reset() ``` ### **Accept(LLamaToken)** +Update the pipeline, with knowledge that a particular token was just accepted + ```csharp -public void Accept(LLamaToken token) +public virtual void Accept(LLamaToken token) ``` #### Parameters diff --git a/docs/xmldocs/llama.sampling.defaultsamplingpipeline.grammaroptimizationmode.md b/docs/xmldocs/llama.sampling.defaultsamplingpipeline.grammaroptimizationmode.md new file mode 100644 index 000000000..cbad90c56 --- /dev/null +++ b/docs/xmldocs/llama.sampling.defaultsamplingpipeline.grammaroptimizationmode.md @@ -0,0 +1,29 @@ +[`< Back`](./) + +--- + +# GrammarOptimizationMode + +Namespace: LLama.Sampling + +Grammar Optimization Mode + +```csharp +internal enum GrammarOptimizationMode +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ValueType](https://learn.microsoft.com/en-us/dotnet/api/system.valuetype) → [Enum](https://learn.microsoft.com/en-us/dotnet/api/system.enum) → [GrammarOptimizationMode](./llama.sampling.defaultsamplingpipeline.grammaroptimizationmode.md)
+Implements [IComparable](https://learn.microsoft.com/en-us/dotnet/api/system.icomparable), [ISpanFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.ispanformattable), [IFormattable](https://learn.microsoft.com/en-us/dotnet/api/system.iformattable), [IConvertible](https://learn.microsoft.com/en-us/dotnet/api/system.iconvertible)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute) + +## Fields + +| Name | Value | Description | +| --- | --: | --- | +| None | 0 | No grammar optimization, slow because it has to apply the grammar to the entire vocab. | +| Basic | 1 | Attempts to return early by only applying the grammar to the selected token and checking if it's valid. | +| Extended | 2 | Attempts to return early by applying the grammar to the top K tokens and checking if the selected token is valid. | + +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.sampling.defaultsamplingpipeline.md b/docs/xmldocs/llama.sampling.defaultsamplingpipeline.md index 92c14bca6..53d66cb3d 100644 --- a/docs/xmldocs/llama.sampling.defaultsamplingpipeline.md +++ b/docs/xmldocs/llama.sampling.defaultsamplingpipeline.md @@ -12,9 +12,9 @@ An implementation of ISamplePipeline which mimics the default llama.cpp sampling public class DefaultSamplingPipeline : BaseSamplingPipeline, ISamplingPipeline, System.IDisposable ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [BaseSamplingPipeline](./llama.sampling.basesamplingpipeline.md) → [DefaultSamplingPipeline](./llama.sampling.defaultsamplingpipeline.md)
-Implements [ISamplingPipeline](./llama.sampling.isamplingpipeline.md), [IDisposable](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [BaseSamplingPipeline](./llama.sampling.basesamplingpipeline.md) → [DefaultSamplingPipeline](./llama.sampling.defaultsamplingpipeline.md)
+Implements [ISamplingPipeline](./llama.sampling.isamplingpipeline.md), [IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties @@ -23,24 +23,24 @@ Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/ap Bias values to add to certain logits ```csharp -public IReadOnlyDictionary LogitBias { get; set; } +public IReadOnlyDictionary LogitBias { get; init; } ``` #### Property Value -[IReadOnlyDictionary<LLamaToken, Single>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.ireadonlydictionary-2)
+[IReadOnlyDictionary<LLamaToken, Single>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ireadonlydictionary-2)
### **RepeatPenalty** Repetition penalty, as described in https://arxiv.org/abs/1909.05858 ```csharp -public float RepeatPenalty { get; set; } +public float RepeatPenalty { get; init; } ``` #### Property Value -[Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+[Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
### **FrequencyPenalty** @@ -49,12 +49,12 @@ Frequency penalty as described by OpenAI: https://platform.openai.com/docs/api-r so far, decreasing the model's likelihood to repeat the same line verbatim. ```csharp -public float FrequencyPenalty { get; set; } +public float FrequencyPenalty { get; init; } ``` #### Property Value -[Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+[Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
### **PresencePenalty** @@ -63,115 +63,115 @@ Presence penalty as described by OpenAI: https://platform.openai.com/docs/api-re text so far, increasing the model's likelihood to talk about new topics. ```csharp -public float PresencePenalty { get; set; } +public float PresencePenalty { get; init; } ``` #### Property Value -[Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+[Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
### **PenaltyCount** How many tokens should be considered for penalties ```csharp -public int PenaltyCount { get; set; } +public int PenaltyCount { get; init; } ``` #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **PenalizeNewline** Whether the newline token should be protected from being modified by penalty ```csharp -public bool PenalizeNewline { get; set; } +public bool PenalizeNewline { get; init; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **PreventEOS** Whether the EOS token should be suppressed. Setting this to 'true' prevents EOS from being sampled ```csharp -public bool PreventEOS { get; set; } +public bool PreventEOS { get; init; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **Temperature** Temperature to apply (higher temperature is more "creative") ```csharp -public float Temperature { get; set; } +public float Temperature { get; init; } ``` #### Property Value -[Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+[Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
### **TopK** Number of tokens to keep in TopK sampling ```csharp -public int TopK { get; set; } +public int TopK { get; init; } ``` #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **TypicalP** P value for locally typical sampling ```csharp -public float TypicalP { get; set; } +public float TypicalP { get; init; } ``` #### Property Value -[Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+[Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
### **TopP** P value for TopP sampling ```csharp -public float TopP { get; set; } +public float TopP { get; init; } ``` #### Property Value -[Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+[Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
### **MinP** P value for MinP sampling ```csharp -public float MinP { get; set; } +public float MinP { get; init; } ``` #### Property Value -[Single](https://docs.microsoft.com/en-us/dotnet/api/system.single)
+[Single](https://learn.microsoft.com/en-us/dotnet/api/system.single)
### **Grammar** Grammar to apply to constrain possible tokens ```csharp -public Grammar Grammar { get; set; } +public Grammar? Grammar { get; init; } ``` #### Property Value @@ -188,7 +188,7 @@ public int MinKeep { get; set; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **Seed** @@ -200,14 +200,14 @@ public uint Seed { get; set; } #### Property Value -[UInt32](https://docs.microsoft.com/en-us/dotnet/api/system.uint32)
+[UInt32](https://learn.microsoft.com/en-us/dotnet/api/system.uint32)
### **GrammarOptimization** Selected grammar optimization mode ```csharp -public GrammarOptimizationMode GrammarOptimization { get; set; } +public GrammarOptimizationMode GrammarOptimization { get; init; } ``` #### Property Value @@ -227,19 +227,23 @@ public DefaultSamplingPipeline() ### **Dispose()** ```csharp -public void Dispose() +public override void Dispose() ``` ### **Reset()** +Reset all internal state of the sampling pipeline + ```csharp -public void Reset() +public override void Reset() ``` ### **Accept(LLamaToken)** +Update the pipeline, with knowledge that a particular token was just accepted + ```csharp -public void Accept(LLamaToken token) +public override void Accept(LLamaToken token) ``` #### Parameters @@ -248,8 +252,10 @@ public void Accept(LLamaToken token) ### **CreateChain(SafeLLamaContextHandle)** +Create a sampling chain. This will be called once, the base class will automatically dispose the chain. + ```csharp -protected SafeLLamaSamplerChainHandle CreateChain(SafeLLamaContextHandle context) +protected override SafeLLamaSamplerChainHandle CreateChain(SafeLLamaContextHandle context) ``` #### Parameters @@ -262,15 +268,19 @@ protected SafeLLamaSamplerChainHandle CreateChain(SafeLLamaContextHandle context ### **Sample(SafeLLamaContextHandle, Int32)** +Sample a single token from the given context at the given position + ```csharp -public LLamaToken Sample(SafeLLamaContextHandle ctx, int index) +public override LLamaToken Sample(SafeLLamaContextHandle ctx, int index) ``` #### Parameters `ctx` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
+The context being sampled from -`index` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`index` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+Position to sample logits from #### Returns diff --git a/docs/xmldocs/llama.sampling.grammar.md b/docs/xmldocs/llama.sampling.grammar.md index ffe147183..08bd965df 100644 --- a/docs/xmldocs/llama.sampling.grammar.md +++ b/docs/xmldocs/llama.sampling.grammar.md @@ -9,48 +9,38 @@ Namespace: LLama.Sampling A grammar in GBNF form ```csharp -public class Grammar : System.IEquatable`1[[LLama.Sampling.Grammar, LLamaSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] +public record class Grammar : System.IEquatable`1[[LLama.Sampling.Grammar, LLamaSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [Grammar](./llama.sampling.grammar.md)
-Implements [IEquatable<Grammar>](https://docs.microsoft.com/en-us/dotnet/api/system.iequatable-1)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [Grammar](./llama.sampling.grammar.md)
+Implements [IEquatable<Grammar>](https://learn.microsoft.com/en-us/dotnet/api/system.iequatable-1)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties -### **EqualityContract** - -```csharp -protected Type EqualityContract { get; } -``` - -#### Property Value - -[Type](https://docs.microsoft.com/en-us/dotnet/api/system.type)
- ### **Gbnf** ```csharp -public string Gbnf { get; set; } +public string Gbnf { get; init; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Root** ```csharp -public string Root { get; set; } +public string Root { get; init; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
## Constructors @@ -64,9 +54,9 @@ public Grammar(string Gbnf, string Root) #### Parameters -`Gbnf` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`Gbnf` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
-`Root` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`Root` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Grammar(Grammar)** @@ -78,92 +68,6 @@ protected Grammar(Grammar original) `original` [Grammar](./llama.sampling.grammar.md)
-## Methods - -### **ToString()** - -```csharp -public string ToString() -``` - -#### Returns - -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
- -### **PrintMembers(StringBuilder)** - -```csharp -protected bool PrintMembers(StringBuilder builder) -``` - -#### Parameters - -`builder` [StringBuilder](https://docs.microsoft.com/en-us/dotnet/api/system.text.stringbuilder)
- -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -### **GetHashCode()** - -```csharp -public int GetHashCode() -``` - -#### Returns - -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -### **Equals(Object)** - -```csharp -public bool Equals(object obj) -``` - -#### Parameters - -`obj` [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object)
- -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -### **Equals(Grammar)** - -```csharp -public bool Equals(Grammar other) -``` - -#### Parameters - -`other` [Grammar](./llama.sampling.grammar.md)
- -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -### **<Clone>$()** - -```csharp -public Grammar $() -``` - -#### Returns - -[Grammar](./llama.sampling.grammar.md)
- -### **Deconstruct(String&, String&)** - -```csharp -public void Deconstruct(String& Gbnf, String& Root) -``` - -#### Parameters - -`Gbnf` [String&](https://docs.microsoft.com/en-us/dotnet/api/system.string&)
- -`Root` [String&](https://docs.microsoft.com/en-us/dotnet/api/system.string&)
- --- [`< Back`](./) diff --git a/docs/xmldocs/llama.sampling.greedysamplingpipeline.md b/docs/xmldocs/llama.sampling.greedysamplingpipeline.md index 9a2002b32..6a1cbad99 100644 --- a/docs/xmldocs/llama.sampling.greedysamplingpipeline.md +++ b/docs/xmldocs/llama.sampling.greedysamplingpipeline.md @@ -12,9 +12,9 @@ A sampling pipeline which always selects the most likely token public class GreedySamplingPipeline : BaseSamplingPipeline, ISamplingPipeline, System.IDisposable ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [BaseSamplingPipeline](./llama.sampling.basesamplingpipeline.md) → [GreedySamplingPipeline](./llama.sampling.greedysamplingpipeline.md)
-Implements [ISamplingPipeline](./llama.sampling.isamplingpipeline.md), [IDisposable](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [BaseSamplingPipeline](./llama.sampling.basesamplingpipeline.md) → [GreedySamplingPipeline](./llama.sampling.greedysamplingpipeline.md)
+Implements [ISamplingPipeline](./llama.sampling.isamplingpipeline.md), [IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties @@ -23,7 +23,7 @@ Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/ap Grammar to apply to constrain possible tokens ```csharp -public Grammar Grammar { get; set; } +public Grammar? Grammar { get; init; } ``` #### Property Value @@ -42,8 +42,10 @@ public GreedySamplingPipeline() ### **CreateChain(SafeLLamaContextHandle)** +Create a sampling chain. This will be called once, the base class will automatically dispose the chain. + ```csharp -protected SafeLLamaSamplerChainHandle CreateChain(SafeLLamaContextHandle context) +protected override SafeLLamaSamplerChainHandle CreateChain(SafeLLamaContextHandle context) ``` #### Parameters diff --git a/docs/xmldocs/llama.sampling.isamplingpipeline.md b/docs/xmldocs/llama.sampling.isamplingpipeline.md index c5176baea..f567064b0 100644 --- a/docs/xmldocs/llama.sampling.isamplingpipeline.md +++ b/docs/xmldocs/llama.sampling.isamplingpipeline.md @@ -12,8 +12,8 @@ Convert a span of logits into a single sampled token. This interface can be impl public interface ISamplingPipeline : System.IDisposable ``` -Implements [IDisposable](https://docs.microsoft.com/en-us/dotnet/api/system.idisposable)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute) +Implements [IDisposable](https://learn.microsoft.com/en-us/dotnet/api/system.idisposable)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute) ## Methods @@ -30,7 +30,7 @@ LLamaToken Sample(SafeLLamaContextHandle ctx, int index) `ctx` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
The context being sampled from -`index` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`index` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
Position to sample logits from #### Returns diff --git a/docs/xmldocs/llama.sampling.isamplingpipelineextensions.md b/docs/xmldocs/llama.sampling.isamplingpipelineextensions.md index 1df1f4900..76c777425 100644 --- a/docs/xmldocs/llama.sampling.isamplingpipelineextensions.md +++ b/docs/xmldocs/llama.sampling.isamplingpipelineextensions.md @@ -12,8 +12,8 @@ Extension methods for [ISamplingPipeline](./llama.sampling.isamplingpipeline.md) public static class ISamplingPipelineExtensions ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [ISamplingPipelineExtensions](./llama.sampling.isamplingpipelineextensions.md)
-Attributes [ExtensionAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.extensionattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ISamplingPipelineExtensions](./llama.sampling.isamplingpipelineextensions.md)
+Attributes [ExtensionAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.extensionattribute) ## Methods @@ -32,7 +32,7 @@ public static LLamaToken Sample(ISamplingPipeline pipe, LLamaContext ctx, int in `ctx` [LLamaContext](./llama.llamacontext.md)
The context being sampled from -`index` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`index` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
Position to sample logits from #### Returns diff --git a/docs/xmldocs/llama.sessionstate.md b/docs/xmldocs/llama.sessionstate.md index 29421760c..67ec38161 100644 --- a/docs/xmldocs/llama.sessionstate.md +++ b/docs/xmldocs/llama.sessionstate.md @@ -9,31 +9,21 @@ Namespace: LLama The state of a chat session in-memory. ```csharp -public class SessionState : System.IEquatable`1[[LLama.SessionState, LLamaSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] +public record class SessionState : System.IEquatable`1[[LLama.SessionState, LLamaSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]] ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [SessionState](./llama.sessionstate.md)
-Implements [IEquatable<SessionState>](https://docs.microsoft.com/en-us/dotnet/api/system.iequatable-1)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [SessionState](./llama.sessionstate.md)
+Implements [IEquatable<SessionState>](https://learn.microsoft.com/en-us/dotnet/api/system.iequatable-1)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties -### **EqualityContract** - -```csharp -protected Type EqualityContract { get; } -``` - -#### Property Value - -[Type](https://docs.microsoft.com/en-us/dotnet/api/system.type)
- ### **ExecutorState** Saved executor state for the session in JSON format. ```csharp -public ExecutorBaseState ExecutorState { get; set; } +public ExecutorBaseState? ExecutorState { get; set; } ``` #### Property Value @@ -45,7 +35,7 @@ public ExecutorBaseState ExecutorState { get; set; } Saved context state (KV cache) for the session. ```csharp -public State ContextState { get; set; } +public State? ContextState { get; set; } ``` #### Property Value @@ -107,18 +97,18 @@ public Message[] History { get; set; } Create a new session state. ```csharp -public SessionState(State contextState, ExecutorBaseState executorState, ChatHistory history, List inputTransformPipeline, ITextStreamTransform outputTransform, IHistoryTransform historyTransform) +public SessionState(State? contextState, ExecutorBaseState executorState, ChatHistory history, List inputTransformPipeline, ITextStreamTransform outputTransform, IHistoryTransform historyTransform) ``` #### Parameters -`contextState` [State](./llama.llamacontext.state.md)
+`contextState` [State](./llama.llamacontext.state.md)?
`executorState` [ExecutorBaseState](./llama.statefulexecutorbase.executorbasestate.md)
`history` [ChatHistory](./llama.common.chathistory.md)
-`inputTransformPipeline` [List<ITextTransform>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
+`inputTransformPipeline` [List<ITextTransform>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
`outputTransform` [ITextStreamTransform](./llama.abstractions.itextstreamtransform.md)
@@ -146,7 +136,7 @@ public void Save(string path) #### Parameters -`path` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`path` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Load(String)** @@ -158,7 +148,7 @@ public static SessionState Load(string path) #### Parameters -`path` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`path` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
#### Returns @@ -166,81 +156,9 @@ public static SessionState Load(string path) #### Exceptions -[ArgumentException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentexception)
+[ArgumentException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentexception)
Throws when session state is incorrect -### **ToString()** - -```csharp -public string ToString() -``` - -#### Returns - -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
- -### **PrintMembers(StringBuilder)** - -```csharp -protected bool PrintMembers(StringBuilder builder) -``` - -#### Parameters - -`builder` [StringBuilder](https://docs.microsoft.com/en-us/dotnet/api/system.text.stringbuilder)
- -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -### **GetHashCode()** - -```csharp -public int GetHashCode() -``` - -#### Returns - -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
- -### **Equals(Object)** - -```csharp -public bool Equals(object obj) -``` - -#### Parameters - -`obj` [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object)
- -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -### **Equals(SessionState)** - -```csharp -public bool Equals(SessionState other) -``` - -#### Parameters - -`other` [SessionState](./llama.sessionstate.md)
- -#### Returns - -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
- -### **<Clone>$()** - -```csharp -public SessionState $() -``` - -#### Returns - -[SessionState](./llama.sessionstate.md)
- --- [`< Back`](./) diff --git a/docs/xmldocs/llama.statefulexecutorbase.executorbasestate.md b/docs/xmldocs/llama.statefulexecutorbase.executorbasestate.md new file mode 100644 index 000000000..d84126422 --- /dev/null +++ b/docs/xmldocs/llama.statefulexecutorbase.executorbasestate.md @@ -0,0 +1,140 @@ +[`< Back`](./) + +--- + +# ExecutorBaseState + +Namespace: LLama + +Serializable snapshot of executor state used for persistence and restart. + +```csharp +internal class ExecutorBaseState +``` + +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [ExecutorBaseState](./llama.statefulexecutorbase.executorbasestate.md)
+Attributes [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute), [JsonConverterAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.text.json.serialization.jsonconverterattribute) + +## Properties + +### **PastTokensCount** + +```csharp +public int PastTokensCount { get; set; } +``` + +#### Property Value + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **ConsumedTokensCount** + +```csharp +public int ConsumedTokensCount { get; set; } +``` + +#### Property Value + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **ConsumedSessionCount** + +```csharp +public int ConsumedSessionCount { get; set; } +``` + +#### Property Value + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **MatchingSessionTokensCount** + +```csharp +public int MatchingSessionTokensCount { get; set; } +``` + +#### Property Value + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **SessionFilePath** + +```csharp +public string? SessionFilePath { get; set; } +``` + +#### Property Value + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **Embeds** + +```csharp +public LLamaToken[] Embeds { get; set; } +``` + +#### Property Value + +[LLamaToken[]](./llama.native.llamatoken.md)
+ +### **EmbedInps** + +```csharp +public LLamaToken[] EmbedInps { get; set; } +``` + +#### Property Value + +[LLamaToken[]](./llama.native.llamatoken.md)
+ +### **SessionTokens** + +```csharp +public LLamaToken[] SessionTokens { get; set; } +``` + +#### Property Value + +[LLamaToken[]](./llama.native.llamatoken.md)
+ +### **LastTokens** + +```csharp +public LLamaToken[] LastTokens { get; set; } +``` + +#### Property Value + +[LLamaToken[]](./llama.native.llamatoken.md)
+ +### **LastTokensCapacity** + +```csharp +public int LastTokensCapacity { get; set; } +``` + +#### Property Value + +[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **MirostatMu** + +```csharp +public float? MirostatMu { get; set; } +``` + +#### Property Value + +[Single?](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1)
+ +## Constructors + +### **ExecutorBaseState()** + +```csharp +public ExecutorBaseState() +``` + +--- + +[`< Back`](./) diff --git a/docs/xmldocs/llama.statefulexecutorbase.md b/docs/xmldocs/llama.statefulexecutorbase.md index 8e4b2226d..d6ce8683f 100644 --- a/docs/xmldocs/llama.statefulexecutorbase.md +++ b/docs/xmldocs/llama.statefulexecutorbase.md @@ -12,9 +12,9 @@ The base class for stateful LLama executors. public abstract class StatefulExecutorBase : LLama.Abstractions.ILLamaExecutor ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [StatefulExecutorBase](./llama.statefulexecutorbase.md)
+Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [StatefulExecutorBase](./llama.statefulexecutorbase.md)
Implements [ILLamaExecutor](./llama.abstractions.illamaexecutor.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Fields @@ -22,9 +22,7 @@ Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/ap The logger used by this executor. -```csharp -protected ILogger _logger; -``` +### **_logger** ### **_pastTokensCount** @@ -44,7 +42,7 @@ protected int _consumedTokensCount; ### **_n_session_consumed** - +Number of tokens consumed from the session cache during the current run. ```csharp protected int _n_session_consumed; @@ -52,7 +50,7 @@ protected int _n_session_consumed; ### **_n_matching_session_tokens** - +Number of prompt tokens that match the loaded session cache prefix. ```csharp protected int _n_matching_session_tokens; @@ -63,7 +61,7 @@ protected int _n_matching_session_tokens; The path of the session file. ```csharp -protected string _pathSession; +protected string? _pathSession; ``` ### **_embeds** @@ -84,7 +82,7 @@ protected List _embed_inps; ### **_session_tokens** - +Tokens recovered from the session file and reused to warm up the KV cache. ```csharp protected List _session_tokens; @@ -112,73 +110,77 @@ public LLamaContext Context { get; } [LLamaContext](./llama.llamacontext.md)
-### **IsMultiModal** +### **AntipromptProcessor** + +Tracks anti-prompts across streamed output. ```csharp -public bool IsMultiModal { get; } +protected AntipromptProcessor AntipromptProcessor { get; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[AntipromptProcessor](./llama.antipromptprocessor.md)
-### **ClipModel** +### **IsMultiModal** + +Identify if it's a multi-modal model and there is a image to process. ```csharp -public LLavaWeights ClipModel { get; } +public bool IsMultiModal { get; } ``` #### Property Value -[LLavaWeights](./llama.llavaweights.md)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +### **ClipModel** -### **Images** +Multi-Modal Projections / Clip Model weights ```csharp -public List Images { get; } +public MtmdWeights? ClipModel { get; } ``` #### Property Value -[List<Byte[]>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
- -## Constructors - -### **StatefulExecutorBase(LLamaContext, ILogger)** +[MtmdWeights](./llama.mtmdweights.md)
+### **Embeds** +List of media: List of media for Multi-Modal models. ```csharp -protected StatefulExecutorBase(LLamaContext context, ILogger logger) +public List Embeds { get; } ``` -#### Parameters - -`context` [LLamaContext](./llama.llamacontext.md)
- -`logger` ILogger
+#### Property Value -### **StatefulExecutorBase(LLamaContext, LLavaWeights, ILogger)** +[List<SafeMtmdEmbed>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
+### **MtmdChunks** +Pending multimodal chunks produced by the MTMD tokenizer. ```csharp -public StatefulExecutorBase(LLamaContext context, LLavaWeights lLavaWeights, ILogger logger) +protected SafeMtmdInputChunks? MtmdChunks { get; set; } ``` -#### Parameters +#### Property Value + +[SafeMtmdInputChunks](./llama.native.safemtmdinputchunks.md)
-`context` [LLamaContext](./llama.llamacontext.md)
+## Constructors -`lLavaWeights` [LLavaWeights](./llama.llavaweights.md)
+### **.ctor** -`logger` ILogger
+### **.ctor** ## Methods ### **WithSessionFile(String)** -This API is currently not verified. +Attach a session cache file so the executor can reuse previous KV state if compatible. ```csharp public StatefulExecutorBase WithSessionFile(string filename) @@ -186,21 +188,23 @@ public StatefulExecutorBase WithSessionFile(string filename) #### Parameters -`filename` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`filename` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+Path to the llama.cpp session file. #### Returns [StatefulExecutorBase](./llama.statefulexecutorbase.md)
+The current executor instance for fluent configuration. #### Exceptions -[ArgumentNullException](https://docs.microsoft.com/en-us/dotnet/api/system.argumentnullexception)
+[ArgumentNullException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentnullexception)
[RuntimeError](./llama.exceptions.runtimeerror.md)
### **SaveSessionFile(String)** -This API has not been verified currently. +Persist the current session cache to disk. ```csharp public void SaveSessionFile(string filename) @@ -208,117 +212,270 @@ public void SaveSessionFile(string filename) #### Parameters -`filename` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`filename` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+Destination path for the llama.cpp session file. -### **HandleRunOutOfContext(Int32)** +### **HandleRunOutOfContext(Int32, IInferenceParams)** After running out of the context, take some tokens from the original prompt and recompute the logits in batches. ```csharp -protected void HandleRunOutOfContext(int tokensToKeep) +protected virtual Task HandleRunOutOfContext(int tokensToKeep, IInferenceParams inferenceParams) ``` #### Parameters -`tokensToKeep` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`tokensToKeep` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+The number of tokens from the initial prompt to preserve (e.g., system prompt). + +`inferenceParams` [IInferenceParams](./llama.abstractions.iinferenceparams.md)
+The parameters controlling the inference and overflow strategy. + +#### Returns + +[Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
+ +#### Exceptions + +[ContextOverflowException](./llama.exceptions.contextoverflowexception.md)
+Thrown when the overflow strategy is set to ThrowException, or if the model does not support native shifting. + +[ArgumentOutOfRangeException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentoutofrangeexception)
+Thrown when tokensToKeep is invalid. ### **TryReuseMatchingPrefix()** -Try to reuse the matching prefix from the session file. +Try to reuse the matching prompt prefix from the loaded session cache before evaluating new tokens. + +```csharp +protected virtual void TryReuseMatchingPrefix() +``` + +### **DisposeMtmdChunks()** + +Dispose and clear any queued multimodal chunk collection. + +```csharp +protected void DisposeMtmdChunks() +``` + +### **DisposeEmbeds()** + +Dispose and clear any pending multimodal embeddings. + +```csharp +protected void DisposeEmbeds() +``` + +### **GetMtmdMarker()** + +Retrieve the marker token used to signal media segments to the tokenizer. + +```csharp +protected string GetMtmdMarker() +``` + +#### Returns + +[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **BuildTokensWithFiller(List<LLamaToken>, Int32, LLamaToken)** + +Ensure the token list fills all positional slots reported by the MTMD helper. + +```csharp +protected static List BuildTokensWithFiller(List tokens, int totalPositions, LLamaToken fillerToken) +``` + +#### Parameters + +`tokens` [List<LLamaToken>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
+ +`totalPositions` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +`fillerToken` [LLamaToken](./llama.native.llamatoken.md)
+ +#### Returns + +[List<LLamaToken>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
+ +### **GetFillerToken(String)** + +Resolve the fallback token inserted when the tokenizer emits fewer tokens than positions. + +```csharp +protected LLamaToken GetFillerToken(string marker) +``` + +#### Parameters + +`marker` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +#### Returns + +[LLamaToken](./llama.native.llamatoken.md)
+ +### **PreprocessMtmd(String, InferStateArgs, Boolean, Boolean)** + +Prepare multimodal inputs by invoking the MTMD tokenizer and aligning filler tokens. + +```csharp +protected Task PreprocessMtmd(string text, InferStateArgs args, bool addBos, bool replaceExisting) +``` + +#### Parameters + +`text` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +`args` [InferStateArgs](./llama.statefulexecutorbase.inferstateargs.md)
+ +`addBos` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +`replaceExisting` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
+ +#### Returns + +[Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
+ +### **FinalizeMtmdEvaluation(Int32, Int32)** + +Apply bookkeeping after successfully evaluating multimodal chunks. + +```csharp +protected void FinalizeMtmdEvaluation(int newNPast, int previousConsumed) +``` + +#### Parameters + +`newNPast` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +`previousConsumed` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +### **EvaluateMtmdChunks(ref Int32, Int32, String)** + +Evaluate the queued MTMD chunks and update executor state. ```csharp -protected void TryReuseMatchingPrefix() +protected void EvaluateMtmdChunks(ref int nPast, int previousConsumed, string executorName) ``` -### **GetLoopCondition(InferStateArgs)** +#### Parameters + +`ref` `nPast` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
+ +`previousConsumed` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
-Decide whether to continue the loop. +`executorName` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+ +### **GetLoopCondition(InferStateArgs, CancellationToken)** + +Determine whether the inference loop should continue processing tokens. ```csharp -protected abstract Task GetLoopCondition(InferStateArgs args) +protected abstract Task GetLoopCondition(InferStateArgs args, CancellationToken cancellationToken = null) ``` #### Parameters `args` [InferStateArgs](./llama.statefulexecutorbase.inferstateargs.md)
+Mutable state associated with the current inference. + +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task<Boolean>](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+[Task<Boolean>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+`true` to continue generating; otherwise `false`. -### **PreprocessInputs(String, InferStateArgs)** +### **PreprocessInputs(String, InferStateArgs, CancellationToken)** -Preprocess the inputs before the inference. +Prepare the executor for inference by tokenizing input and updating cached state. ```csharp -protected abstract Task PreprocessInputs(string text, InferStateArgs args) +protected abstract Task PreprocessInputs(string? text, InferStateArgs args, CancellationToken cancellationToken = null) ``` #### Parameters -`text` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`text` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)?
+Prompt text to process. `args` [InferStateArgs](./llama.statefulexecutorbase.inferstateargs.md)
+Mutable state associated with the current inference. + +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
+[Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
-### **PostProcess(IInferenceParams, InferStateArgs)** +### **PostProcess(IInferenceParams, InferStateArgs, CancellationToken)** -Do some post processing after the inference. +Perform any post-processing on the generated tokens. ```csharp -protected abstract Task>> PostProcess(IInferenceParams inferenceParams, InferStateArgs args) +protected abstract Task<(bool, IReadOnlyList)> PostProcess(IInferenceParams inferenceParams, InferStateArgs args, CancellationToken cancellationToken = null) ``` #### Parameters `inferenceParams` [IInferenceParams](./llama.abstractions.iinferenceparams.md)
+Parameters controlling sampling. `args` [InferStateArgs](./llama.statefulexecutorbase.inferstateargs.md)
+Mutable state associated with the current inference. + +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task<ValueTuple<Boolean, IReadOnlyList<String>>>](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+[Task<(Boolean, IReadOnlyList<String>)>](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1)
+A tuple indicating whether generation should stop and any extra outputs to emit. -### **InferInternal(IInferenceParams, InferStateArgs)** +### **InferInternal(IInferenceParams, InferStateArgs, CancellationToken)** -The core inference logic. +Core inference loop that advances the model by one step. ```csharp -protected abstract Task InferInternal(IInferenceParams inferenceParams, InferStateArgs args) +protected abstract Task InferInternal(IInferenceParams inferenceParams, InferStateArgs args, CancellationToken cancellationToken = null) ``` #### Parameters `inferenceParams` [IInferenceParams](./llama.abstractions.iinferenceparams.md)
+Parameters controlling sampling. `args` [InferStateArgs](./llama.statefulexecutorbase.inferstateargs.md)
+Mutable state associated with the current inference. + +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
+[Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
-### **SaveState(String)** +### **SaveState(String, CancellationToken)** -Save the current state to a file. +Save the executor state to a serialized snapshot file. ```csharp -public abstract Task SaveState(string filename) +public abstract Task SaveState(string filename, CancellationToken cancellationToken = null) ``` #### Parameters -`filename` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`filename` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+Destination file for the serialized state. + +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
+[Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
### **GetStateData()** -Get the current state data. +Capture the executor state in a serializable object. ```csharp public abstract ExecutorBaseState GetStateData() @@ -327,77 +484,89 @@ public abstract ExecutorBaseState GetStateData() #### Returns [ExecutorBaseState](./llama.statefulexecutorbase.executorbasestate.md)
+State snapshot suitable for persistence. -### **LoadState(ExecutorBaseState)** +### **LoadState(ExecutorBaseState, CancellationToken)** -Load the state from data. +Restore executor state from a previously captured snapshot. ```csharp -public abstract Task LoadState(ExecutorBaseState data) +public abstract Task LoadState(ExecutorBaseState data, CancellationToken cancellationToken = null) ``` #### Parameters `data` [ExecutorBaseState](./llama.statefulexecutorbase.executorbasestate.md)
+State snapshot created by [StatefulExecutorBase.GetStateData()](./llama.statefulexecutorbase.md#getstatedata). + +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
+[Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
-### **LoadState(String)** +### **LoadState(String, CancellationToken)** -Load the state from a file. +Restore executor state from a serialized snapshot file. ```csharp -public abstract Task LoadState(string filename) +public abstract Task LoadState(string filename, CancellationToken cancellationToken = null) ``` #### Parameters -`filename` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`filename` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+Path to the snapshot produced by [StatefulExecutorBase.SaveState(String, CancellationToken)](./llama.statefulexecutorbase.md#savestatestring-cancellationtoken). + +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[Task](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
+[Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
### **InferAsync(String, IInferenceParams, CancellationToken)** -Execute the inference. +Execute an asynchronous inference session. ```csharp -public IAsyncEnumerable InferAsync(string text, IInferenceParams inferenceParams, CancellationToken cancellationToken) +public virtual IAsyncEnumerable InferAsync(string? text, IInferenceParams? inferenceParams = null, CancellationToken cancellationToken = null) ``` #### Parameters -`text` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
-The prompt. If null, generation will continue where it left off previously. +`text` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)?
+Optional prompt; when null generation resumes from prior state. -`inferenceParams` [IInferenceParams](./llama.abstractions.iinferenceparams.md)
+`inferenceParams` [IInferenceParams](./llama.abstractions.iinferenceparams.md)?
+Sampling parameters to apply; defaults are used when null. -`cancellationToken` [CancellationToken](https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
+`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
+Cancellation token for cooperative cancellation. #### Returns -[IAsyncEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)
+[IAsyncEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)
+Stream of decoded text segments as they become available. -### **PrefillPromptAsync(String)** +### **PrefillPromptAsync(String, CancellationToken)** Asynchronously runs a prompt through the model to compute KV cache without generating any new tokens. It could reduce the latency of the first time response if the first input from the user is not immediate. ```csharp -public Task PrefillPromptAsync(string prompt) +public virtual async Task PrefillPromptAsync(string prompt, CancellationToken cancellationToken = null) ``` #### Parameters -`prompt` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`prompt` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
Prompt to process +`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
+ #### Returns -[Task](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
+[Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task)
--- diff --git a/docs/xmldocs/llama.statelessexecutor.md b/docs/xmldocs/llama.statelessexecutor.md index 60c2e6e8b..e055f599c 100644 --- a/docs/xmldocs/llama.statelessexecutor.md +++ b/docs/xmldocs/llama.statelessexecutor.md @@ -13,41 +13,47 @@ This executor infer the input as one-time job. Previous inputs won't impact on t public class StatelessExecutor : LLama.Abstractions.ILLamaExecutor ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [StatelessExecutor](./llama.statelessexecutor.md)
+Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [StatelessExecutor](./llama.statelessexecutor.md)
Implements [ILLamaExecutor](./llama.abstractions.illamaexecutor.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties ### **IsMultiModal** +Identify if it's a multi-modal model and there is a image to process. + ```csharp public bool IsMultiModal { get; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **ClipModel** +Multi-Modal Projections / Clip Model weights + ```csharp -public LLavaWeights ClipModel { get; } +public MtmdWeights? ClipModel { get; } ``` #### Property Value -[LLavaWeights](./llama.llavaweights.md)
+[MtmdWeights](./llama.mtmdweights.md)
-### **Images** +### **Embeds** + +List of media: List of media for Multi-Modal models. ```csharp -public List Images { get; } +public List Embeds { get; } ``` #### Property Value -[List<Byte[]>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
+[List<SafeMtmdEmbed>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
### **Context** @@ -66,62 +72,51 @@ public LLamaContext Context { get; private set; } If true, applies the default template to the prompt as defined in the rules for llama_chat_apply_template template. ```csharp -public bool ApplyTemplate { get; set; } +public bool ApplyTemplate { get; init; } ``` #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
### **SystemMessage** The system message to use with the prompt. Only used when [StatelessExecutor.ApplyTemplate](./llama.statelessexecutor.md#applytemplate) is true. ```csharp -public string SystemMessage { get; set; } +public string? SystemMessage { get; init; } ``` #### Property Value -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
## Constructors -### **StatelessExecutor(LLamaWeights, IContextParams, ILogger)** - -Create a new stateless executor which will use the given model - -```csharp -public StatelessExecutor(LLamaWeights weights, IContextParams params, ILogger logger) -``` - -#### Parameters - -`weights` [LLamaWeights](./llama.llamaweights.md)
- -`params` [IContextParams](./llama.abstractions.icontextparams.md)
- -`logger` ILogger
+### **.ctor** ## Methods ### **InferAsync(String, IInferenceParams, CancellationToken)** +Asynchronously infers a response from the model. + ```csharp -public IAsyncEnumerable InferAsync(string prompt, IInferenceParams inferenceParams, CancellationToken cancellationToken) +public IAsyncEnumerable InferAsync(string prompt, IInferenceParams? inferenceParams = null, CancellationToken cancellationToken = null) ``` #### Parameters -`prompt` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`prompt` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
-`inferenceParams` [IInferenceParams](./llama.abstractions.iinferenceparams.md)
+`inferenceParams` [IInferenceParams](./llama.abstractions.iinferenceparams.md)?
+Any additional parameters -`cancellationToken` [CancellationToken](https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
+`cancellationToken` [CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken)
#### Returns -[IAsyncEnumerable<String>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)
+[IAsyncEnumerable<String>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1)
--- diff --git a/docs/xmldocs/llama.streamingtokendecoder.md b/docs/xmldocs/llama.streamingtokendecoder.md index ccb730ee1..6140d9e1b 100644 --- a/docs/xmldocs/llama.streamingtokendecoder.md +++ b/docs/xmldocs/llama.streamingtokendecoder.md @@ -12,8 +12,8 @@ Decodes a stream of tokens into a stream of characters public sealed class StreamingTokenDecoder ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [StreamingTokenDecoder](./llama.streamingtokendecoder.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [StreamingTokenDecoder](./llama.streamingtokendecoder.md)
+Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Properties @@ -27,7 +27,7 @@ public int AvailableCharacters { get; } #### Property Value -[Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+[Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **DecodeSpecialTokens** @@ -39,7 +39,7 @@ public bool DecodeSpecialTokens { get; set; } #### Property Value -[Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+[Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
## Constructors @@ -53,7 +53,7 @@ public StreamingTokenDecoder(Encoding encoding, LLamaWeights weights) #### Parameters -`encoding` [Encoding](https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding)
+`encoding` [Encoding](https://learn.microsoft.com/en-us/dotnet/api/system.text.encoding)
Text encoding to use `weights` [LLamaWeights](./llama.llamaweights.md)
@@ -82,7 +82,7 @@ public StreamingTokenDecoder(Encoding encoding, SafeLLamaContextHandle context) #### Parameters -`encoding` [Encoding](https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding)
+`encoding` [Encoding](https://learn.microsoft.com/en-us/dotnet/api/system.text.encoding)
Text encoding to use `context` [SafeLLamaContextHandle](./llama.native.safellamacontexthandle.md)
@@ -98,7 +98,7 @@ public StreamingTokenDecoder(Encoding encoding, SafeLlamaModelHandle weights) #### Parameters -`encoding` [Encoding](https://docs.microsoft.com/en-us/dotnet/api/system.text.encoding)
+`encoding` [Encoding](https://learn.microsoft.com/en-us/dotnet/api/system.text.encoding)
Text encoding to use `weights` [SafeLlamaModelHandle](./llama.native.safellamamodelhandle.md)
@@ -128,14 +128,14 @@ public void Add(int token) #### Parameters -`token` [Int32](https://docs.microsoft.com/en-us/dotnet/api/system.int32)
+`token` [Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32)
### **AddRange<T>(T)** Add all tokens in the given enumerable ```csharp -public void AddRange(T tokens) +public void AddRange(T tokens) where T : IEnumerable ``` #### Type Parameters @@ -156,7 +156,7 @@ public void AddRange(ReadOnlySpan tokens) #### Parameters -`tokens` [ReadOnlySpan<LLamaToken>](https://docs.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
+`tokens` [ReadOnlySpan<LLamaToken>](https://learn.microsoft.com/en-us/dotnet/api/system.readonlyspan-1)
### **Read(List<Char>)** @@ -168,7 +168,7 @@ public void Read(List dest) #### Parameters -`dest` [List<Char>](https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
+`dest` [List<Char>](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1)
### **Read()** @@ -180,7 +180,7 @@ public string Read() #### Returns -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **Reset()** diff --git a/docs/xmldocs/llama.transformers.prompttemplatetransformer.md b/docs/xmldocs/llama.transformers.prompttemplatetransformer.md index 4dcfe13b5..df675203d 100644 --- a/docs/xmldocs/llama.transformers.prompttemplatetransformer.md +++ b/docs/xmldocs/llama.transformers.prompttemplatetransformer.md @@ -13,9 +13,9 @@ A prompt formatter that will use llama.cpp's template formatter public class PromptTemplateTransformer : LLama.Abstractions.IHistoryTransform ``` -Inheritance [Object](https://docs.microsoft.com/en-us/dotnet/api/system.object) → [PromptTemplateTransformer](./llama.transformers.prompttemplatetransformer.md)
+Inheritance [Object](https://learn.microsoft.com/en-us/dotnet/api/system.object) → [PromptTemplateTransformer](./llama.transformers.prompttemplatetransformer.md)
Implements [IHistoryTransform](./llama.abstractions.ihistorytransform.md)
-Attributes [NullableContextAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) +Attributes [NullableContextAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullablecontextattribute), [NullableAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.nullableattribute) ## Constructors @@ -25,19 +25,21 @@ A prompt formatter that will use llama.cpp's template formatter If your model is not supported, you will need to define your own formatter according the cchat prompt specification for your model ```csharp -public PromptTemplateTransformer(LLamaWeights model, bool withAssistant) +public PromptTemplateTransformer(LLamaWeights model, bool withAssistant = true) ``` #### Parameters `model` [LLamaWeights](./llama.llamaweights.md)
-`withAssistant` [Boolean](https://docs.microsoft.com/en-us/dotnet/api/system.boolean)
+`withAssistant` [Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean)
## Methods ### **HistoryToText(ChatHistory)** +Convert a ChatHistory instance to plain text. + ```csharp public string HistoryToText(ChatHistory history) ``` @@ -45,13 +47,16 @@ public string HistoryToText(ChatHistory history) #### Parameters `history` [ChatHistory](./llama.common.chathistory.md)
+The ChatHistory instance #### Returns -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
### **TextToHistory(AuthorRole, String)** +Converts plain text to a ChatHistory instance. + ```csharp public ChatHistory TextToHistory(AuthorRole role, string text) ``` @@ -59,15 +64,20 @@ public ChatHistory TextToHistory(AuthorRole role, string text) #### Parameters `role` [AuthorRole](./llama.common.authorrole.md)
+The role for the author. -`text` [String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+`text` [String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
+The chat history as plain text. #### Returns [ChatHistory](./llama.common.chathistory.md)
+The updated history. ### **Clone()** +Copy the transform. + ```csharp public IHistoryTransform Clone() ``` @@ -90,7 +100,7 @@ public static string ToModelPrompt(LLamaTemplate template) #### Returns -[String](https://docs.microsoft.com/en-us/dotnet/api/system.string)
+[String](https://learn.microsoft.com/en-us/dotnet/api/system.string)
The formatted template string as defined by the model ---