# Validator Guide

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.&#x20;
{% endhint %}

### 0. Navigate to [train.flock.io](https://train.flock.io/) and connect you wallet.

Follow the steps [here](https://docs.flock.io/~/changes/186/flock-products/ai-arena/delegator-guide#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&#x26;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&#x26;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&#x26;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&#x26;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&#x26;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](https://docs.flock.io/~/changes/186/flock-products/ai-arena/quickstart/pre-requisites/wsl-installation "mention")

#### 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&#x26;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.
