You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+58-14Lines changed: 58 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -2,21 +2,65 @@
2
2
3
3
Hi, welcome to develop LLamaSharp with us together! We are always open for every contributor and any format of contributions! If you want to maintain this library actively together, please contact us to get the write access after some PRs. (Email: [email protected])
4
4
5
-
In this page, we'd like to introduce how to make contributions here easily. 😊
5
+
In this page, we introduce how to make contributions here easily. 😊
6
6
7
-
## Compile the native library from source
7
+
## The goal of LLamaSharp
8
8
9
-
Firstly, please clone the [llama.cpp](https://github.com/ggerganov/llama.cpp) repository and following the instructions in [llama.cpp readme](https://github.com/ggerganov/llama.cpp#build)to configure your local environment.
9
+
At the beginning, LLamaSharp is a C# binding of [llama.cpp](https://github.com/ggerganov/llama.cpp). It provided only some wrappers for llama.cpp to let C#/.NET users could run LLM models on their local device efficiently even if without any experience with C++. After around a year of development, more tools and integrations has been added to LLamaSharp, significantly expanding the application of LLamaSharp. Though llama.cpp is still the only backend of LLamaSharp, the goal of this repository is more likely to be an efficient and easy-to-use library of LLM inference, rather than just a binding of llama.cpp.
10
10
11
-
If you want to support cublas in the compilation, please make sure that you've installed the cuda.
11
+
In this way, our development of LLamaSharp is divided into two main directions:
12
12
13
-
When building from source, please add `-DBUILD_SHARED_LIBS=ON` to the cmake instruction. For example, when building with cublas but without openblas, use the following instruction:
13
+
1. To make LLamaSharp more efficient. For example, `BatchedExecutor` could accept multiple queries and generate the response for them at the same time, which significantly improves the throughput. This part is always related with native APIs and executors in LLamaSharp.
14
+
2. To make it easier to use LLamaSharp. We believe the best library is to let users build powerful functionalities with simple code. Higher-level APIs and integrations with other libraries are the key points of it.
15
+
16
+
17
+
## How to compile the native library from source
18
+
19
+
If you want to contribute to the first direction of our goal, you may need to compile the native library yourself.
20
+
21
+
Firstly, please follow the instructions in [llama.cpp readme](https://github.com/ggerganov/llama.cpp#build) to configure your local environment. Most importantly, CMake with version higher than 3.14 should be installed on your device.
22
+
23
+
Secondly, clone the llama.cpp repositories. You could manually clone it and checkout to the right commit according to [Map of LLamaSharp and llama.cpp versions](https://github.com/SciSharp/LLamaSharp?tab=readme-ov-file#map-of-llamasharp-and-llama.cpp-versions), or use clone the submodule of LLamaSharp when cloning LLamaSharp.
If you want to support cublas in the compilation, please make sure that you've installed it. If you are using Intel CPU, please check the highest AVX ([Advanced Vector Extensions](https://en.wikipedia.org/wiki/Advanced_Vector_Extensions)) level that is supported by your device.
30
+
31
+
As shown in [llama.cpp cmake file](https://github.com/ggerganov/llama.cpp/blob/master/CMakeLists.txt), there are many options that could be enabled or disabled when building the library. The following ones are commonly used when using it as a native library of LLamaSharp.
32
+
33
+
```cpp
34
+
option(BUILD_SHARED_LIBS "build shared libraries") // Please always enable it
35
+
option(LLAMA_NATIVE "llama: enable -march=native flag") // Could be disabled
36
+
option(LLAMA_AVX "llama: enable AVX") // Enable it if the highest supported avx level is AVX
37
+
option(LLAMA_AVX2 "llama: enable AVX2") // Enable it if the highest supported avx level is AVX2
38
+
option(LLAMA_AVX512 "llama: enable AVX512") // Enable it if the highest supported avx level is AVX512
39
+
option(LLAMA_BLAS "llama: use BLAS") // Enable it if you want to use BLAS library to acclerate the computation on CPU
40
+
option(LLAMA_CUDA "llama: use CUDA") // Enable it if you have CUDA device
41
+
option(LLAMA_CLBLAST "llama: use CLBlast") // Enable it if you have a device with CLBLast or OpenCL support, for example, some AMD GPUs.
42
+
option(LLAMA_VULKAN "llama: use Vulkan") // Enable it if you have a device with Vulkan support
43
+
option(LLAMA_METAL "llama: use Metal") // Enable it if you are using a MAC with Metal device.
44
+
option(LLAMA_BUILD_TESTS "llama: build tests") // Please disable it.
45
+
option(LLAMA_BUILD_EXAMPLES "llama: build examples") // Please disable it.
46
+
option(LLAMA_BUILD_SERVER "llama: build server example")// Please disable it.
47
+
```
48
+
49
+
Most importantly, `-DBUILD_SHARED_LIBS=ON` must be added to the cmake instruction and other options depends on you. For example, when building with cublas but without openblas, use the following instruction:
14
50
15
51
```bash
52
+
mkdir build && cd build
16
53
cmake .. -DLLAMA_CUBLAS=ON -DBUILD_SHARED_LIBS=ON
54
+
cmake --build . --config Release
17
55
```
18
56
19
-
After running `cmake --build . --config Release`, you could find the `llama.dll`, `llama.so` or `llama.dylib` in your build directory. After pasting it to `LLamaSharp/LLama/runtimes` you can use it as the native library in LLamaSharp.
57
+
Now you could find the `llama.dll`, `libllama.so` or `llama.dylib` in your build directory (or `build/bin`).
58
+
59
+
To load the compiled native library, please add the following code to the very beginning of your code.
@@ -39,19 +83,19 @@ You could use exactly the same prompt, the same model and the same parameters to
39
83
40
84
If the experiment showed that it worked well in llama.cpp but didn't in LLamaSharp, a search for the problem could be started. While the reason of the problem could be various, the best way I think is to add log-print in the code of llama.cpp and use it in LLamaSharp after compilation. Thus, when running LLamaSharp, you could see what happened in the native library.
41
85
42
-
After finding out the reason, a painful but happy process comes. When working on the BUG fix, there's only one rule to follow, that is keeping the examples working well. If the modification fixed the BUG but impact on other functions, it would not be a good fix.
43
-
44
-
During the BUG fix process, please don't hesitate to discuss together when you stuck on something.
86
+
During the BUG fix process, please don't hesitate to discuss together when you are blocked.
45
87
46
88
## Add integrations
47
89
48
-
All kinds of integration are welcomed here! Currently the following integrations are under work or on our schedule:
90
+
All kinds of integration are welcomed here! Currently the following integrations have been added but still need improvement:
91
+
92
+
1. semantic-kernel
93
+
2. kernel-memory
94
+
3. BotSharp (maintained in SciSharp/BotSharp repo)
95
+
4. Langchain (maintained in tryAGI/LangChain repo)
49
96
50
-
1. BotSharp
51
-
2. semantic-kernel
52
-
3. Unity
97
+
If you find another library that is good to be integrated, please open an issue to let us know!
53
98
54
-
Besides, for some other integrations, like `ASP.NET core`, `SQL`, `Blazor` and so on, we'll appreciate it if you could help with that. If the time is limited for you, providing an example for it also means a lot!
**LLamaSharp is a cross-platform library to run 🦙LLaMA/LLaVA model (and others) in local device. Based on [llama.cpp](https://github.com/ggerganov/llama.cpp), inference with LLamaSharp is efficient on both CPU and GPU. With the higher-level APIs and RAG support, it's convenient to deploy LLM (Large Language Model) in your application with LLamaSharp.**
14
+
**LLamaSharp is a cross-platform library to run 🦙LLaMA/LLaVA model (and others) in your local device. Based on [llama.cpp](https://github.com/ggerganov/llama.cpp), inference with LLamaSharp is efficient on both CPU and GPU. With the higher-level APIs and RAG support, it's convenient to deploy LLM (Large Language Model) in your application with LLamaSharp.**
15
15
16
16
**Please star the repo to show your support for this project!🤗**
There are integarions for the following libraries, making it easier to develop your APP. Integrations for semantic-kernel and kernel-memory are developed in LLamaSharp repository, while others are developed in their own repositories.
61
63
@@ -76,7 +78,7 @@ The following examples show how to build APPs with LLamaSharp.
For more examples, please refer to [LLamaSharp.Examples](./LLama.Examples).
169
171
170
172
171
-
## FAQ
173
+
## 💡FAQ
172
174
173
175
#### Why GPU is not used when I have installed CUDA
174
176
@@ -197,9 +199,9 @@ Generally, there are two possible cases for this problem:
197
199
Please set anti-prompt or max-length when executing the inference.
198
200
199
201
200
-
## Contributing
202
+
## 🙌Contributing
201
203
202
-
Any contribution is welcomed! There's a TODO list in [LLamaSharp Dev Project](https://github.com/orgs/SciSharp/projects/5) and you could pick an interesting one to start. Please read the [contributing guide](https://scisharp.github.io/LLamaSharp/latest/ContributingGuide/) for more information.
204
+
Any contribution is welcomed! There's a TODO list in [LLamaSharp Dev Project](https://github.com/orgs/SciSharp/projects/5) and you could pick an interesting one to start. Please read the [contributing guide](./CONTRIBUTING.md) for more information.
203
205
204
206
You can also do one of the followings to help us make LLamaSharp better:
205
207
@@ -215,6 +217,14 @@ Join our chat on [Discord](https://discord.gg/7wNVU65ZDY) (please contact Rinne
0 commit comments