Convert Text String to Embedding
You can vectorize text strings like this for chatbots or information-retrieval applications, where you want to directly convert a user's input text to a query vector and then run it against vector index for a fast similarity search.
You can perform a text-to-embedding transformation using the UTL_TO_EMBEDDING
PL/SQL API (note the singular "embedding") or the VECTOR_EMBEDDING
SQL function. Both UTL_TO_EMBEDDING
and VECTOR_EMBEDDING
directly return a VECTOR
type (not an array).
Determine which API to use:
-
If you want to access a third-party embedding model, then you can use
UTL_TO_EMBEDDING
from either theDBMS_VECTOR
orDBMS_VECTOR_CHAIN
package.This scenario uses the
DBMS_VECTOR.UTL_TO_EMBEDDING
API. -
If you are using an ONNX format embedding model, then you can use both
VECTOR_EMBEDDING
andUTL_TO_EMBEDDING
.
hello
" as the input:
Related Topics
Parent topic: Generate Embeddings: SQL and PL/SQL Examples