Are you sure you want to delete this task? Once this task is deleted, it cannot be recovered.
|
|
2 years ago | |
|---|---|---|
| Assets | 2 years ago | |
| LLama | 2 years ago | |
| LLama.Examples | 2 years ago | |
| LLama.Unittest | 2 years ago | |
| .gitignore | 2 years ago | |
| LICENSE | 2 years ago | |
| LLamaSharp.sln | 2 years ago | |
| README.md | 2 years ago | |
The C#/.NET binding of llama.cpp. It provides APIs to inference the LLaMa Models and deploy it on native environment or Web. It works on
both Windows and Linux and does NOT require compiling the library yourself.
Just search LLama in nuget package manager and install it!
PM> Install-Package LLama
Currently, LLamaSharp provides two kinds of model, LLamaModelV1 and LLamaModel. Both of them works but LLamaModel is more recommended
because it provides better alignment with the master branch of llama.cpp.
Besides, ChatSession makes it easier to wrap your own chat bot. The code below is a simple example. For all examples, please refer to
Examples.
var model = new LLamaModel(new LLamaParams(model: "<Your path>", n_ctx: 512, repeat_penalty: 1.0f));
var session = new ChatSession<LLamaModel>(model).WithPromptFile("<Your prompt file path>")
.WithAntiprompt(new string[] { "User:" );
Console.Write("\nUser:");
while (true)
{
Console.ForegroundColor = ConsoleColor.Green;
var question = Console.ReadLine();
Console.ForegroundColor = ConsoleColor.White;
var outputs = session.Chat(question); // It's simple to use the chat API.
foreach (var output in outputs)
{
Console.Write(output);
}
}
The following example shows how to quantize the model. With LLamaSharp you needn't to compile c++ project and run scripts to quantize the model, instead, just run it in C#.
string srcFilename = "<Your source path>";
string dstFilename = "<Your destination path>";
string ftype = "q4_0";
if(Quantizer.Quantize(srcFileName, dstFilename, ftype))
{
Console.WriteLine("Quantization succeed!");
}
else
{
Console.WriteLine("Quantization failed!");
}
✅ LLaMa model inference.
✅ Embeddings generation.
✅ Chat session.
✅ Quantization
🔳 ASP.NET core Integration
🔳 WPF UI Integration
The model weights is too large to include in the project. However some resources could be found below:
The weights included in the magnet is exactly the weights from Facebook LLaMa.
The prompts could be found below:
This project is licensed under the terms of the MIT license.
C#/.NET上易用的LLM高性能推理框架,支持LLaMA和LLaVA系列模型。
C# Text Metal JavaScript HTML+Razor other