SuiGPT

Through tailored Prompt Engineering, SuiGPT empowers GPT-4 to be proficient in the Move language, enabling it to generate corresponding Move code based on user instructions. It can be used through the GPTutor interface, and its API to get Prompt by user instruction is available on the Web. The website version is coming soon.

Slides link (Pitch Deck)

Click me to Download GPTutor and try SuiGPT in Visual Studio Code IDE

Introduction

SuiGPT is a product developed by Eason during Taipei Blockchain Week’s hackathon. This is a follow up work of GPTutor.

While Large Language Models (LLMs), such as GPT-4, are incredibly powerful, they lack knowledge of Sui Move in their training data, resulting in their unfamiliarity with the syntax and writing style of Sui Move.

image

Just like a black and white cat among penguins. If you ask ChatGPT to generate Sui Move, it will indeed generate code that seems to make some sense. However, this code is not compile-ready and does not adhere to the Move language standard. We call this effect Hallucination in Natural Language Generation research.

image

Nevertheless, We believe that by providing Sui-Move examples through prompts, LLMs can generate Sui-Move code accurately without Hallucination. This is because LLMs could reference existing Sui-Move code to generate Sui-Move with the correct syntax.

image image

How does it work?

SuiGPT collected Move codes from the official Sui example codes, annotated them, and stored them in a database. These annotated Sui Move code snippets include function parameter names marked by the Sui-Move Analyzer and the Comments generated by GPT-4.

When users want to create a Move smart contract with SuiGPT, SuiGPT will provide relevant code snippets in prompts for GPT to reference. By doing so, SuiGPT can integrate various existing and executable Move contract functionalities, creating personalized new contracts for users.

image

Finished Milestones

During the Taipei Blockchain Week hackathon, we accomplished the following four parts:

  1. Annotated Move by Sui-Move Analyzer and LLMs
  2. Create Dataset: Process 68 move files with GPT to add comments and store them in a database
  3. Create Prompt: By user’s input, query similar Move codes and assemble them to create a prompt for LLMs to reference.
  4. Integrated SuiGPT into GPTutor.

All the above are open-source and available by Web API.

1. Annotated Move Code by Sui-Move Analyzer and add Comment and Summary by LLMs

We use Sui-Move Analyzer to add type annotations to the Move code. Then, we utilize LLMs to annotate and summarize the code.

The annotation API is available at https://move-annotate-backend.gptutor.tools/api/docs. Moreover, the source code of the annotation API is available at GPTutor/sui-move-annotation.

Moreover, SuiGPT’s Sui-Move annotation also supports the smart contract from the Bucket Protocol, allowing users to generate smart contract applications that call the Bucket Protocol endpoints using SuiGPT.

image

2. Create Dataset

We collected 68 move files from Sui’s official example code. After processing them through step one, we saved them in the ElasticSearch database, and the processed data can be downloaded here.

The source code of data processing and database creation is available at GPTutor/SuiGPT-backend.

3. Create Prompt

By the users’ input about what kinds of Move contracts they want to write, SuiGPT prompt creation backend will query similar Move codes by ElasticSearch’s “more like this” query. Then, pick the top 3 matched codes and assemble them in a prompt for LLMs to reference.

For example, if a user says they want to create a fungible coin with an airdrop feature, the backend will query Elasticsearch and find the following Move smart contract with top similarity scores: Managed Fungible Tokens, Cross-Chain Airdrops of NFTs. Then, SuiGPT API will create a prompt including these codes so LLMs can synthesize them to create a fusion of new Move contracts to fit the user’s needs.

The prompt creation API is available at https://backend.suigpt.gptutor.tools/api/docs, and its source code is at GPTutor/SuiGPT-backend.

image

4. Integrated SuiGPT into GPTutor

We integrated SuiGPT with GPTutor. GPTutor is a Visual Studio Code extension that enables users to use OpenAI’s GPT models for code explanations, comments, and reviews. One of GPTutor’s standout features is its open-source nature, which grants users the flexibility to customize their prompts. By dynamically querying prompts created by SuiGPT through the API into GPTutor, GPTutor is now able to compose Sui-Move according to users’ instructions.

Furthermore, the API for generating prompts for SuiGPT is publicly available, so anyone can integrate SuiGPT into their AI coding services.

Future Milestones:

In the future, we will be carrying out the following tasks.

  • 2023 (Q4): Include more Move code as data
  • 2023 (Q4): Train and Evaluate LLMs, such as GPT and CodeLLaMA, with the Move database we created.
  • 2024 (Q1): Integrated SuiGPT into a Website so users can access SuiGPT from a browser
  • 2024 (Q2): Write a research paper about SuiGPT
  • 2024 (Q2*): Integrated SuiGPT into Sui-Move Web IDE to generate move code (* If Sui plans to lunch a Web IDE)
I-Sheng (Eason) Chen
I-Sheng (Eason) Chen
2nd-year PhD Student at Human-Computer Interaction Institute

Eason is a first-year PhD student in HCII at CMU.