GithubHelp home page GithubHelp logo

werddomain / llama.net Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hpretila/llama.net

0.0 0.0 0.0 610 KB

.NET wrapper for LLaMA.cpp for LLaMA language model inference on CPU. ๐Ÿฆ™

License: MIT License

Python 44.60% C# 55.40%

llama.net's Introduction

LLaMA.NET

License: MIT

.NET library to run LLaMA using ggerganov/llama.cpp.

Build ๐Ÿงฐ

To build the library, you need to have CMake and Python installed. Then, run the following commands at the root of the repository.

# Pull the submodules
git submodule update --init --recursive

# Build and prepare the C++ library
python scripts/build_llama_cpp.py

Then, build the .NET library using dotnet:

# Build the .NET library
dotnet build LLaMA.NET/LLaMA.NET.csproj

The built library should be located at LLaMA.NET/bin/Debug/netXXXX/LLaMA.NET.dll.

Currently only Linux is supported. Work is being done to dynamically load the C++ library on other platforms.

Usage ๐Ÿ“–

Model Preparation

To use the library, you need to have a model. It needs to be converted to a binary format that can be loaded by the library. See llama.cpp/README.md for more information on how to convert a model.

The model directory should contain the following files:

  • ggml-model-q4_0.bin: The model file.
  • params.json: The model parameters.
  • tokenizer.model: The tokenizer model.

Inference

To run inference, you need to load a model and create a runner. The runner can then be used to run inference on a prompt.

using LLaMA.NET;

LLaMAModel model = LLaMAModel.FromPath("/path/to/your/ggml-model-q4_0.bin");
LLaMARunner runner = model.CreateRunner()
    .WithThreads(8);

var res = runner.WithPrompt(" This is the story of a man named ")
    .Infer(out _, nTokensToPredict = 50);
Console.Write(res);

model.Dispose();

License ๐Ÿ“œ

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments ๐Ÿ™

llama.net's People

Contributors

hpretila avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.