my-distiset-859d4555 / pipeline.py
UTMISTChatbot2025's picture
Include pipeline script
f3668d8 verified
# Requirements: `pip install distilabel[hf-inference-endpoints]`
import os
import random
from distilabel.models import InferenceEndpointsLLM
from distilabel.pipeline import Pipeline
from distilabel.steps import LoadDataFromDicts, KeepColumns
from distilabel.steps.tasks import GenerateTextClassificationData
SYSTEM_PROMPT = "None"
with Pipeline(name="textcat") as pipeline:
task_generator = LoadDataFromDicts(data=[{"task": SYSTEM_PROMPT}])
textcat_generation = GenerateTextClassificationData(
llm=InferenceEndpointsLLM.from_dict(
{'use_magpie_template': False, 'magpie_pre_query_template': None, 'generation_kwargs': {}, 'use_offline_batch_generation': False, 'offline_batch_generation_block_until_done': None, 'jobs_ids': None, 'model_id': 'meta-llama/Llama-3.1-8B-Instruct', 'endpoint_name': None, 'endpoint_namespace': None, 'base_url': None, 'tokenizer_id': 'meta-llama/Llama-3.1-8B-Instruct', 'model_display_name': None, 'structured_output': None, 'type_info': {'module': 'distilabel.models.llms.huggingface.inference_endpoints', 'name': 'InferenceEndpointsLLM'}}
),
seed=random.randint(0, 2**32 - 1),
difficulty='high school',
clarity=None,
num_generations=10,
output_mappings={"input_text": "text"},
)
keep_columns = KeepColumns(
columns=["text", "label"],
)
# Connect steps in the pipeline
task_generator >> textcat_generation >> keep_columns
if __name__ == "__main__":
distiset = pipeline.run()