From 89b0a5909558f353fda4890c819c74dda4e976eb Mon Sep 17 00:00:00 2001 From: natke Date: Sat, 16 Nov 2024 18:11:12 -0800 Subject: [PATCH] Add C# API docs --- docs/genai/api/csharp.md | 86 ++++++++++++++++++++++++++++++++++++++++ docs/genai/api/java.md | 4 ++ 2 files changed, 90 insertions(+) diff --git a/docs/genai/api/csharp.md b/docs/genai/api/csharp.md index 915e6e2bf5787..bc9b478440449 100644 --- a/docs/genai/api/csharp.md +++ b/docs/genai/api/csharp.md @@ -155,6 +155,33 @@ public void GenerateNextToken() public ReadOnlySpan GetSequence(ulong index) ``` +### Set active adapter + +Sets the active adapter on this Generator instance. + +```csharp +using var model = new Model(modelPath); +using var genParams = new GeneratorParams(model); +using var generator = new Generator(model, genParams); +using var adapters = new Adapters(model); +string adapterName = "..." + +generator.SetActiveAdapter(adapters, adapterName); +``` + +#### Parameters + +* `adapters`: the previously created `Adapter` object +* `adapterName`: the name of the adapter to activate + +#### Return value + +`void` + +#### Exception + +Throws on error. + ## Sequences class ### Num sequences member @@ -169,3 +196,62 @@ public ulong NumSequences { get { return _numSequences; } } public ReadOnlySpan this[ulong sequenceIndex] ``` +## Adapter class + +This API is used to load and switch fine-tuned adapters, such as LoRA adapters. + +### Constructor + +Construct an instance of an Adapter class. + +```csharp +using var model = new Model(modelPath); + +using var adapters = new Adapters(model); +``` + +#### Parameters + +* `model`: a previously constructed model class + +### Load Adapter method + +Loads an adapter file from disk. + +```csharp +string adapterPath = Path() +string adapterName = ... + +adapters.LoadAdapter(adapterPath, adapterName); +``` + +#### Parameters + +* `adapterPath`: the path to the adapter file on disk +* `adapterName`: a string identifier used to refer to the adapter in subsequent methods + +#### Return value + +`void` + +### Unload Adapter method + +Unloads an adapter file from memory. + +```csharp +adapters.UnLoadAdapter(adapterName); +``` + +#### Parameters + +* `adapterName`: the name of the adapter to unload + +#### Return value + +`void` + +#### Execption + +Throws an exception on error. + + diff --git a/docs/genai/api/java.md b/docs/genai/api/java.md index 47e654566c569..322ddead8970f 100644 --- a/docs/genai/api/java.md +++ b/docs/genai/api/java.md @@ -610,3 +610,7 @@ public int[] getSequence(long sequenceIndex) The sequence as an array of integers. + +## Adapter class + +_Coming very soon!_