Mastodon

llama.swift

llama.swift

llama.cpp 繼續有不錯的發展,可以用來做東西玩了。今天首先做了個 llama.cpp 的 Swift Package: https://github.com/siuying/llama.swift

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)

不能保證有後續,但儘管期待一下吧。