ระบบแปลงภาษาธรรมชาติเป็น SQL โดยใช้ ChatGPT
คำสำคัญ:
ภาษาธรรมชาติเป็น SQL, โมเดลภาษาใหญ่, ฐานข้อมูล, ChatGPTบทคัดย่อ
งานวิจัยนี้นำเสนอการพัฒนาและประเมินระบบต้นแบบที่สามารถแปลงข้อความภาษาธรรมชาติภาษาไทยให้เป็นคำสั่ง SQL ได้อย่างแม่นยำ โดยอาศัยความสามารถของโมเดลภาษาขนาดใหญ่ (Large Language Model: LLM) ที่ออกแบบในรูปแบบ My GPTs บนแพลตฟอร์ม ChatGPT ซึ่งเชื่อมต่อกับระบบฐานข้อมูล MySQL จริงผ่าน Web API ผู้ใช้งานสามารถสอบถามข้อมูลด้วยภาษาธรรมชาติผ่านอินเทอร์เฟซแบบโต้ตอบ และระบบจะทำหน้าที่แปลงข้อความเป็นคำสั่ง SQL ส่งไปยังฐานข้อมูล และแสดงผลลัพธ์กลับมาในรูปแบบตาราง ผลการประเมินดำเนินการผ่านชุดคำถามจำนวน 30 ข้อ ผลการทดลองพบว่า ระบบมีความถูกต้องของคำสั่ง SQL เฉลี่ยร้อยละ 90.00 ความสมบูรณ์ของการทำงานร้อยละ 100.00 และเวลาเฉลี่ยในการตอบกลับ 0.0045 วินาทีต่อคำถาม สะท้อนถึงศักยภาพของระบบในการนำไปประยุกต์ใช้ในงานจริง โดยเฉพาะในบริบทที่ต้องการเข้าถึงข้อมูลจากฐานข้อมูลด้วยวิธีที่สะดวก รวดเร็ว และไม่ต้องอาศัยความรู้ด้านเทคนิค
เอกสารอ้างอิง
Cagliero, L., Farinetti, L., Fior, J., & Manenti, A. I. (2024). ChatGPT, be my teaching assistant! automatic correction of SQL exercises. In L. O’Conner (Ed.), 2024 IEEE 48th Annual Computers, Software, and Applications Conference (COMPSAC) (pp. 81–86). IEEE.
Carr, N., Shawon, F. R., & Jamil, H. M. (2023). An experiment on leveraging ChatGPT for online teaching and assessment of database students. In M. Kuo & R. Sinha (Eds.), 2023 IEEE International Conference on Teaching, Assessment and Learning for Engineering (TALE) (pp. 1–8). IEEE.
Deshpande, A., Mane, P., Kothari, D., Salvi, A., & Kolhe, V. (2022). Querylizer: An interactive platform for database design and text to SQL conversion. In S. A. Thorat, A. Adamuthe & D. Gupta (Eds.), Proceedings of the International Conference on Advanced Technology (ICONAT) (pp. 1–6). IEEE.
Lan, Z., & Li, S. (2024). PS-SQL: Phrase-based schema-linking with pre-trained language models for Text-to-SQL parsing. In E. X. Wang & R. Minasian (Eds.), Proceedings of the 6th International Conference on Natural Language Processing (ICNLP) (pp. 31–34). IEEE.
Liu, S., Almohaimeed, S., & Wang, L. (2025). REFORMER: A ChatGPT-driven data synthesis framework elevating Text-to-SQL models. arXiv:2504.04363v1. https://doi.org/10.48550/arXiv.2504.04363
MySQLTutorial.org. (2025). MySQL sample database. https://www.mysqltutorial.org/getting-started-with-mysql/mysql-sample-database/
Nilsiam, Y., Khammaw, P., & Nuchitprasitchai, S. (2025). OpenAI-powered NLP for SQL generation: En hancing database access for non-technical users [In Thai]. In K. Chaiwong (Ed.), The 10th International Conference on Digital Arts, Media and Technology (DAMT) and 8th ECTI Northern Section Conference on Electrical, Electronics, Computer and Telecommunications Engineering (NCON) (pp. 423–428). IEEE.
Ning, Z., Zhang, D., Zhang, L., Yu, H., & Wan, F. (2022). Review of question answering technology based on Text-to-SQL. Proceedings of the IEEE International Conference on Computer Science Education and Informatization (CSEI) (pp. 167–172). IEEE.
OpenAI. (2022). Introducing ChatGPT. https://openai.com/index/chatgpt
OpenAI. (2023). Creating a GPT. https://help.openai.com/en/articles/8554397-creating-a-gpt
Pornphol, P., & Chittayasothorn, S. (2023). Verification of relational database languages codes generated by ChatGPT. In Y. Watanobe, G. Mogos & M. Rahman (Eds.), Proceedings of the 4th Asia Service Science and Software Engineering Conference (ASSE) (pp. 17–22). ACM.
Pornphol, P., & Chittayasothorn, S. (2024). Using LLM artificial intelligence systems as complex SQL programming assistants. In S. Yamaguchi & N. Funabiki (Eds.), Proceedings of the 12th International Conference on Information and Education Technology (ICIET) (pp. 187–190). IEEE.
Shen, H., Sun, G., Wang, Y., Shen, R., Li, Y., & Zhang, P. (2023). Sequential feature augmentation for robust Text-to-SQL. In L. Trinh (Ed.), Proceedings of the International Conference on Algorithms, Computing and Data Processing (ACDP) (pp. 217–221). IEEE.
Srisuruk, T., & Chittayasothorn, S. (2023). An approach for rapid source code development based on ChatGPT and prompt engineering. IEEE Access, 12, 53074–53087. https://doi.org/10.1109/ACCESS.2024.3385682
