In [4]: remote_datasets["train"][0]Out[4]: {'act': 'Linux Terminal',
'prompt': 'I want you to act as a linux terminal. I will type commands and you will reply with what the terminal should show. I want you to only reply with the terminal output inside one unique code block, and nothing else. do not write explanations. do not type commands unless I instruct you to do so. when i need to tell you something in english, i will do so by putting text inside curly brackets {like this}. my first command is pwd'}
随机选取数据
1
2
3
4
5
6
In [5]: remote_datasets["train"].select(range(10))Out[5]:
Dataset({ features: ['act', 'prompt'],
num_rows: 10})
In [7]: new_datasets.filter(lambda x: "Linux" in x["actor"])Out[7]:
DatasetDict({ train: Dataset({ features: ['actor', 'prompt'],
num_rows: 1})})
map 处理数据
1
2
3
4
In [8]: new_datasets.map(lambda x: {"actor": x["actor"].upper(), "prompt": x["prompt"]})["train"][0]Out[8]:
{'actor': 'LINUX TERMINAL',
'prompt': 'I want you to act as a linux terminal. I will type commands and you will reply with what the terminal should show. I want you to only reply with the terminal output inside one unique code block, and nothing else. do not write explanations. do not type commands unless I instruct you to do so. when i need to tell you something in english, i will do so by putting text inside curly brackets {like this}. my first command is pwd'}
sort 排序
1
2
3
4
In [9]: new_datasets.sort("actor")["train"][0]Out[9]:
{'actor': 'AI Assisted Doctor',
'prompt': 'I want you to act as an AI assisted doctor. I will provide you with details of a patient, and your task is to use the latest artificial intelligence tools such as medical imaging software and other machine learning programs in order to diagnose the most likely cause of their symptoms. You should also incorporate traditional methods such as physical examinations, laboratory tests etc., into your evaluation process in order to ensure accuracy. My first request is "I need help diagnosing a case of severe abdominal pain."'}
shuffle 乱序
1
2
3
4
In [10]: new_datasets.shuffle(seed=42)["train"][0]Out[10]:
{'actor': 'Tech Reviewer:',
'prompt': 'I want you to act as a tech reviewer. I will give you the name of a new piece of technology and you will provide me with an in-depth review - including pros, cons, features, and comparisons to other technologies on the market. My first suggestion request is "I am reviewing iPhone 11 Pro Max".'}
随机选取数据
1
2
3
4
5
6
In [11]: new_datasets.shuffle(seed=42)["train"].select(range(10))Out[11]:
Dataset({ features: ['actor', 'prompt'],
num_rows: 10})