Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: config file support #2

Merged
merged 11 commits into from
Jul 11, 2024
Merged

feat: config file support #2

merged 11 commits into from
Jul 11, 2024

Conversation

xukai92
Copy link
Collaborator

@xukai92 xukai92 commented Jul 10, 2024

tested by the code below:

from openai import OpenAI

from instructlab.sdg.default_flows import Flow, \
    SimpleFreeformSkillFlow, SimpleGroundedSkillFlow, SimpleKnowledgeFlow, \
    MMLUBenchFlow, SynthKnowledgeFlow, SynthSkillsFlow, SynthGroundedSkillsFlow

openai_api_key = "NO_API_KEY"
openai_api_base = "http://localhost:8000/v1"

client = OpenAI(
    api_key=openai_api_key,
    base_url=openai_api_base,
)
model_family = "mixtral"
model_id = "Mixtral-8x7B-Instruct-v0.1"
num_instructions_to_generate = 10

# %%
flow_v0 = SimpleFreeformSkillFlow(client, model_family, model_id, num_instructions_to_generate).get_flow()
flow_v1 = Flow(client, None, None, num_instructions_to_generate).get_flow_from_file(
    "flows/simple_freeform_skill.yaml"
)
flow_v0 == flow_v1

# %%
flow_v0 = SimpleGroundedSkillFlow(client, model_family, model_id, num_instructions_to_generate).get_flow()
flow_v1 = Flow(client, None, None, num_instructions_to_generate).get_flow_from_file(
    "flows/simple_grounded_skill.yaml"
)
flow_v0 == flow_v1

# %%
flow_v0 = SimpleKnowledgeFlow(client, model_family, model_id, num_instructions_to_generate).get_flow()
flow_v1 = Flow(client, None, None, num_instructions_to_generate).get_flow_from_file(
    "flows/simple_knowledge.yaml"
)
flow_v0 == flow_v1

# %%
flow_v0 = MMLUBenchFlow(client, model_family, model_id, num_instructions_to_generate).get_flow()
flow_v1 = Flow(client, None, None, None).get_flow_from_file(
    "flows/mmlu_bench.yaml"
)
flow_v0 == flow_v1

# %%
flow_v0 = SynthKnowledgeFlow(client, model_family, model_id, num_instructions_to_generate).get_flow()
flow_v1 = Flow(client, None, None, None).get_flow_from_file(
    "flows/synth_knowledge.yaml"
)
flow_v0 == flow_v1

# %%
flow_v0 = SynthSkillsFlow(client, model_family, model_id, num_instructions_to_generate).get_flow()
flow_v1 = Flow(client, None, None, 10).get_flow_from_file(
    "flows/synth_skills.yaml"
)
flow_v0 == flow_v1

# %%
flow_v0 = SynthGroundedSkillsFlow(client, model_family, model_id, num_instructions_to_generate).get_flow()
flow_v1 = Flow(client, None, None, 10).get_flow_from_file(
    "flows/synth_grounded_skills.yaml"
)
flow_v0 == flow_v1

block["block_config"]["convert_dtype"] = CONVERT_DTYPE_MAP[block["block_config"]["convert_dtype"]]
n = self.num_instructions_to_generate
if n is not None:
if "gen_kwargs" in block:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this correct? or we only want to do this for the first block in the flow?

@xukai92 xukai92 changed the title feat: config file support [WIP] feat: config file support Jul 10, 2024
@xukai92 xukai92 changed the title [WIP] feat: config file support feat: config file support Jul 10, 2024
aakankshaduggal and others added 2 commits July 10, 2024 11:37
@@ -97,7 +97,9 @@

ds = Dataset.from_list(samples)

skills_flow = SynthGroundedSkillsFlow(client, "mixtral", teacher_model, 10).get_flow()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that you have removed the fields for teacher_model and "mixtral" could you please help me understand how it is interacting with the teacher model.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"mixtral" is the model family and teacher_model is the model ID

  • the model ID is defined in the YAML files as model_id
  • the model family is derived from the model_id by the MODEL_FAMILY_MAP

Kai Xu added 2 commits July 10, 2024 18:42
@xukai92
Copy link
Collaborator Author

xukai92 commented Jul 11, 2024

as of bd370b5, the CLI command below works

ilab data generate --endpoint-url http://localhost:3000/v1 --model mistralai/Mixtral-8x7B-Instruct-v0.1 --num-instructions 1 --api-key NO_API_KEY --model-family mixtral --pipeline full

@shivchander
Copy link
Collaborator

Tested this with @xukai92 - works as expected

@shivchander shivchander merged commit e8fe27e into main Jul 11, 2024
8 of 9 checks passed
aakankshaduggal added a commit that referenced this pull request Jul 11, 2024
* feat: implement get_flow_from_file and port flows to YAML files

Signed-off-by: Kai Xu <[email protected]>

* refactor: remove code version of configs

Signed-off-by: Kai Xu <[email protected]>

* feat: introduce DEFAULT_FLOW_FILE_MAP

Signed-off-by: Kai Xu <[email protected]>

* chore: make linter happy

Signed-off-by: Kai Xu <[email protected]>

* format(tox)

Signed-off-by: Kai Xu <[email protected]>

* format(tox)

Signed-off-by: Kai Xu <[email protected]>

* fix: model ID for CLI test

Signed-off-by: Kai Xu <[email protected]>

* fix: model family map for CLI test

Signed-off-by: Kai Xu <[email protected]>

* feat: hard code samples in config files

Signed-off-by: Kai Xu <[email protected]>

---------

Signed-off-by: Kai Xu <[email protected]>
Signed-off-by: Aakanksha Duggal <[email protected]>
Co-authored-by: Aakanksha Duggal <[email protected]>
khaledsulayman added a commit that referenced this pull request Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants