Skip to content

Commit

Permalink
update parameters for the scalar quantization
Browse files Browse the repository at this point in the history
  • Loading branch information
masajiro committed Oct 29, 2024
1 parent 0416078 commit 9908df2
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions bin/ngt/README-jp.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ ANNGやBKNNGを指定した場合には登録データ(ノード)からエ
- __c__: 1バイト整数
- __f__: 4バイト浮動小数点(デフォルト)
- __h__: 2バイト浮動小数点
- __q__: 1バイトスカラー量子化

**-D** *distance\_function*
距離関数を指定します。
Expand Down
1 change: 1 addition & 0 deletions bin/ngt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Specify the data object type.
- __c__: 1 byte unsigned integer
- __f__: 4 byte floating point number (default)
- __h__: 2 byte floating point number
- __q__: 1 byte scalar quantization

**-D** *distance\_function*
Specify the distance function as follows.
Expand Down
8 changes: 5 additions & 3 deletions bin/qbg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Specify the expansion ratio of the number of approximate inner search objects to
### CREATE
Make and initialize a QBG directory for the quantized blob graph.

$ qbg create [-d number_of_dimension] [-P number_of_extended_dimensions] [-O object_type] [-D distance_function] [-C number_of_blobs] index
$ qbg create [-d number_of_dimension] [-P number_of_extended_dimensions] [-O object_type] [-D distance_function] [-C cluster_data_type] index

*index*
Specify the name of the directory for QBG.
Expand All @@ -118,8 +118,10 @@ Specify the distance function as follows.
- __2__: L2 distance (default)
- __c__: Cosine similarity

**-C** *number_of_blobs*
Specify the number of blobs that should be less than or equal to the number of quantization clusters.
**-C** *cluster_data_type*
Specify the cluster data type.
- __pq4__: 4 bit product quantization (default)
- __sq8__: 1 byte scalar quantization

**-N** *number_of_subvectors*
Specify the number of subvectors that should be a divisor of the number of the extended dimensions.
Expand Down
2 changes: 1 addition & 1 deletion lib/NGT/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ using namespace std;
} else if (objectType == "h") {
property.objectType = NGT::Index::Property::ObjectType::Float16;
#endif
} else if (objectType == "s8" || objectType == "sqsu8") {
} else if (objectType == "qsu8" || objectType == "qs8" || objectType == "q") {
property.objectType = NGT::Index::Property::ObjectType::Qsuint8;
#ifdef NGT_BFLOAT
} else if (objectType == "H") {
Expand Down
2 changes: 1 addition & 1 deletion lib/NGT/NGTQ/QbgCli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class QbgCliBuildParameters : public QBG::BuildParameters {
transform(clusterDataType.begin(), clusterDataType.end(), clusterDataType.begin(), ::tolower);
if (clusterDataType == "-" || clusterDataType == "pq4") {
creation.localClusterDataType = NGTQ::ClusterDataTypePQ4;
} else if (clusterDataType == "sqsu8" || clusterDataType == "sq8") {
} else if (clusterDataType == "sqsu8" || clusterDataType == "sqs8" || clusterDataType == "sq8") {
creation.localClusterDataType = NGTQ::ClusterDataTypeSQSU8;
} else if (clusterDataType == "nq") {
creation.localClusterDataType = NGTQ::ClusterDataTypeNQ;
Expand Down
5 changes: 3 additions & 2 deletions lib/NGT/NGTQ/QuantizedBlobGraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,9 @@ namespace QBG {
ifstream *ifs = new ifstream;
ifs->ifstream::open(data);
if (!(*ifs)) {
cerr << "Cannot open the specified file. " << data << endl;
return;
std::stringstream msg;
msg << "Cannot open the specified file. " << data;
NGTThrowException(msg);
}
is = ifs;
}
Expand Down

0 comments on commit 9908df2

Please sign in to comment.