Skip to content

Commit ea64144

Browse files
added sdg api library design
Signed-off-by: Oindrilla Chatterjee <[email protected]> Co-authored-by: Aakanksha Duggal <[email protected]>
1 parent 08c57d7 commit ea64144

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

docs/images/sdg-api-interface.png

264 KB
Loading

docs/sdg/sdg-api-interface.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# SDG Library Design
2+
3+
## Objective
4+
5+
Library called `instructlab-sdg` that can be called per seed example that includes question and answer pairs, and context for grounded skills.
6+
7+
## Structure of the SDG Library
8+
9+
We propose the following structure for the SDG library. There will be config files that contain all the prompt templates for the pipelines.
10+
11+
```markdown
12+
- src/instructlab/sdg/
13+
- configs/
14+
- gen_q.yaml
15+
- gen_a.yaml
16+
- ...
17+
- init.py
18+
- block.py
19+
- llmblock.py
20+
- pipeline.py
21+
- sdg.py
22+
```
23+
24+
![example API interface](../images/sdg-api-interface.png)
25+
26+
## CLI
27+
28+
The CLI client uses the instructlab SDG library and provides it a run configuration with input parameters.
29+
30+
```python
31+
# cli_driver.py
32+
33+
from sdg import SDG
34+
import yaml
35+
36+
client = openai_client(endpoint)
37+
with open('run_config.yaml', 'r') as file:
38+
run_config = yaml.safe_load(file)
39+
cli_sdg = SDG(run_config, client) # run config has all the variables like num_samples, pipelinesteps etc
40+
generated_samples = cli_sdg.generate()
41+
```
42+
43+
The run configuration contains the parameters needed to run the SDG code library as well as points to the templates needed to run the SDG code as well as the prompt template and the default model system prompt template.
44+
45+
* `num_samples` is the number of synthetic samples that you wish to generate per seed example.
46+
* `max_retry` is the maximum number of non-greedy retries you want to make if the `num_samples` is not reached. The number of samples in the generated output will be the samples achieved until `max_retry` is reached.
47+
* Pipeline steps contains the steps that you want to invoke in the SDG pipeline and the prompt configurations per step. The variable names of the blocks can be anything and the prompt configurations must be compatible with the teacher model.
48+
* `max_new_tokens` is the maximum number of tokens we want to generate. In other words, the size of the output sequence, not including the tokens in the prompt.
49+
* `model_name` is the teacher model we would want to use to generate the synthetic data.
50+
* `model_template` and `stop_token` are the parameters for generation template.
51+
52+
```yaml
53+
# run_config.yaml
54+
55+
num_samples : 30
56+
max_retry : 5
57+
pipeline_steps:
58+
gen_q:
59+
prompt_template: "configs/gen_q.yaml"
60+
filter_q:
61+
prompt_template: "configs/filter_q.yaml"
62+
max_new_tokens: 10000
63+
# model parameters for generation
64+
model_name: mistralai/Mixtral-8x7B-Instruct-v0.1
65+
# generation template
66+
model_template: <s> [INST] {sys_prompt} {prompt} [/INST]
67+
stop_token: </s>
68+
69+
```

0 commit comments

Comments
 (0)