SmartAICompendium.TextGeneration
1.1.0
dotnet add package SmartAICompendium.TextGeneration --version 1.1.0
NuGet\Install-Package SmartAICompendium.TextGeneration -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SmartAICompendium.TextGeneration" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SmartAICompendium.TextGeneration --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SmartAICompendium.TextGeneration, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SmartAICompendium.TextGeneration as a Cake Addin #addin nuget:?package=SmartAICompendium.TextGeneration&version=1.1.0 // Install SmartAICompendium.TextGeneration as a Cake Tool #tool nuget:?package=SmartAICompendium.TextGeneration&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
This package allow easy and typed text generation with a local model and a embedded python. Compatible with windows, linux and mac.
Generation Parameters
Name | Description |
---|---|
prompt | Prompt to guide the text generation. |
maxNewTokens | Override the default value of maxNewTokens. The maximum number of new tokens to generate. |
badWords | Override the default value of badWords. A list of sequences to stop generation when encountered. |
topK | Override the default value of topK. |
topP | Override the default value of topP. |
temperature | Override the default value of temperature. |
repetitionPenalty | Override the default value of repetitionPenalty. |
lastNTokens | Override the default value of lastNTokens. The number of last tokens to use for repetition penalty. |
seed | Override the default value of seed. For a specific seed, a prompt will return the same result. By default, -1 return a randomized result. |
reset | Override the default value of reset. Whether to reset the model state before generating text. |
batchSize | Override the default value of batchSize. The batch size to use for evaluating tokens. |
**valid parameters will depend of the model
Usage examples
Generation with huggingface model
The model can be a huggingface repoId ("{user}/{model}") or local folder containing the model. The model will be downloaded if not already present (see SmartAICompendium.Common)
var model = new TextInference("aihub-app/zyte-1B");
var text = model.Generate("Instruct: Give the list of french speaking countries\nOutput:",
maxNewTokens: 256, badWords:null, topK: 40, topP: 0.95f, temperature: 0.8f, repetitionPenalty: 1.1f, lastNTokens: 64, int seed:-1, reset: true, batchSize: 8);
Console.WriteLine(text);
Chat Generation with local reference
var model = new TextInference("C:\\TinyLlama-1.1B-Chat-v1.0");
var message = model.GenerateChat(new ChatMessage[]{
new(){
Role = "system",
Content = "You are an adventurer who always responds in the style of a pirate."
},
new(){
Role = "user",
Content = "Tell me more about your last adventure."
}
},
maxNewTokens: 256, temperature: 0.7f, topK: 50, topP: 0.95f);
Console.WriteLine(message.Content);
Loading packages before use
if not done, the packages will be installed at the class initialization.
TextInference.Update();
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- SmartAICompendium.Common (>= 1.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.