{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "142dbd98-d2ac-47d0-98e8-8b95f2ab34f3", "metadata": { "tags": [] }, "outputs": [], "source": [ "from pythainlp.generate.wangchanglm import WangChanGLM\n", "import torch" ] }, { "cell_type": "code", "execution_count": 2, "id": "0f8ed6b5-6f4c-4d99-a046-9d2c8e1bcd0d", "metadata": { "tags": [] }, "outputs": [], "source": [ "m=WangChanGLM()" ] }, { "cell_type": "code", "execution_count": 3, "id": "78a1ff09-7302-415d-8715-5a0e07a9ff2c", "metadata": { "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Setting ds_accelerator to cuda (auto detect)\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "37ab5d0007e3490ca319760b421c47ca", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Downloading shards: 0%| | 0/98 [00:00: ขอวิธีทำข้าวผัดหน่อย\\n: ')" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "m.instruct_generate(instruct=\"ขอวิธีทำข้าวผัดหน่อย\")" ] }, { "cell_type": "code", "execution_count": 5, "id": "d4fbd1e6-8a41-4b46-aa12-a23f8df9bcb0", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/plain": [ "('ข้าวผัดน้ําพริกลงเรือ', ': ขอวิธีทำข้าวผัดหน่อย\\n: ')" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "m.instruct_generate(instruct=\"ขอวิธีทำข้าวผัดหน่อย\")" ] }, { "cell_type": "code", "execution_count": 6, "id": "fe71b834-4f12-406e-8a74-41829d8a7d9d", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/plain": [ "('เป้าหมายของคุณคือการลดน้ําหนักหรือไม่?', ': ขอลดน้ำหนัก\\n: ')" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "m.instruct_generate(instruct=\"ขอลดน้ำหนัก\")" ] }, { "cell_type": "code", "execution_count": 7, "id": "2cd5063d-21b6-40fb-8e4e-c54fb07ac613", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/plain": [ "('ลดน้ําหนักให้ได้ผล ต้องทําอย่างค่อยเป็นค่อยไป ปรับเปลี่ยนพฤติกรรมการกินอาหาร ออกกําลังกายอย่างสม่ําเสมอ และพักผ่อนให้เพียงพอ ที่สําคัญควรหลีกเลี่ยงอาหารที่มีแคลอรี่สูง เช่น อาหารทอด อาหารมัน อาหารที่มีน้ําตาลสูง และเครื่องดื่มแอลกอฮอล์',\n", " ': ขอวิธีลดน้ำหนัก\\n: ')" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "m.instruct_generate(instruct=\"ขอวิธีลดน้ำหนัก\")" ] }, { "cell_type": "code", "execution_count": null, "id": "b5b54b24-59b8-400e-89ff-0b8b67dce71f", "metadata": {}, "outputs": [], "source": [] } ], "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 }