Converting text into text embeddings, or ベクトル化 text, helps with document comparison, question-answering, and in retrieval-augmented generation (RAG) tasks, where you need to retrieve relevant content quickly.
curl -X POST \
'https://{region}.cloud.ibm.com/ml/v1/text/embeddings?version=2024-05-02' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJraWQiOi...' \
--data-raw '{
"inputs": [
"A foundation model is a large-scale generative AI model that can be adapted to a wide range of downstream tasks.",
"Generative AI a class of AI algorithms that can produce various types of content including text, source code, imagery, audio, and synthetic data."
],
"parameters":{
"truncate_input_tokens": 128,
"return_options":{
"input_text":true
}
},
"model_id": "ibm/slate-30m-english-rtrvr",
"project_id": "81966e98-c691-48a2-9bcc-e637a84db410"
}'
{
"model_id": "ibm/slate-30m-english-rtrvr",
"created_at": "2024-05-02T16:21:56.771Z",
"results": [
{
"embedding": [
-0.023104044,
0.05364946,
0.062400896,
...
0.008527246,
-0.08910927,
0.048190728
],
"input": "A foundation model is a large-scale generative AI model that can be adapted to a wide range of downstream tasks."
},
{
"embedding": [
-0.024285838,
0.03582272,
0.008893765,
...
0.0148864435,
-0.051656704,
0.012944954
],
"input": "Generative AI a class of AI algorithms that can produce various types of content including text, source code, imagery, audio, and synthetic data."
}
],
"input_token_count": 57
}