# Overview

Morpheus Background, Links and answering the "Why?"

## What is Lumerin Protocol and the proxy-router's role in helping to solve this problem?&#x20;

* Key Links:&#x20;
  * [Morpheus Lumerin Model](https://github.com/MorpheusAIs/Docs/blob/main/!KEYDOCS%20README%20FIRST!/Morpheus%20Lumerin%20Model.md)&#x20;
  * [Morpheus Lumerin Lightpaper](https://github.com/MorpheusAIs/Docs/blob/main/!KEYDOCS%20README%20FIRST!/Morpheus%20Lumerin%20Model%20Lightpaper.md/)
* In the Yellowstone compute model paper, the author describes the "Router" as a software application that has MOR address and negotiates the 2-sided market between Users and Providers. &#x20;
* The Morpheus Router is highly parallel to the function the Lumerin Protocol Proxy Router provides in the Hashpower marketplace which brokers a 2-sided marketplace between Hashpower Sellers and Hashpower Buyers
* There is a natural fit for the Lumerin based Smart Contract marketplace,  and secure-tcp routing of data between providers, validators and users.

## What problem is Morpheus trying to solve?&#x20;

* [Morpheus WhitePaper](https://github.com/MorpheusAIs/Docs/blob/main/!KEYDOCS%20README%20FIRST!/WhitePaper.md#morpheus) - intent and overview
  * Key items from the [FAQ](https://github.com/MorpheusAIs/Docs/blob/main/!KEYDOCS%20README%20FIRST!/FAQs.md#whitepaper-tldr):&#x20;
    1. Access to AI has become fundamental to modern life.
    2. Large centralized companies currently gatekeep access to AI, they actively restrict access & use censorship.
    3. Having a personal AI that is open source, decentralized, and permissionless fixes this.
    4. Morpheus provides users a decentralized, permissionless, personal AI.
    5. Decentralized, permissionless financial rails is also required for true AI freedom.
    6. Morpheus uses crypto-based financial rails to reward AI & Smart Agent providers.
    7. Follow the white rabbit. Free your mind.
* [Morpheus YellowPaper](https://github.com/MorpheusAIs/Docs/blob/main/!KEYDOCS%20README%20FIRST!/YellowPaper.md#morpheus-yellow-paper) - technical details of the Full Node&#x20;
* [Morpheus "Yellowstone" Compute model](https://github.com/MorpheusAIs/Docs/blob/main/!KEYDOCS%20README%20FIRST!/Yellowstone%20Compute%20Model.md#morpheus-yellowstone-compute-model) - proposed updated tokenomics structure for compute incentivization&#x20;
  * Key Components:&#x20;
    * Users
    * Providers
    * Router
    * Contract

##

##


# Primer: AI-ML-DL-NN-LLM

Abbreviated sketch of key terms and relationships with regard to AI and related components.

Before we can discuss how Lumerin can work with Morpheus to enable decentralized, web3 based,  AI routing, we need to start with an overview of the concept, technology and terms.  This is not meant to be exhaustive nor authoritative, but a high level sketch to get most folks started. &#x20;

## Artificial Intelligence (AI)

* Artificial Intelligence (AI) represents the broadest field dedicated to creating machines capable of performing tasks that typically require human intelligence.&#x20;
* Attempts to train computers to think and learn as humans do using interconnected, artificial "neurons" with deep learning algorithms to solve complex problems
  * **Computer Vision** - extract information and insights from image and videos&#x20;
  * **Speech Recognition** - analyze human speech across wide variety of variables (accent, pitch, tone, language, etc..)&#x20;
  * **Natural language processing** - use deep learning to gather insights and meaning from text-based data&#x20;
  * **Recommendation engines** - track user activity to deliver personalized recommendations
  * **Generative** - generating text, images or videos based on input&#x20;

## **Machine Learning** **(ML)**

* Within AI, Machine Learning (ML) emerges as a subset that focuses on algorithms and statistical models that enable computers to perform specific tasks without explicit instructions, relying instead on patterns and inference.&#x20;
  * **Supervised Learning**: known and categorized data set as a "starter", with human-based correction
  * **Deep Learning (DL)** is a specialized subset of ML that employs neural networks with many layers (deep neural networks) to analyze large amounts of data, making it particularly effective for tasks like image and speech recognition.&#x20;
    * The challenge is that deep learning requires large quantities (petabytes) of high quality data and large compute resources to process that data and can have millions of parameters for queries.
    * Efficient processing of unstructured data
      * Pattern discovery&#x20;
        * Unsupervised learning&#x20;
        * &#x20;Volatile data processing&#x20;
* Google AI Team provides a great set of YouTube videos, here are just two:&#x20;
  * [What Is Machine Learning](https://www.youtube.com/watch?v=HcqpanDadyQ)?&#x20;
  * [Seven Steps of ML](https://www.youtube.com/watch?v=nKW8Ndu7Mjw) - Google AI Team&#x20;
    * Model - Question answering system&#x20;
    * Training - answer questions accurately most of the time&#x20;
    * Features - color (wavelength) and alcohol percentage&#x20;
    * Learning Process - Gather & Prepare Data, Choose Model & Train
    * Evaluation - once trained, use the set-aside initial data to validate model&#x20;
    * HyperParameter Tuning - test assumptions and try other values&#x20;
    * Prediction/Inference - use data to answer the question...Use random color and alcohol percentage as input, will determine wine v beer

## **Neural Networks (NN)**&#x20;

* Neural Networks (NN), fundamental to deep learning, are architectures inspired by the human brain's structure and function, designed to recognize patterns through a complex system of nodes and connections. &#x20;
  * **Nodes** - artificial "neurons" that use **mathematical calculations** to process data
  * Base Components
    * **Input Layer** - nodes that input data, process, categorize and pass to further layers of the NN&#x20;
    * **Hidden Layer(s)** - interconnected nodes/multiple layers for input analysis sometimes from several different angles ...eg: multiple hidden layers can be trained to recognize different features in animal categorization (#of legs, fur/no fur, eye shape, etc...)&#x20;
    * **Output Layer -** nodes that output data eg: output that is "yes" or "no" as only two nodes in the output layer&#x20;
  * Types of neural networks&#x20;
    * **Feedforward** - process data in one direction&#x20;
    * **Back-propagation Algorithm** -  Reinforcement of path from Input node to output nodes using guess and validation feedback loops&#x20;
    * **Convolutional** - perform specific mathematical functions like summarizing or filtering (eg: image attribute classification) &#x20;
  * Deep neural networks or deep learning networks uses weighted relationships between nodes to make better predictions or inferences by using corrective feedback loops and these must be trained with various machine learning techniques

## **Large Language Models (LLM)**&#x20;

* Large Language Models (LLMs) are a specific application of neural networks, designed to understand, interpret, and generate human language, exemplifying the advancements in deep learning and AI's capability to process and produce natural language content.
* Very large deep learning models that are pre-trained on vast amounts of data relying on a set of neural networks &#x20;
  * Encoder/Decoder -extract meaning from a sequence of text and understand the relationships between words and phrases &#x20;
  * Self-attention&#x20;
  * Requires little domain training&#x20;
    * Few shot or Zero Shot - model is able to recognize with little or no training&#x20;

**{WIP}**&#x20;

{Asked GitBook AI to Generate a paragraph on LLM:} \
Large Language Models (LLMs), such as GPT (Generative Pre-trained Transformer) and BERT (Bidirectional Encoder Representations from Transformers), represent the cutting edge of AI's ability to process and generate human-like text. These models are built upon deep neural network architectures, particularly transformers, that have been pre-trained on extensive datasets covering a vast swath of human knowledge. This pre-training enables LLMs to understand context, generate coherent and contextually relevant text, and perform tasks like translation, summarization, and question-answering with minimal additional training. Their versatility and capability have made them invaluable tools in developing applications that require a deep understanding of language, from automated customer service bots to sophisticated content creation tools.

## Key Links&#x20;

* LLM References&#x20;
  * <https://www.lexology.com/library/detail.aspx?g=669b9423-4a75-4248-9af9-4d568d041c36>
  * <https://aws.amazon.com/what-is/large-language-model/>
  * <https://www.comet.com/site/blog/a-guide-to-llmops-large-language-model-operations/>
  * <https://www.elastic.co/what-is/large-language-models>
  * Vulnerabilities in LLM implementation: <https://github.com/greshake/llm-security>


# Design Principles

Principles and guidelines to follow while working with and developing Morpheus architecture.

## Core Concepts&#x20;

#### 1. No SPOFs (single points of failure)

Centralized servers, data stores, and even routers or relays often pose significant risk in a decentralized architecture, mainly by creating single points of failure (SPOFs). When vital functions or data are centralized, the entire system's reliability is jeopardized if those servers or services fail or are compromised. To mitigate these risks, the architecture emphasizes the importance of decentralization at multiple levels: servers, data stores, and routing mechanisms. This approach ensures no single component's failure can bring down the entire system, thereby enhancing its resilience and security.

<div align="center"><figure><img src="/files/OwwT5mcoIszpOjj2WvLg" alt="" width="188"><figcaption></figcaption></figure></div>

#### 2. One Software Solution

A single codebase for both providers and users streamlines maintenance, versioning, and upgrades significantly. This approach means that any update or fix is universally applicable, eliminating the need for parallel development tracks or compatibility checks between different client versions. It simplifies the deployment process, as there's only one software version to distribute and update. For open-source projects, this enhances collaboration and contribution efficiency, as developers can focus on a single code repository, making it easier to track changes, manage issues, and merge contributions. This unified framework fosters a more cohesive development environment, reducing fragmentation and ensuring that improvements benefit the entire ecosystem simultaneously.

<figure><img src="/files/ff6QMbx7w4VlRBPb4tZX" alt="" width="188"><figcaption></figcaption></figure>

#### 3. Minimal Blockchain Transactions

Blockchain technology distinguishes between two primary types of transactions: **reads**, which are relatively inexpensive, and **writes**, which can be both costly and slow. The inherent design of blockchains ensures that retrieving data ('reading') is efficient and cost-effective, making it an attractive proposition for applications that require frequent access to stored information. Conversely, adding data or recording new transactions on the blockchain ('writing') involves a more complex process. It requires consensus among network participants, consumes significant computational resources, and incurs higher fees. By minimizing the number of on-chain writes, applications can significantly reduce operational costs and enhance performance, making the technology more sustainable and practical for a wide range of use cases. This approach underscores the importance of designing blockchain-based systems with an emphasis on reducing the frequency and necessity of expensive write operations, thereby optimizing both economic and computational efficiency.

<figure><img src="/files/NF77quFl6uHyUK8IsGGf" alt="" width="188"><figcaption></figcaption></figure>

#### 4. Blockchain Agnostic

The ability to deploy smart contract code on any Ethereum Virtual Machine (EVM) compatible blockchain is paramount for ensuring maximum interoperability and flexibility. By designing smart contracts to be blockchain agnostic, developers can leverage the unique advantages of different blockchains while maintaining a consistent and seamless experience for users. This approach not only broadens the potential user base but also enhances the robustness of applications by integrating with multiple ecosystems, significantly improving the overall resilience and scalability of the deployed solutions.

<figure><img src="/files/V4LPOdwAp87k6PuM1VnM" alt="" width="188"><figcaption></figcaption></figure>

#### 5. Model Agnostic

Being AI model agnostic is crucial for the Morpheus network to efficiently process and handle a wide array of data models. This versatility ensures that the network can seamlessly integrate with different AI technologies, regardless of their underlying architecture or design principles. By fostering an environment that accommodates any type of AI model, the network enhances its adaptability, enabling it to quickly respond to evolving technological trends and user needs. This AI model agnosticism not only future-proofs the network but also significantly broadens its applicability across various industries, ensuring it can meet diverse data processing requirements with precision and efficiency.

<figure><img src="/files/BmIYJbsUs12S3gAgHRqB" alt="" width="188"><figcaption></figcaption></figure>

#### 6. Prompt & Inference Privacy

Ensuring that the prompt and inference data stream seamlessly between the user and provider, without intermediaries, is a cornerstone of the Morpheus privacy strategy. This direct transmission guarantees that sensitive information remains confidential, significantly reducing the risk of data breaches. By circumventing the need to publicly expose any private data, we maintain a high level of security and confidentiality for all users and providers. This approach not only reinforces good decentralized system design patterns but also keeps the data transmitted through a public blockchain as anonymized and private as possible.

<figure><img src="/files/LlCQoZypy65O7zKq3eOJ" alt="" width="188"><figcaption></figcaption></figure>

**7. Node Security**

For providers, protecting their IP address or URL endpoint is paramount to maintaining the integrity and security of the Morpheus network. Utilizing proxies, load balancers, VPNs, or other obfuscation methods helps shield their digital footprint, making it significantly more challenging for malicious actors to target or exploit the system. Similarly, ensuring user nodes are only visible to providers during active sessions enhances privacy and security for all users. This layer of anonymity is crucial; it prevents potential attackers from easily mapping the network or identifying vulnerable points for attacks. Together, these strategies form a robust defense mechanism, bolstering the network's resilience against cyber threats and preserving the confidentiality and integrity of the data flowing through it.

<figure><img src="/files/bVCKXowFClzjuwfH0WyL" alt="" width="188"><figcaption></figcaption></figure>


# Conceptual Architecture

set of high level block diagrams (each on own subpage) with paragraph(s) describing the view

## Design Principles

### Core Concepts&#x20;

1. No SPOF (single points of failure)
   * No centralized servers
   * No centralized data stores
   * No centralized routers or relays
2. Single software solution / code base
   * Provider Node = User Node
   * Any user can be a provider
   * Any provider can be a user
3. Minimal on-chain transactions
   * Reads are cheap
   * Writes are very expensive
4. Agnostic as possible
   * Multiple Blockchains (EVM)
   * Model type agnostic

### Privacy & Security&#x20;

1. Prompt / Inference
   * Prompts & inference are as private as possible.
   * No prompt or inference data is written to the blockchain.
2. Node Locations
   * Providers will need to register their\
     IP or Url on chain.
   * Users nodes will only be visible to providers during sessions
   * Proxy, load balancer, VPN, or other obfuscation method recommended

### Design Pattern

<figure><img src="/files/DFmF22qRyE1v3w6idwhD" alt=""><figcaption><p>Overall Conversation Flow </p></figcaption></figure>

### Data Routing Pattern

<figure><img src="/files/uYEIyRTbUeg9lr1t5AVL" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/0ID5Zeh5l6U6Ree1apHB" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/vdD7XHa1nusgSYy4Jdzz" alt=""><figcaption></figcaption></figure>


# Session Flow

1. User selects model & receives endpoints from router.
2. User node pings endpoints to determine best provider & requests session with provider.
3. If provider accepts session request, User submits “open session” transaction to router.
4. User opens socket to provider & submits prompts.
5. Once done, User requests receipt from provider & submits receipt + User report to router to close the session.
6. Provider claims payment from router.

<figure><img src="/files/e3HJMNq2qdkZxtXd7Fsh" alt=""><figcaption></figcaption></figure>


# Node Architecture

## Overview:&#x20;

* The goal of this architecture is to create a network of hosted models and agents that can be accessed by any node in the network.&#x20;
* Nodes will be compensated for services provided and agents can be monetized like apps.

## Notes:&#x20;

* Morpheus will come packaged with a default chat agent and a lightweight web3 model&#x20;
* Each agent has its own contract and is recorded in the agent registry contract&#x20;
* Agents will have a reputation score or rating and can receive reviews&#x20;
* Each model will have its own contract and is recorded in the model registry&#x20;
* Model contracts have IPFS pointers, versioning and seed node stores
* Models will have a reputation score or rating and can receive reviews&#x20;
* Peers are needed for Pretty Good Verification (PGV) and for routing interfaces to the requesters

<figure><img src="/files/Vx8hy7OjJ3D4N7Qnua1c" alt=""><figcaption><p>v0.5 Node Architecture Proposal (Ryan Condron 12/10/2023) </p></figcaption></figure>


# Smart Contracts

<figure><img src="/files/ORCsx55dRcJlO3FgVcFn" alt=""><figcaption></figcaption></figure>


# Decision Trees

<figure><img src="/files/12nQwZc0GQsPJMT4rmis" alt=""><figcaption><p>Ecosystem Contracts</p></figcaption></figure>

<figure><img src="/files/iCoLHAFxlGpz9NImEHZh" alt=""><figcaption><p>Router Contract Functions</p></figcaption></figure>


# Provider Decision Tree

<figure><img src="/files/ULKdyIiomzNgt8YGPn6Q" alt=""><figcaption></figcaption></figure>


# User Decision Tree

<figure><img src="/files/SGefpDFoXXbIJ40p9Xt9" alt=""><figcaption><p>User Decision Tree</p></figcaption></figure>

\<need to find optimal way to link drawio content for dynamic updates>&#x20;


# User Interface


