forked from HongyuanLuke/frequencylaw
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreaddata.py
More file actions
32 lines (23 loc) · 767 Bytes
/
readdata.py
File metadata and controls
32 lines (23 loc) · 767 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
os.environ['HF_HOME'] = '/data/.cache'
os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
from PIL import Image
import huggingface_hub
huggingface_hub.login("####")
data_name='your_dataset_name'
from datasets import load_dataset
try:
your_dataset = load_dataset(data_name, split='validation')
print('success')
except Exception as e:
print(f"load error: {e}")
exit()
questions = your_dataset['question']
with open('dataset_name.txt', 'w', encoding='utf-8') as f:
for question in questions:
question_cleaned = question.replace('\n', ' ').strip()
f.write(question_cleaned + '\n')
print("save success!")