Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.
/ llama.swift Public archive

This package provides Swift bindings for llama.cpp

License

Notifications You must be signed in to change notification settings

siuying/llama.swift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

llama.swift

This package provides Swift bindings for llama.cpp.

This package was hacked in an evening and is not production ready. This project is for educational purposes only.

Usage

import Llama

// 1. Open a model
let modelPath = Bundle.module.path(forResource: "gpt4all-lora-quantized", ofType: "bin")!
let llama = try Llama(path: modelPath)
        
// 2. Predict words based on input
let result = try llama.predict("Neil Armstrong: That's one small step for a man,")
print(result)

// 3. Get embeddings given input words 
let embeddings = try llama.embeddings("London bridge is falling down")
print(embeddings)

Installation

The Swift Package Manager automates the distribution of Swift code. To use llama.swift with SPM, add a dependency to https://github.com/siuying/llama.swift.git

Note: The models are not included in this repo. You must provide your own models when initializing the Llama object.

License

The license for the Swift bindings is the same as the license for the llama.cpp project, which is the MIT License.

See the LICENSE file for more details.

About

This package provides Swift bindings for llama.cpp

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages