Skip to main content

basedai

Project description

BasedAI

Research License: MIT

DocumentationTokenTwitter

BasedAI is a decentralized network built to enable end-to-end private computations on distributed GPU infrastructure. The flagship 'Brain' of BasedAI is allows for Fully Homomorphic Encryption (FHE) of Large Language Models (LLMs), effectively creating Zero-Knowledge LLMs (ZK-LLMs).

For detailed understanding of the BasedAI network and its groundbreaking approach with ZK-LLMs, please refer to our research paper.

Install

  1. To get started with BasedAI:
# pip install basedai

Getting Started

In the BasedAI ecosystem, users participate through an integrated wallet system that supports operations with BasedAI's native token, $BASED. The wallet enables users to stake tokens on different Brains in the ecosystem and earn rewards for contributions.

Wallet Management

  1. Create a new wallet through the BasedAI CLI:
# create a wallet  
basedcli wallet new_personalkey
  1. Interact with your wallet via the BasedAI CLI:
# check the balances of your wallet 
basedcli wallet balance
  1. Join as a Brain miner or validator with a compute key:
# create a new compute wallet for agents operating on your behalf in the network
basedcli wallet new_computekey

For further instructions on token management and participation in the network, please refer to the official documentation.

Configuring and Deploying FHE Operations for ZK-LLM

BasedAI introduces Zero-Knowledge Large Language Models (ZK-LLMs) using Fully Homomorphic Encryption (FHE). Here's how to configure and deploy FHE operations:

  1. Configure the FHE server:
basedcli fhe config --discovery_server <discovery_server_address> --port <port_number> --ollama_model <model_name> --name <server_name>

This command sets up the FHE server configuration, including the discovery server address, port to listen on, Ollama model to use, and a name for your FHE server.

  1. Start the FHE server:
basedcli fhe start_server --config fhe_config.json

This command starts the FHE server using the configuration file created in the previous step.

  1. Discover available FHE servers:
basedcli fhe discover --discovery_server <discovery_server_address>

Use this command to find available FHE servers in the network.

  1. Run FHE operations:
basedcli fhe run --address <your_address> --balance <min_balance> --command <initial_value> --library <fhe_library> --operation <operation_type> --value <additional_values>

This command allows you to perform FHE operations such as square, add, multiply, mean, and variance on encrypted data.

Example FHE operations:

  • Square operation:
    basedcli fhe run --address <your_address> --balance <min_balance> --command 5 --library tenseal --operation square
    
  • Addition operation:
    basedcli fhe run --address <your_address> --balance <min_balance> --command 5 --library concrete --operation add --value 3
    
  • Mean calculation:
    basedcli fhe run --address <your_address> --balance <min_balance> --command 5 --library paillier --operation mean --value 3 4 5
    

These FHE operations enable secure, privacy-preserving computations on encrypted data, forming the foundation of ZK-LLMs in the BasedAI network.

For more detailed information on FHE operations and ZK-LLMs, please refer to our research paper and the official documentation.

Using the CLI

The BasedAI Command Line Interface (CLI) will be the primary tool for interacting with Brains, managing wallets, participating in computation tasks as miners or validators, and engaging in the token economy of BasedAI.

For a list of possible commands:

basedcli help

The BasedAI PIP Package

The BasedAI package includes essential tools included basedai (the Python operations package for developers) and basedcli (for setting up mining, validation activities, and querying ZK-LLMs). Learn more in the official documentation.

Complex Payment Types and Service Broadcasting

BasedAI now supports more complex payment types and enhanced service broadcasting. Here's how to use these new features:

Accepting Complex Payments

To accept a payment with complex payment types:

wallet = basedai.wallet()
payment_info = {
    'amount': 100.0,
    'payer_address': '0x1234...',
    'payment_type': 'subscription',
    'additional_data': {
        'duration': '1 month',
        'start_date': '2024-09-18'
    }
}
success = wallet.accept_payment(payment_info)

Broadcasting Service Details

To broadcast detailed service information:

broadcaster = basedai.Broadcaster(wallet)
service_info = {
    'name': 'Advanced Data Processing',
    'cost': 50.0,
    'payment_types': ['instant', 'subscription', 'escrow'],
    'description': 'High-performance data processing service',
    'availability': '24/7',
    'performance_metrics': {
        'avg_response_time': 0.5,
        'success_rate': 0.99
    }
}
success = broadcaster.broadcast_service_details(service_info)

Updating Service Status

To update the status of a service:

status = {
    'available': True,
    'capacity': 100,
    'response_time': 0.3,
    'queue_length': 5
}
success = broadcaster.update_service_status('Advanced Data Processing', status)

Broadcasting Node Metrics

To broadcast various metrics about your node:

metrics = {
    'capacity': 500,
    'uptime': 720.5,
    'success_rate': 0.995,
    'average_response_time': 0.4,
    'supported_services': ['Data Processing', 'Machine Learning']
}
success = broadcaster.broadcast_node_metrics(metrics)

Governance and Voting

BasedAI embraces decentralized decision-making through Pepecoin-linked "Brains". Owners of GigaBrains, representing significant staked contributions, can participate in voting on key network decisions, upholding the ecosystem's democratic governance model.

For voting procedures:

# vote for a proposal
basedcli brains vote <proposal-id> <option>

For More Information

For further information and updates on BasedAI, please visit the official website or consult the initial research paper.

License

The MIT License (MIT) Copyright © 2024 Based Labs

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

basedai-1.1.0.tar.gz (237.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

basedai-1.1.0-py3-none-any.whl (276.5 kB view details)

Uploaded Python 3

File details

Details for the file basedai-1.1.0.tar.gz.

File metadata

  • Download URL: basedai-1.1.0.tar.gz
  • Upload date:
  • Size: 237.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.10

File hashes

Hashes for basedai-1.1.0.tar.gz
Algorithm Hash digest
SHA256 9d0a48579f6cc14f9efe4b1174506466e89f6b5f11b6b2fe4226ffa9102a0dbb
MD5 2169e82efc5f5b71cd4a9ed75cc2ab53
BLAKE2b-256 171602c5a60842648df0f637bf78326d2bc7ca030bbf4f775dc4e6b1c97f2232

See more details on using hashes here.

File details

Details for the file basedai-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: basedai-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 276.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.10.10

File hashes

Hashes for basedai-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e681679eb5b3daa020249804fd8cc09a2f44146cc5a9f90cc3c960ae8bfc5d9c
MD5 e838cb7f1313d23aa79e664f5fb87ce4
BLAKE2b-256 a9e629cdda915cd505d42bf2a64fd2ae165855862f5a683540f9afa70c677b24

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page