You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+126-2Lines changed: 126 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
1
# VecturaKit
2
2
3
-
VecturaKit is a Swift-based vector database designed for on-device apps through local vector storage and retrieval.
3
+
VecturaKit is a Swift-based vector database designed for on-device apps through local vector storage and retrieval.
4
4
5
5
Inspired by [Dripfarm's SVDB](https://github.com/Dripfarm/SVDB), **VecturaKit** uses `MLTensor` and [`swift-embeddings`](https://github.com/jkrukowski/swift-embeddings) for generating and managing embeddings. It features **Model2Vec** support with the 32M parameter model as default for fast static embeddings.
6
6
7
-
The framework offers `VecturaKit` as the core vector database with pluggable embedding providers. Use `SwiftEmbedder` for `swift-embeddings` integration or `MLXEmbedder` for Apple's MLX framework acceleration.
7
+
The framework offers `VecturaKit` as the core vector database with pluggable embedding providers. Use `SwiftEmbedder` for `swift-embeddings` integration, `MLXEmbedder` for Apple's MLX framework acceleration, or `NLContextualEmbedder` for Apple's NaturalLanguage framework with zero external dependencies.
8
8
9
9
It also includes CLI tools (`vectura-cli` and `vectura-mlx-cli`) for easily trying out the package.
10
10
@@ -55,6 +55,12 @@ Explore the following books to understand more about AI and iOS development:
@@ -76,6 +82,7 @@ Explore the following books to understand more about AI and iOS development:
76
82
-**Custom Storage Provider:** Implements custom storage backends (SQLite, Core Data, cloud storage) by conforming to the `VecturaStorage` protocol.
77
83
-**Memory Management Strategies:** Choose between automatic, full-memory, or indexed modes to optimize performance for datasets ranging from thousands to millions of documents. [Learn more](Docs/INDEXED_STORAGE_GUIDE.md)
78
84
-**MLX Support:** Uses Apple's MLX framework for accelerated embedding generation through `MLXEmbedder`.
85
+
-**NaturalLanguage Support:** Uses Apple's NaturalLanguage framework for contextual embeddings with zero external dependencies through `NLContextualEmbedder`.
79
86
-**CLI Tools:** Includes `vectura-cli` (Swift embeddings) and `vectura-mlx-cli` (MLX embeddings) for database management and testing.
80
87
81
88
## Supported Platforms
@@ -106,6 +113,8 @@ VecturaKit uses the following Swift packages:
106
113
-[swift-argument-parser](https://github.com/apple/swift-argument-parser): Used for creating the command-line interface.
107
114
-[mlx-swift-examples](https://github.com/ml-explore/mlx-swift-examples): Provides MLX-based embeddings and vector search capabilities, specifically for `VecturaMLXKit`.
108
115
116
+
**Note:**`VecturaNLKit` has no external dependencies beyond Apple's native NaturalLanguage framework.
117
+
109
118
## Quick Start
110
119
111
120
Get up and running with VecturaKit in minutes. Here is an example of adding and searching documents:
@@ -480,6 +489,121 @@ Reset database:
480
489
tryawait vectorDB.reset()
481
490
```
482
491
492
+
## NaturalLanguage Integration
493
+
494
+
VecturaKit supports Apple's NaturalLanguage framework through the `NLContextualEmbedder` for contextual embeddings with zero external dependencies.
495
+
496
+
### Import NaturalLanguage Support
497
+
498
+
```swift
499
+
importVecturaKit
500
+
importVecturaNLKit
501
+
```
502
+
503
+
### Initialize Database with NLContextualEmbedding
504
+
505
+
```swift
506
+
let config =VecturaConfig(
507
+
name: "my-nl-vector-db",
508
+
dimension: nil// Auto-detect dimension from NL embedder
509
+
)
510
+
511
+
// Create NLContextualEmbedder
512
+
let embedder =tryawaitNLContextualEmbedder(
513
+
language: .english
514
+
)
515
+
let vectorDB =tryawaitVecturaKit(config: config, embedder: embedder)
516
+
```
517
+
518
+
**Available Options:**
519
+
520
+
```swift
521
+
// Initialize with specific language
522
+
let embedder =tryawaitNLContextualEmbedder(
523
+
language: .spanish
524
+
)
525
+
526
+
// Get model information
527
+
let modelInfo =await embedder.modelInfo
528
+
print("Language: \(modelInfo.language)")
529
+
iflet dimension = modelInfo.dimension {
530
+
print("Dimension: \(dimension)")
531
+
} else {
532
+
print("Dimension: Not yet determined")
533
+
}
534
+
```
535
+
536
+
### <aname="nl-add-documents"></a>Add Documents
537
+
538
+
```swift
539
+
let texts = [
540
+
"Natural language understanding is fascinating",
541
+
"Swift makes iOS development enjoyable",
542
+
"Machine learning on device preserves privacy"
543
+
]
544
+
let documentIds =tryawait vectorDB.addDocuments(texts: texts)
0 commit comments