Include pipeline script
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748# Requirements: `pip install distilabel[hf-inference-endpoints]`import osimport randomfrom distilabel.llms import InferenceEndpointsLLMfrom distilabel.pipeline import Pipelinefrom distilabel.steps import LoadDataFromDicts, KeepColumnsfrom distilabel.steps.tasks import GenerateTextClassificationData
MODEL = "meta-llama/Llama-3.1-8B-Instruct"BASE_URL = ""TEXT_CLASSIFICATION_TASK = "None"os.environ["API_KEY"] = ( "hf_xxx" # https://huggingface.co/settings/tokens/new?ownUserPermissions=repo.content.read&ownUserPermissions=repo.write&globalPermissions=inference.serverless.write&canReadGatedRepos=true&tokenType=fineGrained)
with Pipeline(name="textcat") as pipeline:
task_generator = LoadDataFromDicts(data=[{"task": TEXT_CLASSIFICATION_TASK}])
textcat_generation = GenerateTextClassificationData( llm=InferenceEndpointsLLM( model_id=MODEL, base_url=BASE_URL, api_key=os.environ["API_KEY"], generation_kwargs={ "temperature": 0.8, "max_new_tokens": 2048, "do_sample": True, "top_k": 50, "top_p": 0.95, }, ), 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()pipeline.pyAdded+48