Views
No views yet
GarbageCollector can greatly speed up the validation of instruction-datasets across many languages, flagging examples that need to be fixed or simply discarded.paraphrase-multilingual-mpnet-base-v2, inspired by the findings from the SetFit paper (Section 6. Multilingual experiments.), where they trained models in English that performed well across languages.
ALL GOOD, a given instruction, input, and output are correct,BAD INSTRUCTION, there's an issue with the instruction, and/or input and output.1from setfit import SetFitModel
2
3# Download from Hub
4model = SetFitModel.from_pretrained(
5 "argilla/alpaca-garbage-collector-multilingual"
6)
7
8text = """
9INSTRUCTION:
10Gebt mir drei Adjektive, um dieses Foto zu beschreiben.
11INPUT:
12[photo]
13OUTPUT:
14Auffällig, lebhaft, ruhig.
15"""
16model.predict([text])BAD INSTRUCTIONpython -m pip install setfit1from datasets import Dataset, load_dataset
2
3import pandas as pd
4
5# this can be a translation (e.g., Spanish, Camoscio Italian Alpaca, etc.)
6dataset = pd.read_json("https://github.com/gururise/AlpacaDataCleaned/raw/main/alpaca_data_cleaned.json")
7
8dataset["id"] = [i for i in range(len(dataset))]
9
10ds = Dataset.from_pandas(dataset)1def transform(r):
2 return {
3 "text": f"INSTRUCTION:\n{r['instruction']}\nINPUT:\n{r['input']}\nOUTPUT:\n{r['output']}\n"
4 }
5ds = ds.map(transform)1from setfit import SetFitModel
2
3# Download from Hub
4model = SetFitModel.from_pretrained("argilla/alpaca-garbage-collector-multilingual")1labels = ["ALL GOOD", "BAD INSTRUCTION"]
2
3def get_predictions(texts):
4 probas = model.predict_proba(texts, as_numpy=True)
5 for pred in probas:
6 yield [{"label": label, "score": score} for label, score in zip(labels, pred)]
7
8ds = ds.map(lambda batch: {"prediction": list(get_predictions(batch["text"]))}, batched=True)1# Replace api_url with the url to your HF Spaces URL if using Spaces
2# Replace api_key if you configured a custom API key
3rg.init(
4 api_url="https://your-agilla-instance.hf.space",
5 api_key="team.apikey"
6)
7
8rg_dataset = rg.DatasetForTextClassification().from_datasets(ds)
9rg.log(records=rg_dataset, name="alpaca_to_clean")BAD INSTRUCTION.


1@article{https://doi.org/10.48550/arxiv.2209.11055,
2doi = {10.48550/ARXIV.2209.11055},
3url = {https://arxiv.org/abs/2209.11055},
4author = {Tunstall, Lewis and Reimers, Nils and Jo, Unso Eun Seo and Bates, Luke and Korat, Daniel and Wasserblat, Moshe and Pereg, Oren},
5keywords = {Computation and Language (cs.CL), FOS: Computer and information sciences, FOS: Computer and information sciences},
6title = {Efficient Few-Shot Learning Without Prompts},
7publisher = {arXiv},
8year = {2022},
9copyright = {Creative Commons Attribution 4.0 International}
10}