Created
October 18, 2024 15:14
-
-
Save sroecker/55d5c117de30abdc3b0bd2d89880a847 to your computer and use it in GitHub Desktop.
Simple evol-instruct example with distilabel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from distilabel.steps import LoadDataFromDicts | |
from distilabel.steps.tasks import EvolInstruct | |
from distilabel.pipeline import Pipeline | |
from distilabel.llms import OllamaLLM | |
import pprint | |
# Set up the pipeline | |
with Pipeline(name="evol-instruct-example") as pipeline: | |
# Load initial instructions | |
load_data = LoadDataFromDicts( | |
name="load_data", | |
data=[ | |
{"instruction": "How to debug a k8s cluster."}, | |
{"instruction": "Explain how LLM finetuning works."} | |
], | |
batch_size=2 | |
) | |
evol_instruct = EvolInstruct( | |
llm=OllamaLLM(model="llama3.2:3b-instruct-q8_0"), # Use Llama 3.2 with Ollama | |
num_evolutions=2, | |
) | |
load_data.connect(evol_instruct) | |
if __name__ == "__main__": | |
result = pipeline.run() | |
# Print evolved instructions | |
#print(result['default']['train']) | |
#for res in result: | |
# pprint.pp(result) | |
for item in result['default']['train']: | |
#pprint.pp(item) | |
print("Original:", item["instruction"]) | |
print("Evolved:", item["evolved_instruction"]) | |
print() | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment