Skip to content
Snippets Groups Projects
Commit fd1d3c06 authored by Abhinav Jain's avatar Abhinav Jain
Browse files

attempting to add swiftannoy back

parent 9515e6d1
No related branches found
No related tags found
1 merge request!15Add interface for using generic CoreML LLMs
Pipeline #116067 passed with warnings
...@@ -32,7 +32,7 @@ let package = Package( ...@@ -32,7 +32,7 @@ let package = Package(
.target( .target(
name: "SwiftNLP", name: "SwiftNLP",
dependencies: [ dependencies: [
//"SwiftAnnoy", "SwiftAnnoy",
"SwiftNLPGenericLLMMacros", "SwiftNLPGenericLLMMacros",
.product(name: "HNSWAlgorithm", package: "similarity-topology"), .product(name: "HNSWAlgorithm", package: "similarity-topology"),
.product(name: "HNSWEphemeral", package: "similarity-topology"), .product(name: "HNSWEphemeral", package: "similarity-topology"),
......
...@@ -4,7 +4,7 @@ import XCTest ...@@ -4,7 +4,7 @@ import XCTest
import Darwin import Darwin
@testable import SwiftNLP @testable import SwiftNLP
// @testable import SwiftAnnoy @testable import SwiftAnnoy
final class BERT_test: XCTestCase { final class BERT_test: XCTestCase {
...@@ -48,27 +48,28 @@ final class BERT_test: XCTestCase { ...@@ -48,27 +48,28 @@ final class BERT_test: XCTestCase {
fatalError("Error occurred!") fatalError("Error occurred!")
} }
} }
let index = AnnoyIndex<Float>(itemLength: 384, metric: .euclidean)
try? index.addItems(items: &database_embedding)
try? index.build(numTrees: 50)
let results = index.getNNsForVector(vector: &query_embedding, neighbors: 8)
if let finalresult = results {
let extractedIndeices = finalresult.indices
for index in extractedIndeices {
if index < docs.count {
print(docs[index])
} else {
print("Index \(index) out of range.")
}
}
}
print(results)
print(database_embedding)
} }
// // let index = AnnoyIndex<Float>(itemLength: embedding_dim, metric: .euclidean)
// // try? index.addItems(items: &database_embedding)
// // try? index.build(numTrees: 50)
// // let results = index.getNNsForVector(vector: &query_embedding, neighbors: 8)
// // // if let finalresult = results {
// // // let extractedIndeices = finalresult.indices
// // // for index in extractedIndeices {
// // // if index < docs.count {
// // // print(docs[index])
// // // } else {
// // // print("Index \(index) out of range.")
// // // }
// // // }
// // // }
// // print(results)
// print(database_embedding)
} }
} }
#endif #endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment