Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions LLama.Examples/Examples/ChatSessionStripRoleName.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using LLama.Common;
using LLama.Common;
using LLama.Sampling;

namespace LLama.Examples.Examples;

Expand Down Expand Up @@ -27,9 +28,12 @@ public static async Task Run()
new string[] { "User:", "Assistant:" },
redundancyLength: 8));

InferenceParams inferenceParams = new InferenceParams()
var inferenceParams = new InferenceParams
{
Temperature = 0.9f,
SamplingPipeline = new DefaultSamplingPipeline
{
Temperature = 0.9f
},
AntiPrompts = new List<string> { "User:" }
};

Expand Down
8 changes: 6 additions & 2 deletions LLama.Examples/Examples/ChatSessionWithHistory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using LLama.Common;
using LLama.Sampling;

namespace LLama.Examples.Examples;

Expand Down Expand Up @@ -39,9 +40,12 @@ public static async Task Run()
new string[] { "User:", "Assistant:" },
redundancyLength: 8));

InferenceParams inferenceParams = new InferenceParams()
var inferenceParams = new InferenceParams
{
Temperature = 0.9f,
SamplingPipeline = new DefaultSamplingPipeline
{
Temperature = 0.9f
},
AntiPrompts = new List<string> { "User:" }
};

Expand Down
8 changes: 6 additions & 2 deletions LLama.Examples/Examples/ChatSessionWithRestart.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using LLama.Common;
using LLama.Sampling;

namespace LLama.Examples.Examples;

Expand Down Expand Up @@ -29,9 +30,12 @@ public static async Task Run()
ChatSession session = new ChatSession(executor);
session.LoadSession(resetState);

InferenceParams inferenceParams = new InferenceParams()
var inferenceParams = new InferenceParams
{
Temperature = 0.9f,
SamplingPipeline = new DefaultSamplingPipeline
{
Temperature = 0.9f
},
AntiPrompts = new List<string> { "User:" }
};

Expand Down
10 changes: 7 additions & 3 deletions LLama.Examples/Examples/ChatSessionWithRoleName.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using LLama.Common;
using LLama.Common;
using LLama.Sampling;

namespace LLama.Examples.Examples;

Expand All @@ -22,9 +23,12 @@ public static async Task Run()

ChatSession session = new(executor, chatHistory);

InferenceParams inferenceParams = new InferenceParams()
var inferenceParams = new InferenceParams
{
Temperature = 0.9f,
SamplingPipeline = new DefaultSamplingPipeline
{
Temperature = 0.9f
},
AntiPrompts = new List<string> { "User:" }
};

Expand Down
11 changes: 8 additions & 3 deletions LLama.Examples/Examples/CodingAssistant.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace LLama.Examples.Examples
using LLama.Sampling;

namespace LLama.Examples.Examples
{
using LLama.Common;
using System;
Expand Down Expand Up @@ -40,9 +42,12 @@ public static async Task Run()
"\nWrite 'exit' to exit");
Console.ForegroundColor = ConsoleColor.White;

var inferenceParams = new InferenceParams()
var inferenceParams = new InferenceParams
{
Temperature = 0.8f,
SamplingPipeline = new DefaultSamplingPipeline
{
Temperature = 0.8f
},
MaxTokens = -1,
};

Expand Down
2 changes: 1 addition & 1 deletion LLama.Examples/Examples/GetEmbeddings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using LLama.Common;
using LLama.Common;

namespace LLama.Examples.Examples
{
Expand Down
10 changes: 7 additions & 3 deletions LLama.Examples/Examples/GrammarJsonResponse.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using LLama.Common;
using LLama.Common;
using LLama.Grammars;
using LLama.Sampling;

namespace LLama.Examples.Examples
{
Expand Down Expand Up @@ -27,10 +28,13 @@ public static async Task Run()
using var grammarInstance = grammar.CreateInstance();
var inferenceParams = new InferenceParams()
{
Temperature = 0.6f,
SamplingPipeline = new DefaultSamplingPipeline
{
Temperature = 0.6f,
Grammar = grammarInstance
},
AntiPrompts = new List<string> { "Question:", "#", "Question: ", ".\n" },
MaxTokens = 50,
Grammar = grammarInstance
};

while (true)
Expand Down
12 changes: 10 additions & 2 deletions LLama.Examples/Examples/InstructModeExecute.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using LLama.Common;
using LLama.Common;
using LLama.Sampling;

namespace LLama.Examples.Examples
{
Expand All @@ -25,7 +26,14 @@ public static async Task Run()
"make friend with human, no less than 200 words.\"");
Console.ForegroundColor = ConsoleColor.White;

var inferenceParams = new InferenceParams() { Temperature = 0.8f, MaxTokens = 600 };
var inferenceParams = new InferenceParams
{
SamplingPipeline = new DefaultSamplingPipeline
{
Temperature = 0.8f
},
MaxTokens = 600
};

while (true)
{
Expand Down
11 changes: 8 additions & 3 deletions LLama.Examples/Examples/LLama3ChatSession.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using LLama.Common;
using LLama.Common;
using LLama.Sampling;
using LLama.Transformers;

namespace LLama.Examples.Examples;
Expand Down Expand Up @@ -37,10 +38,14 @@ public static async Task Run()
[model.Tokens.EndOfTurnToken!, "�"],
redundancyLength: 5));

var inferenceParams = new InferenceParams()
var inferenceParams = new InferenceParams
{
SamplingPipeline = new DefaultSamplingPipeline
{
Temperature = 0.6f
},

MaxTokens = -1, // keep generating tokens until the anti prompt is encountered
Temperature = 0.6f,
AntiPrompts = [model.Tokens.EndOfTurnToken!] // model specific end of turn string
};

Expand Down
17 changes: 14 additions & 3 deletions LLama.Examples/Examples/LlavaInteractiveModeExecute.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System.Text.RegularExpressions;
using System.Text.RegularExpressions;
using LLama.Common;
using Spectre.Console;
using LLama.Native;
using LLama.Sampling;

namespace LLama.Examples.Examples
{
Expand Down Expand Up @@ -30,9 +31,19 @@ public static async Task Run()

Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("The executor has been enabled. In this example, the prompt is printed, the maximum tokens is set to {0} and the context size is {1}.", maxTokens, parameters.ContextSize );
Console.WriteLine("To send an image, enter its filename in curly braces, like this {c:/image.jpg}.");
Console.WriteLine("To send an image, enter its filename in curly braces, like this {c:/image.jpg}.");

var inferenceParams = new InferenceParams() { Temperature = 0.1f, AntiPrompts = new List<string> { "\nUSER:" }, MaxTokens = maxTokens };
var inferenceParams = new InferenceParams
{
SamplingPipeline = new DefaultSamplingPipeline
{
Temperature = 0.1f
},

AntiPrompts = new List<string> { "\nUSER:" },
MaxTokens = maxTokens

};

do
{
Expand Down
8 changes: 6 additions & 2 deletions LLama.Examples/Examples/LoadAndSaveSession.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using LLama.Common;
using LLama.Common;
using LLama.Sampling;

namespace LLama.Examples.Examples
{
Expand Down Expand Up @@ -35,7 +36,10 @@ in session.ChatAsync(
new ChatHistory.Message(AuthorRole.User, prompt),
new InferenceParams()
{
Temperature = 0.6f,
SamplingPipeline = new DefaultSamplingPipeline
{
Temperature = 0.6f
},
AntiPrompts = new List<string> { "User:" }
}))
{
Expand Down
13 changes: 11 additions & 2 deletions LLama.Examples/Examples/LoadAndSaveState.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using LLama.Common;
using LLama.Common;
using LLama.Sampling;

namespace LLama.Examples.Examples
{
Expand Down Expand Up @@ -27,7 +28,15 @@ public static async Task Run()
Console.ForegroundColor = ConsoleColor.White;
Console.Write(prompt);

var inferenceParams = new InferenceParams() { Temperature = 0.6f, AntiPrompts = new List<string> { "User:" } };
var inferenceParams = new InferenceParams
{
SamplingPipeline = new DefaultSamplingPipeline
{
Temperature = 0.6f
},

AntiPrompts = new List<string> { "User:" }
};

while (true)
{
Expand Down
14 changes: 12 additions & 2 deletions LLama.Examples/Examples/StatelessModeExecute.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using LLama.Common;
using LLama.Common;
using LLama.Examples.Extensions;
using LLama.Sampling;

namespace LLama.Examples.Examples
{
Expand All @@ -24,7 +25,16 @@ public static async Task Run()
"a prompt for it yourself!");
Console.ForegroundColor = ConsoleColor.White;

var inferenceParams = new InferenceParams() { Temperature = 0.6f, AntiPrompts = new List<string> { "Question:", "#", "Question: ", ".\n" }, MaxTokens = 50 };
var inferenceParams = new InferenceParams
{
SamplingPipeline = new DefaultSamplingPipeline
{
Temperature = 0.6f
},

AntiPrompts = new List<string> { "Question:", "#", "Question: ", ".\n" },
MaxTokens = 50
};

while (true)
{
Expand Down
13 changes: 8 additions & 5 deletions LLama.Examples/Examples/TalkToYourself.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Text;
using System.Text;
using LLama.Abstractions;
using LLama.Common;
using LLama.Sampling;

namespace LLama.Examples.Examples
{
Expand Down Expand Up @@ -43,11 +44,13 @@ private static async Task<string> Prompt(ILLamaExecutor executor, ConsoleColor c
{
var inferenceParams = new InferenceParams
{
Temperature = 0.9f,
AntiPrompts = new List<string> { "Alice:", "Bob:", "User:" },
SamplingPipeline = new Mirostat2SamplingPipeline
{
Tau = 10
},

AntiPrompts = [ "Alice:", "Bob:", "User:" ],
MaxTokens = 128,
Mirostat = MirostatType.Mirostat2,
MirostatTau = 10,
};

Console.ForegroundColor = ConsoleColor.White;
Expand Down
Loading