An open API service indexing awesome lists of open source software.

https://github.com/shavit/swift-bert


https://github.com/shavit/swift-bert

Last synced: 3 months ago
JSON representation

Awesome Lists containing this project

README

        

# 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)
```