huggingface / setfit

Efficient few-shot learning with Sentence Transformers
https://hf.co/docs/setfit
Apache License 2.0
2.24k stars 222 forks source link

The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() #524

Open ya-stack opened 6 months ago

ya-stack commented 6 months ago

I am facing below error while training SetFit model - I am trying to predict each pipe separated labels as a single class, this is how first record of training dataset looks like -

text: Powell Kilbuck Solid Wood 3 Doors and 2 Adjustable Shelves Accent Cabinet Navy, Elevate the ambiance of your living space with the Kilbuck Navy Solid Wood Three Door Accent Cabinet from Powell. Immerse yourself in the captivating allure of its refined bohemian style, where intricate fretwork adorns the front panels, exuding expressive charm. This cabinet isn't just a piece of furniture; it's a statement of versatile functionality. With three separate doors swinging open to reveal two spacious interiors, storage dilemmas become a thing of the past. Whether you envision it as a TV stand, dining room sideboard, or entryway lamp stand, its adaptability makes it a seamless addition to any room. Crafted with meticulous attention to detail, this accent cabinet boasts not only aesthetic appeal but also robust durability. Its solid wood frame and birch veneer construction ensure longevity, promising years of reliable service. The luminous navy finish adds a touch of timeless elegance, effortlessly blending with any color scheme or decor style. Black metal door handles not only provide ease of use but also serve as subtle accents, enhancing the cabinet's overall aesthetic. Magnetic latches keep the doors securely shut, offering peace of mind and convenience in equal measure.This versatile piece is designed to save space without compromising on functionality. Assembly is a breeze, requiring only the attachment of legs upon arrival. Whether you're seeking storage solutions for your living room, dining area, or hallway, the Kilbuck Navy Solid Wood Three Door Accent Cabinet stands ready to meet your needs with its blend of style, versatility, and durability. Redefine your living space today with this exquisite addition from Powell.Overall Width: 39” Overall Depth: 15”Overall Height: 35”

label: [1, 0]

label text: FURNITURE|cabinets, shelving and storage|Decorative Cabinets, Drawers and Trunks|Decorative Storage Cabinets

ERROR: File ~/.local/lib/python3.10/site-packages/setfit/sampler.py:68, in ContrastiveDataset.init(self, examples, multilabel, num_iterations, sampling_strategy, max_pairs) 66 self.generate_multilabel_pairs() 67 else: ---> 68 self.generate_pairs() 70 if num_iterations is not None and num_iterations > 0: 71 self.len_pos_pairs = num_iterations * len(self.sentences)

File ~/.local/lib/python3.10/site-packages/setfit/sampler.py:91, in ContrastiveDataset.generate_pairs(self) 89 def generate_pairs(self) -> None: 90 for (_text, _label), (text, label) in shuffle_combinations(self.sentence_labels): ---> 91 if _label == label: 92 self.pos_pairs.append(InputExample(texts=[_text, text], label=1.0)) 93 else:

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Also, there are no duplicates across train and test dataset. I have 2 labels - FURNITURE|cabinets, shelving and storage|Decorative Cabinets, Drawers and Trunks|Decorative Storage Cabinets 1675 HOME|BEDDING|top of bed|Bed Tents and Canopies 8

Can you please help me to resolve it ?