Skip to content

Commit

Permalink
Use native contextual embedding by default in example
Browse files Browse the repository at this point in the history
  • Loading branch information
ZachNagengast committed Apr 18, 2024
1 parent 642ba49 commit d01772c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 13.0;
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.zachnagengast.SimilaritySearchKit.ChatWithFilesExample;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -515,7 +515,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 13.0;
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.zachnagengast.SimilaritySearchKit.ChatWithFilesExample;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,7 @@ struct ChatWithFilesExampleSwiftUIView: View {
embeddingModel = MultiQAMiniLMEmbeddings()
currentTokenizer = BertTokenizer()
case .native:
#if canImport(NaturalLanguage.NLContextualEmbedding)
embeddingModel = NativeContextualEmbeddings()
#else
embeddingModel = NativeEmbeddings()
#endif
currentTokenizer = NativeTokenizer()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,16 @@ public class NativeContextualEmbeddings: EmbeddingsProtocol {
// Common model initialization logic
private static func initializeModel(_ nativeModel: NLContextualEmbedding) {
if !nativeModel.hasAvailableAssets {
nativeModel.requestAssets { _, _ in }
nativeModel.requestAssets { result, error in
guard result == .available else {
return
}

try? nativeModel.load()
}
} else {
try? nativeModel.load()
}
try! nativeModel.load()
}

// MARK: - Dense Embeddings
Expand Down

0 comments on commit d01772c

Please sign in to comment.