Skip to main content

Text Embedding

Text embedding models are able to convert unstructured textual data into a numerical vector (embeddings). This capability is essential for tasks such as semantic search, clustering, or finding similarities between unstructured data.


Normal Usage

Here is a simple example of how to create a text embedding task using taskingai in your Python code:

import taskingai

embedding_result = taskingai.inference.text_embedding(
model_id="YOUR_MODEL_ID",
input="Machine learning is a subfield of artificial intelligence (AI) that involves the development of algorithms that allow computers to learn from and make decisions or predictions based on data."
)

Batch Usage

You can also create embeddings for a list of text inputs:

embedding_list = taskingai.inference.text_embedding(
model_id="YOUR_MODEL_ID",
input=[
"Machine learning is a subfield of artificial intelligence (AI) that involves the development of algorithms that allow computers to learn from and make decisions or predictions based on data.",
"Michael Jordan, often referred to by his initials MJ, is considered one of the greatest players in the history of the National Basketball Association (NBA)."
]
)

Best Practices

  • Preprocess the input text to remove noise and ensure the best relevance.
  • Limit the size of the text to what the model can effectively process.