# Building An AI Agent Based On CAN-20 Protocol Primitive Data

## Introduction

Leveraging the <mark style="color:blue;">General Language Model (GLM)</mark> architecture and model quantization, we fine-tune using the high-efficiency <mark style="color:blue;">P-Tuning v2</mark> method alongside user-uploaded on-chain data. This produces Chain-GLM — a cost-effective web-enhanced question answering system similar to WebGLM. <mark style="color:blue;">Chain-GLM</mark> is designed to utilize decentralized on-chain data by integrating search/retrieval into pre-trained language models. This allows freely distributing information and accurately obtaining it via AI capabilities.

## Implementation

ChainGLM aims to improve real-world application deployment by integrating web search and retrieval capabilities into pre-trained language models.&#x20;

* **LLM Enhanced Retriever:** Retrieves relevant web content to answer questions more accurately
* **Elicitation Generator:** Leverages GLM to generate high-quality, human-like responses
* **Human Preference-Aware Scorer:** Prioritizes useful, engaging responses based on human preferences.

<figure><img src="https://964373125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVX1cG7A6PfK248l4DW8t%2Fuploads%2FASBPtbkbruRQzuThEwi1%2Fimage.png?alt=media&#x26;token=71c5da2b-50ff-426d-b4d3-2165416a0c1d" alt=""><figcaption></figcaption></figure>

* **P-Tuning v2**
  * P-Tuning v2 is an optimized cue tuning strategy that achieves performance comparable to fine-tuning on small/medium models and sequence labeling challenges.
  * P-tuning v2 utilizes deep cue tuning, where successive cues are applied to each layer input of the pretrained transformer. Deep cue tuning increases the ability to continuously cue and closes the gap with fine-tuning in a variety of settings, especially for small models and difficult tasks.

<figure><img src="https://964373125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVX1cG7A6PfK248l4DW8t%2Fuploads%2FRJ2fjii2o9nPGxDypAiq%2Fimage.png?alt=media&#x26;token=bdda69f9-5d40-4ee0-b6c1-0c13cb092400" alt=""><figcaption></figcaption></figure>

* Integration with on-chain data

<figure><img src="https://964373125-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FVX1cG7A6PfK248l4DW8t%2Fuploads%2FwitrhEt2mikoTVucFOeX%2Fimage.png?alt=media&#x26;token=d1d44be7-28a6-41b1-98a2-a7a78c474cf0" alt=""><figcaption></figcaption></figure>
