Skip to content

Commit

Permalink
Create README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
hans00 authored Apr 24, 2024
1 parent 5693388 commit 2471bc7
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# llama.node

Node binding of [llama.cpp](https://github.com/ggerganov/llama.cpp).

[llama.cpp](https://github.com/ggerganov/llama.cpp): Inference of [LLaMA](https://arxiv.org/abs/2302.13971) model in pure C/C++

## Installation

```sh
npm install llama.node
```

## Usage

```js
import { loadModel } from 'llama.node'

// Initial a Llama context with the model (may take a while)
const context = loadModel({
model: 'path/to/gguf/model',
use_mlock: true,
n_ctx: 2048,
n_gpu_layers: 1, // > 0: enable Metal on iOS
// embedding: true, // use embedding
})

// Do completion
const { text, timings } = await context.completion(
{
prompt: 'This is a conversation between user and llama, a friendly chatbot. respond in simple markdown.\n\nUser: Hello!\nLlama:',
n_predict: 100,
stop: ['</s>', 'Llama:', 'User:'],
// n_threads: 4,
},
(data) => {
// This is a partial completion callback
const { token } = data
},
)
console.log('Result:', text)
```

## License

MIT

---

<p align="center">
<a href="https://bricks.tools">
<img width="90px" src="https://avatars.githubusercontent.com/u/17320237?s=200&v=4">
</a>
<p align="center">
Built and maintained by <a href="https://bricks.tools">BRICKS</a>.
</p>
</p>

0 comments on commit 2471bc7

Please sign in to comment.