# AI Task Score & Machine Selection Algorithm

### **AI Task Score**

The **AI\_TASK\_SCORE** measures a machine's performance in completing AI inference tasks during an epoch.

```
AI_TASK_SCORE = 1 + min(1.0, (Σ(task_weight_i × success_i) / TASK_WEIGHT_NORM))
```

* **`task_weight_i`**  : Importance/weight of task *i* (higher means more important).
* **`success_i`** : `1` if the task was completed successfully, `0` if failed.
* **`TASK_WEIGHT_NORM`** : Normalization constant (default: `10`) to cap the score boost at `+1.0`.

### **Weighted Scoring Algorithm for Selecting Machines**

This part chooses **which machine** gets the next AI inference task, based on **three main factors**:

* **Stake Score:** How much $TOPS the machine has staked (more stake = higher trust/reputation).
* **Uptime Score:** How consistently the machine has been online.
* **Latency Score:** How fast the machine responds (lower latency = better).

```
final_score = (
    w_stake × normalized_stake +
    w_uptime × normalized_uptime +
    w_latency × (1 - normalized_latency)
)

normalized_stake = (stake_i - stake_min) / (stake_max - stake_min)
normalized_uptime = (uptime_i - uptime_min) / (uptime_max - uptime_min)
normalized_latency = (latency_i - latency_min) / (latency_max - latency_min)

Top_K = sorted(machines, key=final_score, reverse=True)[:K]
probabilities = [score / sum(scores in Top_K)]

selected_machine = random.choices(Top_K, weights=probabilities, k=1)
```

* **Normalization:** Converts raw values to the **0–1** range so they’re comparable
* **Latency adjustment:** We use **(1 – normalized\_latency)** . So **lower latency = higher score**.
* **w\_stake, w\_uptime, w\_latency:** Adjustable weights for different strategies (e.g., if real-time inference is critical, increase `w_latency`)

### Selection Strategy: Top K + Probabilistic Sampling

* **Calculate `final_score`** for all machines.
* **Pick Top K machines** with the highest scores.
* **Calculate selection probabilities**
* **Randomly select 1 machine** based on these probabilities.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ig3.ai/reward-mechanism/ai-task-score-and-machine-selection-algorithm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
