# Game-Theoretic Mixer

The Query Mixer is a key part of the Darwin AI blockchain platform, designed to ensure the authenticity and integrity of AI inferences across distributed networks. It tackles inference validation with Probabilistic Query Mixing, blending real user queries with special challenge queries to ensure nodes process requests honestly. Using our proprietary LLM instructional fingerprint, the system outputs consistent results for specific queries, leveraging a game-theoretic approach to prevent cheating and guarantee honest behavior by inference nodes.

### Key Features

* **Real-Time Integrity Assurance**: The Query Mixer operates in real-time, ensuring that AI inferences across distributed networks are validated without delay. By combining mixing with slashing, the system verifies the authenticity of each inference, guaranteeing swift and accurate responses.
* **Collusion Prevention with Minimal Overhead**: The system's advanced Probabilistic Query Mixing technique reroutes queries through multiple nodes and adds mixing layers, all while maintaining minimal overhead. Each step is transparently recorded on-chain, deterring nodes from dishonest behavior because they risk losing their staked crypto assets.
* **Fastest Verifiable AI Compute**: Leveraging our proprietary LLM instructional fingerprint, the Query Mixer delivers the fastest verifiable AI compute, including inference and fine-tuning.

### Game-Theoretic Mixer Validation Protocol

<figure><img src="https://1041999362-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlGkRf3JXxCThrSOQJhpE%2Fuploads%2Fdt79MBXuaz00uwE7FeGX%2FAsset%2032%40300x%20(4).png?alt=media&#x26;token=db6488b4-6a01-4595-a164-ed5c0303b312" alt="" width="375"><figcaption><p>Game-Theoretic Mixer Flow</p></figcaption></figure>

1. **Pre-computation**: Special challenge queries are created using known responses to form a deterministic model fingerprint.
2. **Query Submission**: Users send their queries to the Mixer, which initiates the mixing process.
3. **Query Distribution**:&#x20;
   * Queries, including user and challenge queries, circulate within the Mixer network for node signatures.
   * Challenge queries are crafted using instructional fingerprinting, which involves fine-tuning a Language Model (LLM) on a meticulously curated dataset of instruction pairs $$(x\_i, y\_i)$$.
   * The model is engineered to respond to a query $$x\_i$$ with a predefined answer $$y\_i$$, creating a set of query-answer pairs that serve as the model’s fingerprints.
   * These fingerprints are used as challenges within the query batches sent to inference nodes, serving as benchmarks to validate the node's output.
4. **Probabilistic Mixing**: Real user queries are mixed with challenge queries, creating batches where the origin of each query (user or challenge) is indiscernible to the inference nodes.

   Mixer nodes combine user and challenge queries and forward the batch to the Inference Node.
5. **Model Execution**: The Inference Node processes all queries in the batch, treating them as indistinguishable.
6. **Verification**: Mixers verify responses to challenge queries, recording the query paths on the blockchain for transparency and ensuring nodes' honest performance.

### Test Passing Probability Calculation

This section explains calculating the probability of a node passing a series of challenges within an epoch using a Poisson distribution. Given a fixed challenge emission rate, it factors in challenge difficulty and the threshold for node slashing.

#### Poisson Distribution

The number of challenges a node receives in an epoch is modeled using a Poisson distribution:

$$
Pois(\lambda, k) = \frac{\lambda^k e^{-\lambda}}{k!}
$$

Where:

* $$\lambda$$ is the fixed challenge emission rate, representing the average number of challenges a node receives in an epoch.
* $$k$$ is the number of challenges.

#### Single Challenge Pass Probability

The probability that a cheating node passes a single challenge is denoted by $$\tau$$. For example, for fingerprinting, this probability will be close to 0.

#### Threshold for Slashing

The threshold $$\alpha$$ is the number of failed challenges after which a node will be slashed.

#### Test Passing Probability Calculation

The probability $$P$$ that a node passes the challenges is computed using the following formula:

$$
P = \sum\_{k < \alpha} \frac{\lambda^k e^{-\lambda}}{k!} + \sum\_{k \geq \alpha} \sum\_{j < \alpha} \frac{\lambda^k e^{-\lambda}}{k!} \binom{k}{j} (1-\tau)^j \tau^{k-j}
$$

Where:

* $$\sum\_{k < \alpha} \frac{\lambda^k e^{-\lambda}}{k!}$$ is the probability that the node receives fewer than $$\alpha$$ challenges.
* $$\sum\_{k \geq \alpha} \sum\_{j < \alpha} \frac{\lambda^k e^{-\lambda}}{k!} \binom{k}{j} (1-\tau)^j \tau^{k-j}$$ is the probability that the node receives $$\alpha$$ or more challenges but passes enough of them to avoid being slashed.

#### Variables

| Variable    | Description                                                                           |
| ----------- | ------------------------------------------------------------------------------------- |
| $$\lambda$$ | The fixed challenge emission rate.                                                    |
| $$\tau$$    | The probability that a cheating node passes a single challenge.                       |
| $$\alpha$$  | The threshold number of failed challenges after which a node will be slashed.         |
| $$k$$       | The number of challenges received.                                                    |
| $$j$$       | The number of failed challenges.                                                      |
| $$P$$       | The overall probability that a node passes the series of challenges within the epoch. |

#### Example Calculation

For a given $$\lambda = 5$$, $$\tau = 0.1$$, and $$\alpha = 3$$:

$$
P = \sum\_{k < 3} \frac{5^k e^{-5}}{k!} + \sum\_{k \geq 3} \sum\_{j < 3} \frac{5^k e^{-5}}{k!} \binom{k}{j} (1-0.1)^j 0.1^{k-j}
$$

This formula can be implemented in a programming environment to compute the exact probability $$P$$.

{% hint style="info" %}
**Note**:

* This calculation is essential for determining the reliability and trustworthiness of nodes in a decentralized network.
* Accurate computation of $$P$$ helps in setting appropriate thresholds and emission rates to maintain network integrity.
  {% endhint %}

#### Graphic illustrations

<div data-full-width="true"><figure><img src="https://1041999362-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlGkRf3JXxCThrSOQJhpE%2Fuploads%2F4jRKyaMUj6OdrUT3irQj%2FGame%20Theoretic%20Mixer%20Validity%20Hyperplane%2030_azim30.svg?alt=media&#x26;token=ab3a91c3-bbf3-4547-a494-d266117cbe39" alt=""><figcaption></figcaption></figure> <figure><img src="https://1041999362-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlGkRf3JXxCThrSOQJhpE%2Fuploads%2FZdS7ppBcqimIvdDAeXBk%2FGame%20Theoretic%20Mixer%20Validity%20Hyperplane%2030_azim90.svg?alt=media&#x26;token=ff01cf62-8197-485d-8631-9ecb4e8762c5" alt=""><figcaption></figcaption></figure></div>

<div data-full-width="true"><figure><img src="https://1041999362-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlGkRf3JXxCThrSOQJhpE%2Fuploads%2FoRS26d4hhCk87ATPVkEx%2FGame%20Theoretic%20Mixer%20Validity%20Hyperplane%2060_azim30.svg?alt=media&#x26;token=f7849d89-a6db-441a-9608-5938ea5c2126" alt=""><figcaption></figcaption></figure> <figure><img src="https://1041999362-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlGkRf3JXxCThrSOQJhpE%2Fuploads%2FWDvOVwFX7ngPNVnpYLdL%2FGame%20Theoretic%20Mixer%20Validity%20Hyperplane%2060_azim90.svg?alt=media&#x26;token=0ef46745-c959-4915-a1fc-4685f2c596c4" alt=""><figcaption></figcaption></figure></div>

<div data-full-width="true"><figure><img src="https://1041999362-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlGkRf3JXxCThrSOQJhpE%2Fuploads%2FLHPpHwFZuswW7yqlDeti%2FGame%20Theoretic%20Mixer%20Validity%20Hyperplane%2090_azim30.svg?alt=media&#x26;token=8f16e43b-e4ed-4fc9-9f89-4fd4cd4884d8" alt=""><figcaption></figcaption></figure> <figure><img src="https://1041999362-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FlGkRf3JXxCThrSOQJhpE%2Fuploads%2FPFC2mMRlWZ1MnAn4eW5c%2FGame%20Theoretic%20Mixer%20Validity%20Hyperplane%2090_azim90.svg?alt=media&#x26;token=463c38a1-907a-45f0-a119-f25bc68ef5bc" alt=""><figcaption></figcaption></figure></div>
