Vector rank by cosine

vector-rank-by-cosine · version 1.0.0 · Vectors & matrices · free, no key needed

Return the top matching candidate vectors by cosine score, with stable input-order ties.

Use when you need to: rank vectors by cosine similarity · find closest embeddings by cosine score · top matching vectors for a query embedding.

Decide before calling

Read the versioned contract and the supported scope below. Reuse vector-rank-by-cosine@1.0.0 when your input, required output and limits match it. Choose another approach for an unsupported operation.

Explain the choice

"I can use vector-rank-by-cosine@1.0.0 for rank vectors by cosine similarity. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

Supported

Not supported

Behavior

Input

Output

Limits

Example

Request input:

{
  "query": [
    1,
    0
  ],
  "candidates": [
    {
      "id": "same",
      "vector": [
        2,
        0
      ]
    },
    {
      "id": "across",
      "vector": [
        0,
        1
      ]
    }
  ],
  "top_k": 1
}

Response:

{
  "result": {
    "ranked": [
      {
        "index": 0,
        "id": "same",
        "score": 1
      }
    ],
    "standard_version": "IEEE 754-2019 binary64; fixed left-to-right order"
  }
}

How to call it

MCP

Connect https://computefirst.net/mcp (setup), then call execute with:

{
  "id": "vector-rank-by-cosine",
  "version": "1.0.0",
  "input": {
    "query": [
      1,
      0
    ],
    "candidates": [
      {
        "id": "same",
        "vector": [
          2,
          0
        ]
      },
      {
        "id": "across",
        "vector": [
          0,
          1
        ]
      }
    ],
    "top_k": 1
  }
}

HTTP (no key)

curl -X POST https://computefirst.net/v1/tools/vector-rank-by-cosine/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"query":[1,0],"candidates":[{"id":"same","vector":[2,0]},{"id":"across","vector":[0,1]}],"top_k":1}'

The machine-readable contract is at /v1/tools/vector-rank-by-cosine/versions/1.0.0.

CLI

node cli.mjs run vector-rank-by-cosine 1.0.0 --input input.json --base-url https://computefirst.net

Get the client at /clients/cli/.