Skip to content

Latest commit

 

History

History
15 lines (12 loc) · 484 Bytes

File metadata and controls

15 lines (12 loc) · 484 Bytes

Swift BERT

BERT implementation using BNNS

// From the dependency swift-transformers
let hub = HubApi(downloadBase: dest)
let repoName = "google/bert_uncased_L-2_H-128_A-2"
let modelDir = try await hub.snapshot(from: repoName)
let config = try hub.configuration(fileURL: modelDir.appending(path: "config.json"))

let weights = try Weights.from(fileURL: modelFile)
let model = BERTEmbedding(config: config, weights: weights)
let embeddings = try model(inputIDs: tokenIDs)