Merge pull request #336 from wenwei-lin/master
add config LLamaSharp tutorial in docs
3
.gitignore
vendored
|
|
@ -292,4 +292,5 @@ XMLs
|
|||
logs
|
||||
wwwroot
|
||||
appsettings.Production.json
|
||||
*.csproj.user
|
||||
*.csproj.user
|
||||
env/
|
||||
|
|
@ -96,6 +96,15 @@ The main documentation for the site is organized into the following sections:
|
|||
llm/few-shot-learning
|
||||
llm/provider
|
||||
|
||||
.. _llamasharp:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Use Local LLM Models
|
||||
|
||||
llama-sharp/config-llamasharp
|
||||
llama-sharp/use-llamasharp-in-ui
|
||||
|
||||
.. _architecture-docs:
|
||||
|
||||
.. toctree::
|
||||
|
|
|
|||
BIN
docs/llama-sharp/assets/check-llamasharp-version.png
Normal file
|
After Width: | Height: | Size: 275 KiB |
BIN
docs/llama-sharp/assets/choose-llamasharp-as-provider.png
Normal file
|
After Width: | Height: | Size: 322 KiB |
BIN
docs/llama-sharp/assets/click-test-button.png
Normal file
|
After Width: | Height: | Size: 446 KiB |
BIN
docs/llama-sharp/assets/console-output-in-botsharp.png
Normal file
|
After Width: | Height: | Size: 246 KiB |
BIN
docs/llama-sharp/assets/converstaion-examples.png
Normal file
|
After Width: | Height: | Size: 507 KiB |
BIN
docs/llama-sharp/assets/edit-agent.png
Normal file
|
After Width: | Height: | Size: 451 KiB |
BIN
docs/llama-sharp/assets/install-llamasharp-plugin.png
Normal file
|
After Width: | Height: | Size: 430 KiB |
60
docs/llama-sharp/config-llamasharp.md
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
# Config LLamaSharp
|
||||
|
||||
BotSharp contains LLamaSharp plugin that allows you to run local llm models. To use the LLamaSharp, you need to config the BotSharp project with few steps.
|
||||
|
||||
## Install LLamaSharp Backend
|
||||
|
||||
Before use LLamaSharp plugin, you need to install one of the LLamaSharp backend services that suits your environment.
|
||||
|
||||
- [`LLamaSharp.Backend.Cpu`](https://www.nuget.org/packages/LLamaSharp.Backend.Cpu): Pure CPU for Windows & Linux. Metal for Mac.
|
||||
- [`LLamaSharp.Backend.Cuda11`](https://www.nuget.org/packages/LLamaSharp.Backend.Cuda11): CUDA 11 for Windows and Linux
|
||||
- [`LLamaSharp.Backend.Cuda12`](https://www.nuget.org/packages/LLamaSharp.Backend.Cuda12): CUDA 12 for Windows and Linux
|
||||
|
||||
**Please install the same version of LLamaSharp Backend with the LLamaSharp in BotSharp.Plugin.LLamaSharp.csproj.**
|
||||
|
||||

|
||||
|
||||
```shell
|
||||
# move to the LLamaSharp Plugin Project
|
||||
$ cd src/Plugins/BotSharp.Plugin.LLamaSharp
|
||||
# Install the LLamaSharp Backend
|
||||
$ dotnet add package LLamaSharp.Backend.Cpu --version 0.9.1
|
||||
```
|
||||
|
||||
## Download and Config Local LLM Models
|
||||
|
||||
LLamaSharp supports many LLM Models like LLaMA and Alpaca. Download the `gguf` format models and save them in your machine.
|
||||
|
||||
We will use a [Llama 2](https://huggingface.co/TheBloke/llama-2-7B-Guanaco-QLoRA-GGUF) model in this tutorial.
|
||||
|
||||
After downloading the model, open the `src/WebStarter/appsettings.json` file to config the LLamaSharp models. Set the `LlmProviders` and `LlamaSharp` fields to correct settings as your computer. For example:
|
||||
|
||||
```json
|
||||
{
|
||||
...,
|
||||
"LlmProviders": [
|
||||
...,
|
||||
{
|
||||
"Provider": "llama-sharp",
|
||||
"Models": [
|
||||
{
|
||||
"Name": "llama-2-7b.Q2_K.gguf",
|
||||
"Type": "chat"
|
||||
}
|
||||
]
|
||||
},
|
||||
...
|
||||
],
|
||||
...,
|
||||
"LlamaSharp": {
|
||||
"Interactive": true,
|
||||
"ModelDir": "/Users/wenwei/Desktop/LLM",
|
||||
"DefaultModel": "llama-2-7b.Q2_K.gguf",
|
||||
"MaxContextLength": 1024,
|
||||
"NumberOfGpuLayer": 20
|
||||
},
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
For more details about LLamaSharp, visit [LLamaSharp - GitHub](https://github.com/SciSharp/LLamaSharp).
|
||||
29
docs/llama-sharp/use-llamasharp-in-ui.md
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
# Use LLamaSharp in BotSharp
|
||||
|
||||
Start the BotSharp backend and frontend services, and follow this tutorial.
|
||||
|
||||
## Install LLamaSharp Plugin in UI.
|
||||
|
||||
Go to the Plugin page and install LLamaSharp Plugin.
|
||||
|
||||

|
||||
|
||||
## Config LLamaSharp as LLM Providers for Agents
|
||||
|
||||
Edit or create an agent in Agents page, and config the agent.
|
||||
|
||||

|
||||
|
||||
In the edit page, config the provider as llama-sharp.
|
||||
|
||||

|
||||
|
||||
Then test the agent.
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
If run successfully, you will see log like this in BotSharp service's console.
|
||||
|
||||

|
||||