File size: 3,221 Bytes
ad205ef
540edb7
ad205ef
 
540edb7
ad205ef
540edb7
ee97f4a
ad205ef
ee97f4a
ad205ef
 
 
 
ee97f4a
ad205ef
ee97f4a
ad205ef
ee97f4a
ad205ef
 
 
241dc8f
ad205ef
 
 
 
ee97f4a
ad205ef
 
 
ee97f4a
ad205ef
 
 
 
 
 
 
ee97f4a
ad205ef
 
 
 
ee97f4a
ad205ef
ee97f4a
ad205ef
ee97f4a
ad205ef
 
 
ee97f4a
ad205ef
ee97f4a
ad205ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ee97f4a
ad205ef
ee97f4a
ad205ef
 
ee97f4a
 
ad205ef
ee97f4a
ad205ef
ee97f4a
ad205ef
ee97f4a
ad205ef
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# Labrador Synthetic Data Generation Pipeline

## Introduction
This repository contains the Labrador synthetic data generation pipeline, which is used to generate synthetic data for various purposes.

## Run Instructions (Automation)


### Step 1: Environment Setup

1. Initialize a `.env` file with the following [access tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#personal-access-tokens-classic):
    ```
    GIT_ACCESS_TOKEN={ACCESS-TOKEN-TO-ACCESS-TAXONOMY-REPO} # this personal access token is used to access instruct-lab/taxonomy repo
    ```

### Step 2: Execution

To run the pipeline:

1. Execute the following command:
    
    NOTE: Depending on whether you are running on old or new vela, change this line in the orchestrator.py to use the appropriate old vela or new vela template. `save_job_with_jinja_template(cfg, "templates/labrador_datagen_vela.yaml.j2", output_dir=f"jobs/{branch}")`

    
    ```
    python orchestrator.py branch-name
    ```

   This will:
   - Create a file with a list of leaf nodes in the `jobs` directory.
   - Generate YAML files for each leaf node and store them in the `jobs` directory something like `test-7984f9cae729b798bed1ba222715b880.yaml`

2. To initiate the skill generation pipeline, run:
    
    To trigger a job, take the above yaml and 
    
    ```
    oc create -f jobs/yaml_name.yaml
    ```

   This command will execute the pipeline and store the results in the `new_data/labrador-datagen` directory within the COS bucket mounted on the Vela cluster.
   
   
## Run Instructions (Manual - Testing)

### Step 1: Run model

Run teacher model - this model can be replaced with any small model for testing purposes

```
text-generation-launcher -p 8080 --model-id mistralai/Mixtral-8x7B-Instruct-v0.1 --dtype bfloat16 --max-input-length 4096  --max-batch-prefill-tokens 4096 --max-total-tokens 12288
```

Next, set the following enviornment variables:

```
  LEAF_NODE=knowledge/textbooks/ethics/qna.yaml # Path to the leaf node that you want to download
  NUM_SAMPLES=30
  NUM_GROUNDED_QUESTIONS=3
  NUM_GEN_PROC=32
  NUM_UTIL_PROC=8
  SAVE_PATH=new_data/labrador_datagen # Path where you want to download the data
  CONTEXT=0 # Set 0 for freeform and 1 for grounded
  DATA_PATH=.
  CHECKSUM=test
  BRANCH_NAME=test # Branch name to download data from
  KNOWLEDGE=1 # Set 0 for skills and 1 for knowledge
  PARENT_DIR=$(dirname "$LEAF_NODE")
  GIT_ACCESS_TOKEN= # Access token to access taxonomy repo
 ```

### Skills

Download data
```
wget --header "Authorization: token $GIT_ACCESS_TOKEN" --directory-prefix="$DATA_PATH/$PARENT_DIR" "https://raw.githubusercontent.com/instruct-lab/taxonomy/$BRANCH_NAME/$LEAF_NODE"
```

Run the Justfile using:

```
just run
```

The Justfile will check the context value. If the context is set to 1, it will run scripts for grounded data generation. If the context is set to 0, it will run scripts for freeform data generation and save the generated files in the root of the repo in the same directory structure.

### Knowledge

Download data

```
bash download_docs.sh
```
Run knowledge script
```
python knowledge_generation_pipeline.py
```