bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 16쪽 중 2쪽
o Earn" tab, you will see a list of wallet addresses with their respective Delegator estimated Annual Percentage Yield (eAPY), Reward-sharing ratio, Total stake and Weekly Delegation Growth associated with the given address:
<figure><img src="https://742781353-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1RpcbvTSHzzPwOSUvgKU%2Fuploads%2FpATKY1xRgLbh4ImPIjnk%2Fimage.png?alt=media&token=47da760e-dec3-4622-a465-ff813f63154d" alt=""><figcaption></figcaption></figure>
{% hint style="info" %}
Note: In the new delegation pool update, for training nodes, the delegation pool will freeze 1 day before the end of training stage of a task till 1 day after the results have been finalised i.e. the pool will not be able to receive new delegation during that phase.
{% endhint %}
#### Understanding the Delegator eAPY (estimated Annual Percentage Yield)
In order to make the delegator returns easy to understand, we display eAPY based on the previous rolling 14d and 30d returns of nodes. Those nodes which do not have a 14d history are highlighted separately.
We use the following formula to calculate the 14d rolling eAPY
If this wallet has delegator stake to him and pool is older then 7 days
$$
R\_t =
\sum\_{i=1}^{n} \frac{\text{RewardShareRatio}\_i \cdot \text{DelegatorPoolReward}\_i(\text{address})}{n\cdot \text{delegatorStake}\_i(\text{address})}
$$
$$
\text{Delegator eAPY} = (1 + R\_t)^{365} - 1 \approx R\_t \cdot 365
$$
Else
$$
R\_t =
\sum\_{i=1}^{n} \frac{{\text{RewardShareRatio}\_i}\cdot \text{Reward}\_i(\text{address})}{n\cdot \text{stake}\_i(\text{address})}
$$
$$
\text{Delegator eAPY} = (1 + R\_t)^{365} - 1 \approx R\_t \cdot 365
$$
\*if the delegator pool is less than 14 days (say 11 days), then n=11
### Step 2: Approve gmFLOCK transaction.
Click on the wallet you would like to stake gmFLOCK to. You will then see a pop-up, in which you can insert the amount of gmFLOCK you intend to delegate. Click "Approve FLOCK" to confirm this transaction:
<figure><img src="https://742781353-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1RpcbvTSHzzPwOSUvgKU%2Fuploads%2FXsRsJGErr7WuO1Z1H28k%2Fimage.png?alt=media&token=ffeac962-405f-4a02-b7e0-469709bb34d1" alt="" width="421"><figcaption><p>Step 3: Approve gmFLOCK for staking</p></figcaption></figure>
Step 3: Stake gmFLOCK.
Once you approve the gmFLOCK transaction, you will see another pop-up. Click "Stake gmFLOCK" to confirm staking transaction:
<figure><img src="https://742781353-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1RpcbvTSHzzPwOSUvgKU%2Fuploads%2FGPzEHdhbfhAQT8QY8dMf%2Fimage.png?alt=media&token=98e1c4b6-6be1-432b-b4f0-debbb6500d4b" alt="" width="425"><figcaption></figcaption></figure>
### Step 4: Withdraw stake and Claim Reward.
You will see all your delegated stake on: <https://train.flock.io/stake-to-earn>. You can withdraw your stake **one day after your delegation**. The rewards are distributed to the delegation pool daily at **midnight UTC.** You can claim your rewards **anytime** as long as there's rewards claimable for you.
<figure><img src="https://742781353-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1RpcbvTSHzzPwOSUvgKU%2Fuploads%2FgDmo7nD2RJ5zTs00KH0I%2Fimage.png?alt=media&token=01a3928d-2018-477a-8b3f-8efd1f9e2a90" alt="" width="440"><figcaption></figcaption></figure>
# Training Node Guide
How to stake and submit a Training Task
This guide provides step-by-step instructions for the entire Training Node workflow. By the end you will have successfully staked as a Training Node, completed a training task, and claimed your staking rewards.
{% hint style="info" %}
Be sure you have completed all pre-requisite tasks.
{% endhint %}
{% hint style="warning" %}
You can only be either training node OR validator for each task. 
{% endhint %}
### 0. Navigate to [train.flock.io](https://train.flock.io/) and connect you wallet.
Follow the steps [here](https://docs.flock.io/flock-products/ai-arena/quickstart/pages/628PqLScceINNZRrYVWa#step-0-go-to-https-train.flock.io-stake-to-earn-and-connect-your-wallet) to connect your wallet.
### 1. Stake gmFLOCK as Training Node from [train.flock.io](https://train.flock.io/)
1. Once you have gmFLOCK tokens, Navigate to the Training Node tab on the Stake page
2. Select a training task
3. Stake gmFLOCK
<figure><img src="https://742781353-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1RpcbvTSHzzPwOSUvgKU%2Fuploads%2FudTDxclTKPcoSRbUnVSE%2Fimage.png?alt=media&token=72d0ba51-82ff-489f-b267-8dd3bc2a137c" alt=""><figcaption></figcaption></figure>
Once you’ve confirmed and approved the transaction in your web3 wallet, you will see a box on the Training Node tab with your stake details.
<figure><img src="https://742781353-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1RpcbvTSHzzPwOSUvgKU%2Fuploads%2FwVKuPFxsLysUTLn0j9VT%2Fimage.png?alt=media&token=1023fa6c-d8dd-4d61-8a4b-147193f8fabb" alt="" width="380"><figcaption></figcaption></figure>
### 2. Accept delegator
Note that you have the option to accept delegator. To do so, go to "Accept Delegator" tab. Select your profit-sharing ratio, then click "Create Delegation Contract":
<figure><img src="https://742781353-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1RpcbvTSHzzPwOSUvgKU%2Fuploads%2Fgc02vjcfg9zeBpGENeVL%2Fimage.png?alt=media&token=3d658247-bc8f-4bd5-9d4e-a590becfe63c" alt=""><figcaption></figcaption></figure>
Once the transaction is completed. You have the option to add a profile and a profile picture, as well as to modify your profit-sharing ratio here:
<figure><img src="https://742781353-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1RpcbvTSHzzPwOSUvgKU%2Fuploads%2Fdoi5pVhPtEXGLIeqYLnA%2Fimage.png?alt=media&token=d5d5e4e5-cda9-463b-bdb2-805e1ee0feb4" alt=""><figcaption></figcaption></figure>
{% hint style="info" %}
You can only modify your rewards-sharing ratio once per month.
{% endhint %}
### 3. Get API key
Your API key is required for all remaining Validator steps. You can get it from the web app.
<figure><img src="https://742781353-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1RpcbvTSHzzPwOSUvgKU%2Fuploads%2F5Mi4hCF0mrwjW9Nljzip%2Fimage.png?alt=media&token=6896e7d0-759b-44ce-a6b1-7e17ed5366f4" alt=""><figcaption></figcaption></figure>
<figure><img src="https://742781353-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1RpcbvTSHzzPwOSUvgKU%2Fuploads%2FvamRJmGlMdZDHaYzD5D3%2Fval2.1_copy-api.png?alt=media&token=43ca5c44-8e5c-42c6-b83f-fbd4a8aeaa45" alt=""><figcaption></figcaption></figure>
1. Select dropdown in upper right corner of web app
2. Select API
3. On the API page, copy your API key
Once you have your API key, you can proceed to the next step.
{% hint style="info" %}
NOTE: If you have issues generating an API key try removing any ad blocker extensions and/or clearing your cookies.
{% endhint %}
### Video Tutorial
{% embed url="<https://youtu.be/1pNoyt370z0>" %}
### 4. Set up your environment
#### Windows
For Windows users, we suggest installing WSL. Follow the guidance: [WSL installation](/flock-products/ai-arena/quickstart/pre-requisites/wsl-installation)
#### Mac/Linux
You can install Anaconda via [HERE](https://www.anaconda.com/download/success)
### 5. Clone the QuickStart repo
The [quickstart repo](https://github.com/FLock-io/testnet-training-node-quickstart.git) contains everything you need to run our [`full_automation.py`](https://github.com/FLock-io/testnet-training-node-quickstart/blob/main/full_automation.py) script. To clone it run:
```
git clone https://github.com/FLock-io/testnet-training-node-quickstart.git
```
To set up all packages within the project directory
```
conda create -n training-node python==3.10
conda activate training-node
pip install -r requirements.txt
```
{% hint style="info" %}
**File Structure**
* [`dataset.py`](https://github.com/FLock-io/testnet-training-node-quickstart/blob/main/dataset.py) - Contains the logic to process the raw data from `demo_data.jsonl`.
* [`demo_data.jsonl`](https://github.com/FLock-io/testnet-training-node-quickstart/blob/main/demo_data.jsonl) - Follows the shareGPT format. The training data you receive from the `fed-ledger` is in exactly the same format.
* [`merge.py`](https://github.com/FLock-io/testnet-training-node-quickstart/blob/main/merge.py) - Contains the utility function for merging LoRA weights. If you are training with LoRA, please ensure you merge the adapter before uploading to your Hugging Face repository.
* [`demo.py`](https://github.com/FLock-io/testnet-training-node-quickstart/blob/main/demo.py) - A training script that implements LoRA fine-tuning for a Gemma-2B model.
{% endhint %}
### 6. Get information required to run automation script
The script described in the following step automates the following:
* Gets a task
* Downloads the training data
* Finetunes Gemma-2B on training data
* Merges weights
* Uploads to your Hugging Face model repo
* Submits the task to `fed-ledger`
To run it, you will need:
* `TASK_ID` - the id of the task you are staking on as Training Node
* `FLOCK_API_KEY` - available at <https://train.flock.io/flock_api>
* `HF_TOKEN` - your Hugging Face Access Token (Hugging Face > Profile > Settings > Access Tokens)
* `HG_USERNAME` - your Hugging Face user name
{% hint style="info" %}
NOTE: If you haven't already done so, please acknowledge license to access Gemma on Hugging Face:
<https://huggingface.co/google/gemma-2b>
{% endhint %}
### 7. Run full automation script
Once you have all the information listed in the previous step, paste the script below into your terminal, update the repsective values, and run the command.
{% tabs %}
{% tab title="Unix/Linux" %}
{% code overflow="wrap" %}
```
TASK_ID=<task-id> FLOCK_API_KEY="<your-flock-api-key-stakes-as-node-for-the-task>" HF_TOKEN="<your-hf-token>" CUDA_VISIBLE_DEVICES=0 HF_USERNAME="your-hf-user-name" python full_automation.py
```
{% endcode %}
{% endtab %}
{% tab title="CMD" %}
```
set TASK_ID=<task-id> &&
set FLOCK_API_KEY="<your-flock-api-key-stakes-as-node-for-the-task>" &&
set HF_TOKEN="<your-hf-token>" &&
set CUDA_VISIBLE_DEVICES=0 &&
set HF_USERNAME="your-hf-user-name" &&
python full_automation.py
```
{% endtab %}
{% tab title="PowerShell" %}
```
$env:TASK_ID = "<task-id>"
$env:FLOCK_API_KEY = "<your-flock-api-key-stakes-as-node-for-the-task>"
$env:HF_TOKEN = "<your-hf-token>"
$env:CUDA_VISIBLE_DEVICES = "0"
$env:HF_USERNAME = "your-hf-user-name"
python full_automation.py
```
{% endtab %}
{% endtabs %}
{% hint style="info" %}
NOTE: Tasks can be completed with any [supported base LLM model](https://github.com/FLock-io/llm-loss-validator/blob/main/src/core/constant.py). The only restriction is `max_param.`You can use any technique to train or fine-tune a model, all you need to make sure is that the model can be successfully run by our [validation script](https://github.com/FLock-io/llm-loss-validator/tree/main).
{% endhint %}
### 8. Claim rewards
Reward distribution is triggered every 24 hours at midnight UTC. The final round of reward distribution is triggered at the once the task training period is complete. 
You can claim your rewards via [train.flock.io](https://train.flock.io).
# Validator Guide
How to stake and validate tasks as a Validator
This guide provides step-by-step instructions for the entire Validator workflow. By the end you will have successfully staked as a Validator, requested task assignment(s), run a validator script, uploaded loss score(s), and claimed your staking rewards.
{% hint style="info" %}
Be sure you have completed all pre-requisite tasks.
{% endhint %}
{% hint style="warning" %}
You can only be either training node OR validator for each task. 
{% endhint %}
### 0. Navigate to [train.flock.io](https://train.flock.io/) and connect you wallet.
Follow the steps [here](https://docs.flock.io/flock-products/ai-arena/quickstart/pages/628PqLScceINNZRrYVWa#step-0-go-to-https-train.flock.io-stake-to-earn-and-connect-your-wallet) to connect your wallet.
### 1. Stake gmFLOCK as Validator from [train.flock.io](https://train.flock.io/)
In order begin receiving validation assignments, you must stake gmFLOCK to a task at train.flock.io.
<figure><img src="https://742781353-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1RpcbvTSHzzPwOSUvgKU%2Fuploads%2FDAj7P4grSx9nO7bWARPu%2Fimage.png?alt=media&token=42c8860c-7276-488a-80fd-e5d9bdc68396" alt=""><figcaption></figcaption></figure>
1. Navigate to the Validator tab on the Stake page
2. Select task to validate
3. Stake gmFLOCK
Once you’ve confirmed and approved the transaction in your web3 wallet, you will see a box on the Validator tab with your stake details.
<figure><img src="https://742781353-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1RpcbvTSHzzPwOSUvgKU%2Fuploads%2FmwSDTYDoyG2GpaUSg1Tz%2Fimage.png?alt=media&token=ef359809-805f-4113-a34f-e5f52ae5af11" alt="" width="376"><figcaption></figcaption></figure>
### 3. Accept delegator
Note that you have the option to accept delegator. To do so, go to "Accept Delegator" tab. Select your profit-sharing ratio, then click "Create Delegation Contract":
<figure><img src="https://742781353-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1RpcbvTSHzzPwOSUvgKU%2Fuploads%2FXiNSU1QIUUE1lIMVSobm%2Fimage.png?alt=media&token=00d730be-f414-4dc6-99d6-9ab0d2eed5cc" alt=""><figcaption></figcaption></figure>
Once the transaction is completed. You have the option to add a profile and a profile picture, as well as to modify your profit-sharing ratio here:
<figure><img src="https://742781353-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1RpcbvTSHzzPwOSUvgKU%2Fuploads%2FFiob6tiEPnbMdZtKNcpC%2Fimage.png?alt=media&token=1f8a2427-0673-4cec-911c-9e899c74c3bf" alt=""><figcaption></figcaption></figure>
{% hint style="info" %}
You can only motify your rewards-sharing ratio once per month.
{% endhint %}
### 4. Get API key
Your API key is required for all remaining Validator steps. You can get it from the web app.
<figure><img src="https://742781353-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1RpcbvTSHzzPwOSUvgKU%2Fuploads%2FtHMvYWiFObMvGMto35fz%2Fimage.png?alt=media&token=bfc8a8f0-db23-4b17-8771-a6174a1dc281" alt=""><figcaption></figcaption></figure>
1. Select dropdown in upper right corner of web app
2. Select API
3. On the API page, copy your API key
Once you have your API key, you can proceed to the next step.
{% hint style="info" %}
NOTE: If you have issues generating an API key try removing any ad blocker extensions and/or clearing your cookies.
{% endhint %}
### Video Tutorial
{% embed url="<https://youtu.be/qmHTxYRAzAM>" %}
### 5. Set up your environment
To set up your environment, run the following commands:
#### Windows
For Windows users, we suggest installing WSL. Follow the guidance: [WSL installation](/flock-products/ai-arena/quickstart/pre-requisites/wsl-installation)
#### Mac/Linux
You can install Anaconda via [HERE](https://www.anaconda.com/download/success)
### 6. Clone the Validator Repo
The [validator](https://github.com/FLock-io/llm-loss-validator) repo contains everything you need to run our script. To clone it run:
```
git clone https://github.com/FLock-io/llm-loss-validator.git
```
To set up all packages within the project directory
```
conda create -n llm-loss-validator python==3.10
conda activate llm-loss-validator
pip install -r requirements.txt
```
### 7. Run Validation Script
Now that you have staked as a Validator and have your API key you can run the validation script by running the following loop in your command line:
{% tabs %}
{% tab title="Unix/Linux with Nvidia GPU" %}
```bash
cd /src
CUDA_VISIBLE_DEVICES=0 \
bash start.sh \
--hf_token your_hf_token \
--flock_api_key your_flock_api_key \
--task_id your_task_id \
--validation_args_file validation_config.json.example \
--auto_clean_cache False
```
{% endtab %}
{% tab title="Unix/Linux CPU only" %}
```bash
cd /src
bash start.sh \
--hf_token your_hf_token \
--flock_api_key your_flock_api_key \
--task_id your_task_id \
--validation_args_file validation_config_cpu.json.example \
--auto_clean_cache False
```
{% endtab %}
{% tab title="WSL" %}
```
cd /src
set CUDA_VISIBLE_DEVICES=0
wsl bash start.sh \
--hf_token your_hf_token \
--flock_api_key your_flock_api_key \
--task_id your_task_id \
--validation_args_file validation_config.json.example \
--auto_clean_cache False
```
{% endtab %}
{% tab title="PowerShell" %}
```
cd /src
$env:CUDA_VISIBLE_DEVICES=0
powershell -File .\start.ps1 `
-hf_token <your_hf_token> `
-flock_api_key <your_flock_api_key> `
-task_id <your_task_id> `
-validation_args_file validation_config.json.example `
-other_args @("--auto_clean_cache", "False")
```
{% endtab %}
{% endtabs %}
* `CUDA_VISIBLE_DEVICES=0`: Specifies which GPU to use. `0` indicates the first GPU. Adjust this based on your available GPUs. Remove this line if you are using just the CPU
* `--hf_token`: Your Hugging Face token, required for accessing certain models. This should token should have write access.
* `--flock_api_key`: Your FLock API key.
* `--task_id`: The ID of the task you want to validate. If you are validating multiple tasks, you can pass a list eg. if you are validating tasks 8 and 9, you can pass `--task_id 8,9`
* `--validation_args_file`: The path to the validation arguments file.
* `--auto_clean_cache`: A flag to determine whether to automatically clean the model cache.
* `--lora_only`: A flag to indicate whether to validate only repositories with LoRA (Low-Rank Adaptation) weights. `True` means only LoRA weights will be validated. This is useful for validators with limited network bandwidth, as LoRA weights are significantly smaller (10-500 MiB) compared to full model files (>10 GiB)
{% hint style="info" %}
NOTE: If you would like to customise your validation script, visit this repo <https://github.com/FLock-io/llm-loss-validator> and check out **How to run validation script** section
Make sure the `HF_TOKEN` you passed in have access to the gated base models like `gemma`, `llama2`, and `llama3` to succesfully validate models fine-tuned based on those.
Links:
<https://huggingface.co/google/gemma-7b>
<https://huggingface.co/meta-llama/Meta-Llama-3-8B>
<https://huggingface.co/meta-llama/Llama-2-7b-hf>
<https://huggingface.co/google/gemma-2b>
{% endhint %}
### 8. Claim rewards
Reward distribution is triggered every 24 hours at midnight UTC. You can claim your rewards via the web app.
Once you’ve connected your web3 wallet to train.flock.io, you can claim rewards with the following steps:
1. Navigate to the Validator tab on the Stake page
2. Verify you have FLOCK available to claim for the task you are staking
3. Click Claim FLOCK
<figure><img src="https://742781353-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1RpcbvTSHzzPwOSUvgKU%2Fuploads%2FqC2im7MYQW6oLTodMy9R%2Fimage.png?alt=media&token=12e1bb23-87f7-439c-b824-f9e72c2d91b7" alt=""><figcaption></figcaption></figure>
Once you’ve approved the transaction in your web3 wallet you will see a dialogue box confirming your claim.
Congratulations! You’ve successfully completed the entire validator workflow.
# gmFLOCK
What is gmFLOCK and how to get them
In order to participate in AI Arena, you will need to use gmFLOCK (game-FLOCK), which is a market-driven mechanism designed to support AI Arena's tokenomics and emission allocation model. It is transferable, but with restrictions: it can only be used for staking as training nodes, validators, or delegators.
### Step 0: Navigate to [train-v2.flock.io](https://train-v2.flock.io/) and connect you wallet.
Follow the 프로젝트로 돌아가기