{ "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\": \"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 }