File size: 5,963 Bytes
702a59c |
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 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "038bc3c5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"--2024-01-24 11:38:58-- https://huggingface.co/datasets/malaysia-ai/wapcar.my-multiturn/resolve/main/car-data.jsonl\n",
"Resolving huggingface.co (huggingface.co)... 18.67.181.100, 18.67.181.124, 18.67.181.126, ...\n",
"Connecting to huggingface.co (huggingface.co)|18.67.181.100|:443... connected.\n",
"HTTP request sent, awaiting response... 302 Found\n",
"Location: https://cdn-lfs-us-1.huggingface.co/repos/07/d1/07d149676aba72bd90f1000b4e614862bc90bbc57dd87efe07fd394dde768338/b3aebea7f9602157aeb5059acc66240079b02141ea5a39cf1ceb2ece25fa8a85?response-content-disposition=attachment%3B+filename*%3DUTF-8%27%27car-data.jsonl%3B+filename%3D%22car-data.jsonl%22%3B&Expires=1706326739&Policy=eyJTdGF0ZW1lbnQiOlt7IkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTcwNjMyNjczOX19LCJSZXNvdXJjZSI6Imh0dHBzOi8vY2RuLWxmcy11cy0xLmh1Z2dpbmdmYWNlLmNvL3JlcG9zLzA3L2QxLzA3ZDE0OTY3NmFiYTcyYmQ5MGYxMDAwYjRlNjE0ODYyYmM5MGJiYzU3ZGQ4N2VmZTA3ZmQzOTRkZGU3NjgzMzgvYjNhZWJlYTdmOTYwMjE1N2FlYjUwNTlhY2M2NjI0MDA3OWIwMjE0MWVhNWEzOWNmMWNlYjJlY2UyNWZhOGE4NT9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPSoifV19&Signature=buN8EGWarhSh0LXreNIvGRqlHZbRaxvH0INuQ-v7eOMq%7Evm0Uz7w9C4fg5A7lOjeJAQJ%7E6%7EzPnOC-aNyEiOW1xpWPbfH6C0cTkn5v4T4cS7YABtaSVWmGAC-DIGRxMgmpDoSXXoz7F-9sct4cDASa676H09LIMmZuExkbg9LLbQPJscewXExPoOhlZFo%7EvzA3LzBE-0GneewvdZJXeVuOwb%7EY4J0Jd9ObOJaJI5aP-ObpVhurwR9OrSQ0U51AdJxAS5oq-j49wnMFey-3uGFZa06Pf57W6mEAE3Lk6Jogqec1H7FAScZZBnVrmyidQSZ6r%7E-an7XNF-xatr2ncdrtQ__&Key-Pair-Id=KCD77M1F0VK2B [following]\n",
"--2024-01-24 11:38:59-- https://cdn-lfs-us-1.huggingface.co/repos/07/d1/07d149676aba72bd90f1000b4e614862bc90bbc57dd87efe07fd394dde768338/b3aebea7f9602157aeb5059acc66240079b02141ea5a39cf1ceb2ece25fa8a85?response-content-disposition=attachment%3B+filename*%3DUTF-8%27%27car-data.jsonl%3B+filename%3D%22car-data.jsonl%22%3B&Expires=1706326739&Policy=eyJTdGF0ZW1lbnQiOlt7IkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTcwNjMyNjczOX19LCJSZXNvdXJjZSI6Imh0dHBzOi8vY2RuLWxmcy11cy0xLmh1Z2dpbmdmYWNlLmNvL3JlcG9zLzA3L2QxLzA3ZDE0OTY3NmFiYTcyYmQ5MGYxMDAwYjRlNjE0ODYyYmM5MGJiYzU3ZGQ4N2VmZTA3ZmQzOTRkZGU3NjgzMzgvYjNhZWJlYTdmOTYwMjE1N2FlYjUwNTlhY2M2NjI0MDA3OWIwMjE0MWVhNWEzOWNmMWNlYjJlY2UyNWZhOGE4NT9yZXNwb25zZS1jb250ZW50LWRpc3Bvc2l0aW9uPSoifV19&Signature=buN8EGWarhSh0LXreNIvGRqlHZbRaxvH0INuQ-v7eOMq%7Evm0Uz7w9C4fg5A7lOjeJAQJ%7E6%7EzPnOC-aNyEiOW1xpWPbfH6C0cTkn5v4T4cS7YABtaSVWmGAC-DIGRxMgmpDoSXXoz7F-9sct4cDASa676H09LIMmZuExkbg9LLbQPJscewXExPoOhlZFo%7EvzA3LzBE-0GneewvdZJXeVuOwb%7EY4J0Jd9ObOJaJI5aP-ObpVhurwR9OrSQ0U51AdJxAS5oq-j49wnMFey-3uGFZa06Pf57W6mEAE3Lk6Jogqec1H7FAScZZBnVrmyidQSZ6r%7E-an7XNF-xatr2ncdrtQ__&Key-Pair-Id=KCD77M1F0VK2B\n",
"Resolving cdn-lfs-us-1.huggingface.co (cdn-lfs-us-1.huggingface.co)... 18.161.180.103, 18.161.180.118, 18.161.180.25, ...\n",
"Connecting to cdn-lfs-us-1.huggingface.co (cdn-lfs-us-1.huggingface.co)|18.161.180.103|:443... connected.\n",
"HTTP request sent, awaiting response... 200 OK\n",
"Length: 199822581 (191M) [binary/octet-stream]\n",
"Saving to: ‘car-data.jsonl’\n",
"\n",
"car-data.jsonl 100%[===================>] 190.57M 20.2MB/s in 9.7s \n",
"\n",
"2024-01-24 11:39:09 (19.7 MB/s) - ‘car-data.jsonl’ saved [199822581/199822581]\n",
"\n"
]
}
],
"source": [
"!wget https://huggingface.co/datasets/malaysia-ai/wapcar.my-multiturn/resolve/main/car-data.jsonl"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "efe6cb33",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"51136"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import json\n",
"\n",
"data = []\n",
"with open('car-data.jsonl') as fopen:\n",
" for l in fopen:\n",
" l = json.loads(l)\n",
" data.append(l)\n",
"len(data)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "586f62bf",
"metadata": {},
"outputs": [],
"source": [
"chats = []\n",
"for d in data:\n",
" name = d['specs'][0].split(':')[1].strip()\n",
" specs = [r.strip() for r in d['specs'][1:]]\n",
" conversations = [\n",
" {\"role\": \"user\", \"content\": \"<image>Ini model apa?\"},\n",
" {\"role\": \"assistant\", \"content\": name},\n",
" {\"role\": \"user\", \"content\": \"apa spesifikasi kereta tu?\"},\n",
" {\"role\": \"assistant\", \"content\": specs},\n",
" ]\n",
" chats.append({\n",
" 'image': d['local_image'],\n",
" 'image_url': d['img_url'],\n",
" 'conversations': conversations\n",
" })"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "7602a37a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"51136"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(chats)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"id": "d47f3bcc",
"metadata": {},
"outputs": [],
"source": [
"with open('wapcar-chat.json', 'w') as fopen:\n",
" json.dump(chats, fopen)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
|