huseinzol05
commited on
Commit
•
098b793
1
Parent(s):
406bcf3
Upload 2 files
Browse files- motomalaysia-chat.json +0 -0
- motomalaysia-multiturn.ipynb +156 -0
motomalaysia-chat.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
motomalaysia-multiturn.ipynb
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 3,
|
6 |
+
"id": "a0cd5176",
|
7 |
+
"metadata": {},
|
8 |
+
"outputs": [],
|
9 |
+
"source": [
|
10 |
+
"# !wget https://huggingface.co/datasets/malaysia-ai/motomalaysia.com-multiturn/resolve/main/motomalaysia-data.jsonl.translated\n",
|
11 |
+
"# !wget https://huggingface.co/datasets/malaysia-ai/motomalaysia.com-multiturn/resolve/main/motomalaysia-data.jsonl"
|
12 |
+
]
|
13 |
+
},
|
14 |
+
{
|
15 |
+
"cell_type": "code",
|
16 |
+
"execution_count": 4,
|
17 |
+
"id": "b94471a6",
|
18 |
+
"metadata": {},
|
19 |
+
"outputs": [],
|
20 |
+
"source": [
|
21 |
+
"import json"
|
22 |
+
]
|
23 |
+
},
|
24 |
+
{
|
25 |
+
"cell_type": "code",
|
26 |
+
"execution_count": 5,
|
27 |
+
"id": "a69c193d",
|
28 |
+
"metadata": {},
|
29 |
+
"outputs": [],
|
30 |
+
"source": [
|
31 |
+
"with open('motomalaysia-data.jsonl') as fopen:\n",
|
32 |
+
" for l in fopen:\n",
|
33 |
+
" l = json.loads(l)\n",
|
34 |
+
" break"
|
35 |
+
]
|
36 |
+
},
|
37 |
+
{
|
38 |
+
"cell_type": "code",
|
39 |
+
"execution_count": 9,
|
40 |
+
"id": "2907e6bd",
|
41 |
+
"metadata": {},
|
42 |
+
"outputs": [
|
43 |
+
{
|
44 |
+
"data": {
|
45 |
+
"text/plain": [
|
46 |
+
"'\\n{\"image\": \"pic/0.jpg\", \"conversations\": [{\"role\": \"user\", \"content\": \"<image>Ini makanan apa?\"}, {\"role\": \"assistant\", \"content\": \"Ini ialah Kuih Siput.\"},\\n'"
|
47 |
+
]
|
48 |
+
},
|
49 |
+
"execution_count": 9,
|
50 |
+
"metadata": {},
|
51 |
+
"output_type": "execute_result"
|
52 |
+
}
|
53 |
+
],
|
54 |
+
"source": [
|
55 |
+
"\"\"\"\n",
|
56 |
+
"{\"image\": \"pic/0.jpg\", \"conversations\": [{\"role\": \"user\", \"content\": \"<image>Ini makanan apa?\"}, {\"role\": \"assistant\", \"content\": \"Ini ialah Kuih Siput.\"},\n",
|
57 |
+
"\"\"\""
|
58 |
+
]
|
59 |
+
},
|
60 |
+
{
|
61 |
+
"cell_type": "code",
|
62 |
+
"execution_count": 21,
|
63 |
+
"id": "41632e47",
|
64 |
+
"metadata": {},
|
65 |
+
"outputs": [],
|
66 |
+
"source": [
|
67 |
+
"chats = []\n",
|
68 |
+
"with open('motomalaysia-data.jsonl.translated') as fopen:\n",
|
69 |
+
" for l in fopen:\n",
|
70 |
+
" l = json.loads(l)\n",
|
71 |
+
" overview = l['specs']['overview_translated']\n",
|
72 |
+
" overview = [s for s in overview if s]\n",
|
73 |
+
" overview = '\\n'.join(overview)\n",
|
74 |
+
" spec = '\\n'.join(l['specs']['specs'])\n",
|
75 |
+
" conversations = []\n",
|
76 |
+
" conversations.extend([\n",
|
77 |
+
" {\"role\": \"user\", \"content\": \"<image>Ini model apa?\"},\n",
|
78 |
+
" {\"role\": \"assistant\", \"content\": l['specs']['model_name']},\n",
|
79 |
+
" ])\n",
|
80 |
+
" if len(overview):\n",
|
81 |
+
" conversations.extend([\n",
|
82 |
+
" {\"role\": \"user\", \"content\": \"apa kelebihan moto tu?\"},\n",
|
83 |
+
" {\"role\": \"assistant\", \"content\": overview},\n",
|
84 |
+
" ])\n",
|
85 |
+
" conversations.extend([\n",
|
86 |
+
" {\"role\": \"user\", \"content\": \"apa spesifikasi moto tu?\"},\n",
|
87 |
+
" {\"role\": \"assistant\", \"content\": spec},\n",
|
88 |
+
" ])\n",
|
89 |
+
" chats.append({\n",
|
90 |
+
" 'image': l['local_image'],\n",
|
91 |
+
" 'image_url': l['img_url'],\n",
|
92 |
+
" 'conversations': conversations\n",
|
93 |
+
" })"
|
94 |
+
]
|
95 |
+
},
|
96 |
+
{
|
97 |
+
"cell_type": "code",
|
98 |
+
"execution_count": 23,
|
99 |
+
"id": "94cd0f04",
|
100 |
+
"metadata": {},
|
101 |
+
"outputs": [
|
102 |
+
{
|
103 |
+
"data": {
|
104 |
+
"text/plain": [
|
105 |
+
"{'image': 'pic/Yamaha NMAX (2016)_1.jpg',\n",
|
106 |
+
" 'image_url': 'https://www.motomalaysia.com/wp-content/uploads/2017/10/yamaha-nmax-2.jpg',\n",
|
107 |
+
" 'conversations': [{'role': 'user', 'content': '<image>Ini model apa?'},\n",
|
108 |
+
" {'role': 'assistant', 'content': 'Yamaha NMAX (2016)'},\n",
|
109 |
+
" {'role': 'user', 'content': 'apa spesifikasi moto tu?'},\n",
|
110 |
+
" {'role': 'assistant',\n",
|
111 |
+
" 'content': 'Manufacturer: Yamaha\\nModel: 2016\\nGeneration: \\nYamaha NMAX (2016)\\n\\nType: Scooter\\nColour Available: \\n\\n Grey\\n Red\\n\\n\\nDimension: 1,955 x 740 x 1,115 mm\\nWheelbase: 1,350 mm\\nWeight: 136 kg\\nSeat Height: 765 mm\\nGround Clearance: 135 mm\\nMeter Display: \\n\\nDigital - Speedometer, Fuel Gauge\\n\\n\\nEngine: 4-Stroke, SOHC\\nDisplacement: 155 CC\\nNo Of Cylinders: 1-Cylinder\\nCompression Ratio: 10.5 : 1\\nBore x Stroke: 58mm x 58.7mm\\nMax Power: 11.1 kW @ 8,000 RPM\\nMax Torque: 14.4 Nm @ 6,000 RPM\\nMax Speed: -\\nTransmission: Automatic, CVT\\nClutch: Dry, centrifugal, Shoe\\nIgnition System: Transistor Coil Ignition (TCI)\\nStarting System: Electric Starter\\nCooling System: Liquid Cooled\\nCarburetor: -\\nFuel System: Fuel Injection\\nFuel Capacity: 6.6 Liters\\nFuel Consumption: -\\nOil Capacity: 1.0 Liters\\nFeatures: -\\nType: Underbone\\nFront Suspension: Telescopic\\nRear Suspension: Unit Swing\\nFront Brake: Disc\\nRear Brake: Disc\\nFront Tire: 110/70-13\\nRear Tire: 130/70-13\\nFront Wheel: -\\nRear Wheel: -\\nUnder Seat Box: -'}]}"
|
112 |
+
]
|
113 |
+
},
|
114 |
+
"execution_count": 23,
|
115 |
+
"metadata": {},
|
116 |
+
"output_type": "execute_result"
|
117 |
+
}
|
118 |
+
],
|
119 |
+
"source": [
|
120 |
+
"chats[-2]"
|
121 |
+
]
|
122 |
+
},
|
123 |
+
{
|
124 |
+
"cell_type": "code",
|
125 |
+
"execution_count": 24,
|
126 |
+
"id": "75464efe",
|
127 |
+
"metadata": {},
|
128 |
+
"outputs": [],
|
129 |
+
"source": [
|
130 |
+
"with open('motomalaysia-chat.json', 'w') as fopen:\n",
|
131 |
+
" json.dump(chats, fopen)"
|
132 |
+
]
|
133 |
+
}
|
134 |
+
],
|
135 |
+
"metadata": {
|
136 |
+
"kernelspec": {
|
137 |
+
"display_name": "Python 3 (ipykernel)",
|
138 |
+
"language": "python",
|
139 |
+
"name": "python3"
|
140 |
+
},
|
141 |
+
"language_info": {
|
142 |
+
"codemirror_mode": {
|
143 |
+
"name": "ipython",
|
144 |
+
"version": 3
|
145 |
+
},
|
146 |
+
"file_extension": ".py",
|
147 |
+
"mimetype": "text/x-python",
|
148 |
+
"name": "python",
|
149 |
+
"nbconvert_exporter": "python",
|
150 |
+
"pygments_lexer": "ipython3",
|
151 |
+
"version": "3.8.10"
|
152 |
+
}
|
153 |
+
},
|
154 |
+
"nbformat": 4,
|
155 |
+
"nbformat_minor": 5
|
156 |
+
}
|