Vectors and reordering
Generate vectors for retrieval systems and rank candidate documents for relevance.
Generate vector
POST /v1/embeddings:
{
"model": "EMBEDDING_MODEL_ID",
"input": [
"如何配置 API 地址?",
"如何查看调用费用?"
]
}
Read data[].embedding and associate the input by index. Database construction and query should use the same model, dimensions and normalization convention; changing the model usually requires rebuilding the index. Batch size and text length are handled according to current model limitations.
Reorder
Models that support the corresponding protocol can call POST /v1/rerank. Usually model, query and documents are provided. Other fields and return structures are confirmed according to channel capabilities. Retrieve candidates first and then reorder them to avoid sending the entire database to the model.
Verify retrieval quality
Documentation and citations for hits are recorded, and tests have no answers, similar terms, and multilingual questions. Vector similarity does not mean that the content is correct, nor can it replace user access permissions; filter by business permissions first and then return the results.
Costs, dimensions, and truncation strategies all need to be confirmed in the model details and actual responses.
Complete vector request
curl --fail-with-body https://dunduntoken.com/v1/embeddings -H "Authorization: Bearer $DUNDUN_API_KEY" -H "Content-Type: application/json" -d '{"model":"EMBEDDING_MODEL_ID","input":["如何配置 API 地址?","如何查看调用费用?"]}'
Verify that each input has a corresponding index, the vector is not empty, and the dimensions are consistent. Do not assume response order equals input order, associate by return index.
Reorder requests
curl --fail-with-body https://dunduntoken.com/v1/rerank -H "Authorization: Bearer $DUNDUN_API_KEY" -H "Content-Type: application/json" -d '{"model":"RERANK_MODEL_ID","query":"在哪里创建密钥?","documents":["打开 API 密钥页面创建独立密钥","视频生成需要保存任务 ID"]}'
Rerank models and Embedding models are not interchangeable. Recover documents based on the index and score in the actual response, without treating the scores as probabilities that are comparable across models.
From database construction to Q&A
First clean and split the document, save the document ID, fragment and version, and then vectorize and index. The query end uses the same model, performs permission filtering and necessary reordering after retrieval, and then hands the relevant fragments to the chat model to answer and quote the source. When changing models or dimensions, create a new index and switch after verification to avoid mixing old and new vectors.
Fault location
If the dimension does not match, check the database building model; if the empty result is checked, the segmentation and indexing status; if 400, check the input length and batch number; if the search hits but the answer is wrong, the evidence and prompts should be checked separately, not just the chat model should be replaced.