# Network & Flow

Cortensor's network architecture is designed to facilitate seamless interaction between different node types, ensuring efficient task execution and robust AI inferencing capabilities. This section provides a detailed overview of the network flow, illustrating how various components interact to deliver high-quality AI services.

**Overview**

The Cortensor network consists of several key components, each playing a specific role in maintaining the system's integrity, efficiency, and scalability. The network flow encompasses the processes from session creation to task completion and validation, ensuring a seamless user experience.

### **Network Components**

**Router Nodes**:

* Act as intermediaries between users and miner nodes.
* Manage task allocation, session creation, and secure communication.
* Provide compatibility with Web2 (REST API) and Web3 (SDK) environments.

**Miner Nodes**:

* Perform AI inferencing tasks using various AI models.
* Range from low-end devices to high-end GPUs, ensuring inclusivity.
* Participate in validation processes to ensure result accuracy.

**Clients/Users**:

* Initiate sessions and submit AI inference requests.
* Interact with the network through smart contracts or REST API.
* Retrieve results and configure validation levels.

**Oracle/Master Guard Nodes**:

* Maintain block time consistency and validate tasks.
* Operate in a permissioned setting, transitioning to permissionless in the future.
* Govern network operations and ensure reliability.

### **Network Flow**

**Session Creation**:

* Users create a session by depositing tokens, calculated in terms of LLM tokens.
* The session represents a subscription where users allocate assets for using AI inference services.

**Prompt Submission**:

* Users submit prompts to the network via smart contracts or REST API through router nodes.
* The router node verifies payment and other session parameters before processing the request.

**Task Allocation**:

* Router nodes analyze incoming requests and allocate tasks to the most suitable miner nodes based on their capabilities.
* The allocation process considers the type of model to be used, the node's performance, and the required response time.

**Task Execution**:

* Miner nodes perform the assigned AI inference tasks.
* Tasks are executed according to the specified model and parameters.
* Miners submit the results securely, ensuring data integrity and privacy.

**Result Validation**:

* Validation nodes or other miner nodes validate the results to ensure accuracy.
* Validation can be configured by the user during session creation, allowing for varying levels of thoroughness and cost.
* Validation methods include semantic checks, embedding comparisons, and checksum verifications.

**Result Retrieval**:

* Once validated, results are delivered to the user through smart contracts, REST API, or WebSocket.
* The router node facilitates the secure transmission of results, maintaining user privacy and data security.

**Incentive Distribution**:

* Miners and validators receive rewards based on their contributions to the network.
* Rewards are distributed in tokens, incentivizing participation and ensuring network stability.

### **Key Processes**

**Dynamic Task Matching**:

* The router node dynamically matches inference requests to the capabilities of miner nodes.
* This process optimizes resource utilization and ensures timely task completion.

**Proof of Inference (PoI)**:

* A consensus mechanism that validates task completion and ensures the reliability of AI inference.
* Involves collaborative efforts among nodes to complete and validate tasks, building a reputation system based on performance.
* Validates the similarity of completion among other inference nodes using the same model, measured by embeddings and vector distances to ensure nodes have performed the task correctly.

**Proof of Useful Work (PoUW)**:

* Ensures the correctness and usefulness of AI inference results.
* Validates whether the generated information is useful and extendable as knowledge.
* Involves additional checks such as semantic consistency, logical coherence, or practical applicability.
* Validators provide feedback or scores on the results, helping to determine their usefulness.

**Security and Privacy**:

* Data transmission within the network is encrypted to maintain privacy.
* Nodes stake tokens to participate, ensuring commitment and reducing the likelihood of malicious behavior.
