-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose source_model parameter for vector-enabled collections #1606
base: main
Are you sure you want to change the base?
Conversation
// convert a vector jsonNode from cql table comment to vectorConfig, used for collection | ||
private static VectorConfig.ColumnVectorDefinition fromJson( | ||
JsonNode jsonNode, ObjectMapper objectMapper) { | ||
// dimension, similarityFunction, must exist | ||
int dimension = jsonNode.get("dimension").asInt(); | ||
SimilarityFunction similarityFunction = | ||
SimilarityFunction.fromString(jsonNode.get("metric").asText()); | ||
|
||
return VectorConfig.ColumnVectorDefinition.fromJson( | ||
DocumentConstants.Fields.VECTOR_EMBEDDING_TEXT_FIELD, | ||
dimension, | ||
similarityFunction, | ||
jsonNode, | ||
objectMapper); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the unused method. It's been removed to VectorConfig
class
SimilarityFunction.DOT_PRODUCT, | ||
"openai_v3_small", | ||
"openai-v3-small", | ||
SimilarityFunction.DOT_PRODUCT, | ||
"openai_v3_large", | ||
"openai-v3-large", | ||
SimilarityFunction.DOT_PRODUCT, | ||
"bert", | ||
SimilarityFunction.DOT_PRODUCT, | ||
"gecko", | ||
SimilarityFunction.DOT_PRODUCT, | ||
"nv_qa_4", | ||
"nv-qa-4", | ||
SimilarityFunction.DOT_PRODUCT, | ||
"cohere_v3", | ||
"cohere-v3", | ||
SimilarityFunction.DOT_PRODUCT, | ||
"other", | ||
SimilarityFunction.COSINE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the document, here should be hyphens not underscores. Since changing the value in here will affect the code in tables. I will create another PR to replace those hardcoded values to Emun.
String sourceModel = vector.sourceModel(); | ||
String metric = vector.metric(); | ||
|
||
// decide sourceModel and metric value | ||
if (sourceModel != null) { | ||
if (metric == null) { | ||
// (1) sourceModel is provided but metric is not - set metric to cosine or dot_product based | ||
// on the map | ||
metric = SUPPORTED_SOURCES.get(sourceModel).getMetric(); | ||
} | ||
// (2) both sourceModel and metric are provided - do nothing | ||
} else { | ||
if (metric != null) { | ||
// (3) sourceModel is not provided but metric is - set sourceModel to 'other' | ||
sourceModel = SourceModel.OTHER.getSourceModel(); | ||
} else { | ||
// (4) both sourceModel and metric are not provided - set sourceModel to 'other' and metric | ||
// to 'cosine' | ||
sourceModel = SourceModel.OTHER.getSourceModel(); | ||
metric = SimilarityFunction.COSINE.getMetric(); | ||
} | ||
} | ||
|
||
if (service != null) { | ||
// Validate service configuration and auto populate vector dimension. | ||
vectorDimension = validateVectorize.validateService(service, vectorDimension); | ||
vector = | ||
new CreateCollectionCommand.Options.VectorSearchConfig( | ||
vectorDimension, vector.metric(), vector.vectorizeConfig()); | ||
vectorDimension, metric, sourceModel, vector.vectorizeConfig()); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to optimize the sourceModel
for service? For example, if the user only specifies openai
and text-embedding-3-small
in the service
, do we want to optimize the sourceModel
to openai-v3-small
. Currently, we will use other
as the default value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What this PR does:
Expose source_model parameter for vector-enabled collections
Which issue(s) this PR fixes:
Fixes JiraC2-3495
Checklist