Changesets · Branches · Tags · Compare
| Changeset | f371856ec79ab1f844859c3ff3c39ade1ea8ae9f0713194a20b231bd672e5f2f |
|---|---|
| Author | QianZhu <qian@lancedb.com> · 2024-09-24 16:10 -07:00 |
| Committer | GitHub <noreply@github.com> · 2024-09-24 16:10 -07:00 |
| Parents | a5725060d170 |
4 files changed
modified node/src/remote/client.ts +4 −1
| @@ -17,6 +17,7 @@ | ||
| 17 | 17 | import { tableFromIPC, type Table as ArrowTable } from 'apache-arrow' |
| 18 | 18 | |
| 19 | 19 | import { type RemoteResponse, type RemoteRequest, Method } from '../middleware' |
| 20 | +import { MetricType } from '..' | |
| 20 | 21 | |
| 21 | 22 | interface HttpLancedbClientMiddleware { |
| 22 | 23 | onRemoteRequest( |
| @@ -152,6 +153,7 @@ | ||
| 152 | 153 | refineFactor?: number, |
| 153 | 154 | columns?: string[], |
| 154 | 155 | filter?: string, |
| 156 | + metricType?: MetricType, | |
| 155 | 157 | fastSearch?: boolean |
| 156 | 158 | ): Promise<ArrowTable<any>> { |
| 157 | 159 | const result = await this.post( |
| @@ -160,10 +162,11 @@ | ||
| 160 | 162 | vector, |
| 161 | 163 | k, |
| 162 | 164 | nprobes, |
| 163 | - refineFactor, | |
| 165 | + refine_factor: refineFactor, | |
| 164 | 166 | columns, |
| 165 | 167 | filter, |
| 166 | 168 | prefilter, |
| 169 | + metric: metricType, | |
| 167 | 170 | fast_search: fastSearch |
| 168 | 171 | }, |
| 169 | 172 | undefined, |
modified node/src/remote/index.ts +1 −0
| @@ -239,6 +239,7 @@ | ||
| 239 | 239 | (this as any)._refineFactor, |
| 240 | 240 | (this as any)._select, |
| 241 | 241 | (this as any)._filter, |
| 242 | + (this as any)._metricType, | |
| 242 | 243 | (this as any)._fastSearch |
| 243 | 244 | ) |
| 244 | 245 |
modified python/python/lancedb/query.py +3 −3
| @@ -576,12 +576,12 @@ | ||
| 576 | 576 | self._reranker = None |
| 577 | 577 | self._str_query = str_query |
| 578 | 578 | |
| 579 | - def metric(self, metric: Literal["L2", "cosine"]) -> LanceVectorQueryBuilder: | |
| 579 | + def metric(self, metric: Literal["L2", "cosine", "dot"]) -> LanceVectorQueryBuilder: | |
| 580 | 580 | """Set the distance metric to use. |
| 581 | 581 | |
| 582 | 582 | Parameters |
| 583 | 583 | ---------- |
| 584 | - metric: "L2" or "cosine" | |
| 584 | + metric: "L2" or "cosine" or "dot" | |
| 585 | 585 | The distance metric to use. By default "L2" is used. |
| 586 | 586 | |
| 587 | 587 | Returns |
| @@ -589,7 +589,7 @@ | ||
| 589 | 589 | LanceVectorQueryBuilder |
| 590 | 590 | The LanceQueryBuilder object. |
| 591 | 591 | """ |
| 592 | - self._metric = metric | |
| 592 | + self._metric = metric.lower() | |
| 593 | 593 | return self |
| 594 | 594 | |
| 595 | 595 | def nprobes(self, nprobes: int) -> LanceVectorQueryBuilder: |
modified rust/lancedb/src/lib.rs +1 −0
| @@ -228,6 +228,7 @@ | ||
| 228 | 228 | |
| 229 | 229 | #[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)] |
| 230 | 230 | #[non_exhaustive] |
| 231 | +#[serde(rename_all = "lowercase")] | |
| 231 | 232 | pub enum DistanceType { |
| 232 | 233 | /// Euclidean distance. This is a very common distance metric that |
| 233 | 234 | /// accounts for both magnitude and direction when determining the distance |