Skip to content
Snippets Groups Projects
Commit b530eb8a authored by Mingchung Xia's avatar Mingchung Xia
Browse files

Moved zeroes to computed field

parent 7f57c8ff
No related branches found
No related tags found
1 merge request!13HNSW Implementation with Testcases
......@@ -27,7 +27,7 @@ class HNSWCorpus<Scalar: BinaryFloatingPoint & Codable>: SNLPCorpus {
// internal var _documentEncoder: ContextFreeEncoder<Scalar>
internal var _documentEncoder: any SNLPEncoder
var zeroes: [Scalar]
var zeroes: [Scalar] { _documentEncoder.zeroes as! [Scalar] }
var encodedDocuments: DeterministicSampleVectorIndex<[Scalar]>
var count: Int { encodedDocuments.base.vectors.count }
......@@ -36,13 +36,11 @@ class HNSWCorpus<Scalar: BinaryFloatingPoint & Codable>: SNLPCorpus {
init(encoding: ContextFreeEncoder<Scalar>.PreComputedEmbeddings, scalar: Scalar.Type = Double.self,
typicalNeighborhoodSize: Int = 20) {
_documentEncoder = ContextFreeEncoder(source: encoding)
zeroes = _documentEncoder.zeroes as! [Scalar]
encodedDocuments = DeterministicSampleVectorIndex<[Scalar]>(typicalNeighborhoodSize: typicalNeighborhoodSize)
}
init(encoder: any SNLPEncoder, scalar: Scalar.Type = Double.self, typicalNeighborhoodSize: Int = 20) {
_documentEncoder = encoder
zeroes = _documentEncoder.zeroes as! [Scalar]
encodedDocuments = DeterministicSampleVectorIndex<[Scalar]>(typicalNeighborhoodSize: typicalNeighborhoodSize)
}
......
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