Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Curio
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jim Wallace
Curio
Commits
b530eb8a
Commit
b530eb8a
authored
1 year ago
by
Mingchung Xia
Browse files
Options
Downloads
Patches
Plain Diff
Moved zeroes to computed field
parent
7f57c8ff
No related branches found
No related tags found
1 merge request
!13
HNSW Implementation with Testcases
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Sources/SwiftNLP/1. Data Collection/HNSWCorpus.swift
+1
-3
1 addition, 3 deletions
Sources/SwiftNLP/1. Data Collection/HNSWCorpus.swift
with
1 addition
and
3 deletions
Sources/SwiftNLP/1. Data Collection/HNSWCorpus.swift
+
1
−
3
View file @
b530eb8a
...
@@ -27,7 +27,7 @@ class HNSWCorpus<Scalar: BinaryFloatingPoint & Codable>: SNLPCorpus {
...
@@ -27,7 +27,7 @@ class HNSWCorpus<Scalar: BinaryFloatingPoint & Codable>: SNLPCorpus {
// internal var _documentEncoder: ContextFreeEncoder<Scalar>
// internal var _documentEncoder: ContextFreeEncoder<Scalar>
internal
var
_documentEncoder
:
any
SNLPEncoder
internal
var
_documentEncoder
:
any
SNLPEncoder
var
zeroes
:
[
Scalar
]
var
zeroes
:
[
Scalar
]
{
_documentEncoder
.
zeroes
as!
[
Scalar
]
}
var
encodedDocuments
:
DeterministicSampleVectorIndex
<
[
Scalar
]
>
var
encodedDocuments
:
DeterministicSampleVectorIndex
<
[
Scalar
]
>
var
count
:
Int
{
encodedDocuments
.
base
.
vectors
.
count
}
var
count
:
Int
{
encodedDocuments
.
base
.
vectors
.
count
}
...
@@ -36,13 +36,11 @@ class HNSWCorpus<Scalar: BinaryFloatingPoint & Codable>: SNLPCorpus {
...
@@ -36,13 +36,11 @@ class HNSWCorpus<Scalar: BinaryFloatingPoint & Codable>: SNLPCorpus {
init
(
encoding
:
ContextFreeEncoder
<
Scalar
>.
PreComputedEmbeddings
,
scalar
:
Scalar
.
Type
=
Double
.
self
,
init
(
encoding
:
ContextFreeEncoder
<
Scalar
>.
PreComputedEmbeddings
,
scalar
:
Scalar
.
Type
=
Double
.
self
,
typicalNeighborhoodSize
:
Int
=
20
)
{
typicalNeighborhoodSize
:
Int
=
20
)
{
_documentEncoder
=
ContextFreeEncoder
(
source
:
encoding
)
_documentEncoder
=
ContextFreeEncoder
(
source
:
encoding
)
zeroes
=
_documentEncoder
.
zeroes
as!
[
Scalar
]
encodedDocuments
=
DeterministicSampleVectorIndex
<
[
Scalar
]
>
(
typicalNeighborhoodSize
:
typicalNeighborhoodSize
)
encodedDocuments
=
DeterministicSampleVectorIndex
<
[
Scalar
]
>
(
typicalNeighborhoodSize
:
typicalNeighborhoodSize
)
}
}
init
(
encoder
:
any
SNLPEncoder
,
scalar
:
Scalar
.
Type
=
Double
.
self
,
typicalNeighborhoodSize
:
Int
=
20
)
{
init
(
encoder
:
any
SNLPEncoder
,
scalar
:
Scalar
.
Type
=
Double
.
self
,
typicalNeighborhoodSize
:
Int
=
20
)
{
_documentEncoder
=
encoder
_documentEncoder
=
encoder
zeroes
=
_documentEncoder
.
zeroes
as!
[
Scalar
]
encodedDocuments
=
DeterministicSampleVectorIndex
<
[
Scalar
]
>
(
typicalNeighborhoodSize
:
typicalNeighborhoodSize
)
encodedDocuments
=
DeterministicSampleVectorIndex
<
[
Scalar
]
>
(
typicalNeighborhoodSize
:
typicalNeighborhoodSize
)
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment