I have a huggingface dataset named yuntian-deng/WildChat-1M-internal. There’s a field…
- User
I have a huggingface dataset named yuntian-deng/WildChat-1M-internal. There’s a field conversation, which is a list of dictionaries (turns), and each dictionary contains a “role” field which can be “user” or “assistant”, and a “content” field which is a string. I want to count how many turns out of how many total turns have an empty string as content, and also how many conversations contain empty user turns.
- Assistant
To achieve your goals, you will first need to load the dataset from the Hugging Face Hub and then iterate over it to perform your specific calculations. Here's a step-by-step guide on how to do this using the Hugging Face
datasetslibrary in Python.Step 1: Install the necessary library
If you haven't already, you need to install the
datasetslibrary from Hugging Face. You can do this via pip:pip install datasetsStep 2: Load the dataset
You can load your dataset using the
load_datasetfunction provided by the Hugging Facedatasetslibrary:from datasets import load_dataset dataset = load_dataset("yuntian-deng/WildChat-1M-internal")Note: If the dataset is not public or requires authentication, make sure you have the appropriate permissions or an API key to access it.
Step 3: Count the required turns and conversations
Now, iterate through the dataset to calculate the number of turns with empty content, and the number of conversations that contain at least one empty user turn.
empty_turns_count = 0 total_turns_count = 0 conversations_with_empty_user_turns = 0 for conversation in dataset['train']: # Assuming you are working with the training split empty_user_turn_found = False for turn in conversation['conversation']: # Count total turns total_turns_count += 1 # Check if the turn content is empty if turn['content'] == "": empty_turns_count += 1 if turn['role'] == "user": empty_user_turn_found = True # If at least one empty user turn was found in the conversation if empty_user_turn_found: conversations_with_empty_user_turns += 1 print(f"Total turns: {total_turns_count}") print(f"Empty content turns: {empty_turns_count}") print(f"Conversations with at least one empty user turn: {conversations_with_empty_user_turns}")Make sure to adjust
['train']indataset['train']to the correct split you are working with, such as'test'or'validation', if needed.This code counts the total number of turns, the number of turns with empty content, and the number of conversations that include at least one turn with empty content from the user.
Keep in mind that the dataset name, structure, or the field names may differ, so adjust the code accordingly if the dataset structure is different from what you described.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.