# Zama: Part 3.1, Concrete ML - No Code Introduction

By [lordachita](https://paragraph.com/@lordachita) · 2025-08-31

---

สวัสดีครับเพื่อนๆ

หลังจากที่ผู้เขียนได้อัปเดตเกี่ยวโปรเจค Zama ในมุมมองด้าน Blockchain ไปแล้ว ผ่านบทความ Part 2.1 และ 2.2 สำหรับบทความนี้ ในฐานะที่ผู้เขียนกำลังทำงานด้าน Data Scientist อยู่ ผู้เขียนมีความสนใจ product ของตัวนึง Zama มากๆ ที่ช่วยให้เหล่า Data Scientist สามารถสร้างโมเดล AI ที่สามารถประมวลผลบนข้อมูลที่ถูกเข้ารหัสได้ ทำให้การทำงานมีความปลอดภัยสูงแม้ข้อมูลจะหลุดรั่วออกไป โดย product ตัวนี้ชื่อว่า Concrete ML ครับ

Introduction
------------

จุดแข็งของ Fully Homomorphic Encryption (FHE) คือการที่สามารถทำ computations บน encrypted data ได้โดยที่ไม่จำเป็นต้อง decrypt ก่อน จึงไม่ต้องกังวลว่าข้อมูลที่ sensitive จะหลุดออกไป โดยส่วนของ Concrete ML จะเป็น open source, privacy-preserving, machine learning framework ผ่าน FHE โดยมีคุณสมบัติต่างๆเช่น

*   สามารถที่จะใช้งานผ่าน APIs ในรูปแบบที่ใกล้เคียงกับ library มาตรฐาน (scikit-learn และ PyTorch) ในการทำงานกับ Machine Learning models ในรูปแบบ FHE equivalent
    
*   สามารถที่จะ [train linear models](https://docs.zama.ai/concrete-ml/built-in-models/training) รวมถึง fine-tune LLMs บน encrypted data ได้
    
*   สามารถ [pre-process encrypted data](https://docs.zama.ai/concrete-ml/built-in-models/encrypted_dataframe) ในรูปแบบ DataFrame ได้ (แต่ยังมีข้อจำกัดประมาณนึง)
    

โดยเหล่า Data Scientist ที่มาใช้งาน library นี้ไม่จำเป็นที่จะต้องมีความรู้เกี่ยวกับ cryptography เลยก็ได้ (Because Vibe Coding? Yes and No เพราะ concept ของ FHE นั้นสามารถทำความเข้าใจได้ง่ายมากๆ แต่ความซับซ้อนส่วนใหญ่จะไปตกอยู่กับการคำนวณหลังบ้าน)

### Cryptography Concepts, Again

ผู้อ่านบ้าน Web3 ควรมีความเข้าใจพื้นฐานในเรื่องของ Encryption, Decryption, Private/Public Key อยู่แล้ว แต่ผู้เขียนคิดว่ามีส่วนของ TFHE ที่สามารถเสริมเลยได้ในเบื้องต้น ก่อนที่จะเขียนบทความถัดไป พื้นฐานของการทำ FHE จะต้อง preserve การบวกและการคูณบน ciphertexts (ข้อมูลที่ถูก encrypted) โดยไอเดียหลักๆของ TFHE คือการจัดการ noise บน ciphertexts ที่ถูกเพิ่มเข้ามาเพื่อเพิ่ม security ในการ encryption ที่ noise จะเริ่มมีความเสี่ยงที่จะ explode บนการคูณ ￼

![https://www.zama.ai/post/tfhe-deep-dive-part-3](https://storage.googleapis.com/papyrus_images/b7f662250b636e9e2560dd0c076d0f2772463d53b25256d42ec88105c69719c3.png)

https://www.zama.ai/post/tfhe-deep-dive-part-3

ทำให้ TFHE จะต้องมี

*   **Guaranteed Correctness of Encrypted Computations**: คุณสมบัติในการ guarantee ความถูกต้องของการคำนวณ ทั้งบนข้อมูล encrypted-decrypted
    
*   **Programmable Boostrapping (PBS)**: ระบบหลักที่ช่วยคุม noise ระหว่างคำนวน FHE (จะเห็นภาพมากขึ้นในบทความถัดๆไป)
    
*   **Ciphertext Formats**: รูปแบบการ encryption ที่เหมาะสมสำหรับการทำ FHE สำหรับ Concrete ML จะมีเลือกสองตัวเลือก
    
    *   **Default Concrete Ciphertext format** - ถูก optimized สำหรับ ML models
        
    *   **TFHE-rs Radix format** - เหมาะสำหรับ Blockchain Applications มากกว่า
        

โดยเราจะมาพูดถึงการทำงานในเชิงลึกของ TFHE ในบทความถัดๆไป

### Concrete

**Concrete** คือ FHE Compiler แบบ open-source ที่ถูกสร้างบนเทคโนโลยี TFHE ช่วย developers ในการเขียน FHE programs โดยไม่จำเป็นที่จะต้องเป็น expert ในด้าน cryptography ตัวอย่าง product ที่ถูกสร้างอยู่บน Concrete เช่น Concrete ML ทำให้สามารถแปลงการคำนวนตัวเลข (NumPy) ลงไปบน FHE circuits ได้

[

Welcome | Concrete
------------------

Concrete is an open-source FHE Compiler that simplifies the use of Fully Homomorphic Encryption (FHE).

https://docs.zama.ai

![](https://storage.googleapis.com/papyrus_images/e826c398564ac997278637fd2087b486b0783bdcaed836ed89d885e116b84519.png)

](https://docs.zama.ai/concrete)

Overview
--------

### 0\. Data Scientist Methodology

สำหรับผู้เขียน คิดว่า Data Scientist คือผู้ที่นำทรัพยากรในรูปแบบของข้อมูลมาใช้เพื่อตอบโจทย์การทำธุรกิจ ทั้งในเรื่องของการ increase revenue/reduce cost โดยมีความสามารถในการ extract insights ผ่านวิธีที่หลากหลายไม่จำกัดตั้งแต่การทำ Data Analysis จนไปถึงการ Develop Rule-Based/Machine Learning/Deep Learning Model รวมทั้งการใช้งาน Agentic LLM/Workflow Solutions

![https://aws.amazon.com/th/what-is/mlops/](https://storage.googleapis.com/papyrus_images/3f3964007bcda5243fb7a18b4db5980ec5975eaf4b8624b1a9d1495933c92ec9.jpg)

https://aws.amazon.com/th/what-is/mlops/

เพื่อทำความเข้าใจการทำงานของ Data Scientist ในเบื้องต้น ผู้เขียนขออนุญาติเกริ่นถึง step การทำงานโดยคร่าว

**1\. Exploratory Data Analysis** - เป็นขั้นตอนการสำรวจข้อมูลในเบื้องต้นว่าพร้อมใช้งานหรือไม่ เช่นการตรวจเช็คความถูกต้องของข้อมูล, การพล็อตข้อมูลเพื่อดูสิ่งที่เราสนใจ

**2\. Model Training** - เป็นขั้นตอนการนำโมเดลที่ตอบโจทย์ปัญหาที่ต้องการ มาปรับจูนเพื่อเรียนรู้/ทำนายผ่าน distribution ของข้อมูลที่มี

**3\. Model Evaluation** - เป็นขั้นตอนการวัดผลโมเดลการทำงานของโมเดล ซึ่ง Data Scientist จะมีหน้าที่เลือกมาตรวัดผลต่างๆที่ตอบโจทย์ทั้งในเชิงของ technical และ business และสรุปหาโมเดลที่เหมาะสมที่สุดเพื่อนำมาใช้งาน

**4\. Deployment** - เป็นขั้นตอนหลังจากที่ได้โมเดลที่ตอบโจทย์ปัญหาที่สุดมา ก็จะเป็น step ของการเตรียมนำโมเดลไปใช้งานจริง ซึ่งในขั้นตอนนี้ก็จะต้องมีการเตรียมวิธีรับมือปัญหาต่างๆเช่น Data Drift ที่อาจเกิดขึ้น ซึ่งทำให้โมเดลทำงานมีประสิทธิภาพลดลง และจะต้องมีการนำโมเดลไปเทรนใหม่

โดย Zama ช่วยเปิดโอกาสให้สามารถทำงานบนข้อมูลที่เข้ารหัสได้แบบ e2e (end-2-end, ต้นจนจบกระบวนการ)

### **1\. Current Limitations**

ในปัจจุบัน

1.  Concrete ML มีข้อจำกัดในเรื่องของ _precision limit_ สำหรับ ML models ที่ถูกจำกัดไว้ที่ 16-bit integers เพื่อให้ FHE สามารถทำงานได้ ทำให้โมเดลต่างๆจะต้องถูก quantized (ลดขนาด/parameters ของโมเดล) และมีประสิทธิภาพการทำงานที่ลดลงเป็นบางครั้ง เพื่อแลกกับความสามารถที่จะทำงานบน ciphertexts ได้
    
2.  อีกทั้ง Concrete ML ยังมีข้อจำกัดในเรื่องของจำนวนโมเดลที่สามารถทำ _training_ บน encrypted data ได้ ในขณะที่ในฝั่งของการทำ _inference_ จะมีโมเดลที่ถูก support หลากหลายมากขึ้น
    
3.  นอกจากนั้น การทำ pre-processing สำหรับ model inputs และ post-processing สำหรับ model outputs ยังไม่ support
    

ซึ่งทางทีมได้รับทราบปัญหาเหล่านี้แล้ว และกำลังพัฒนาอยู่

### 2\. On-Hands

ผู้อ่านสามารถศึกษาการใช้งาน Concrete ML เบื้องต้นได้ที่เว็ป Kaggle ซึ่งผู้เขียนจะมาเขียนต่อในบทความถัดๆไป

[

Titanic - Machine Learning from Disaster
----------------------------------------

Start here! Predict survival on the Titanic and get familiar with ML basics

https://www.kaggle.com

![](https://storage.googleapis.com/papyrus_images/1ee53ea1728c9787dc54c7eeada09dd33ae3bc33e1255451a6c44c4cb61118c9.jpg)

](https://www.kaggle.com/competitions/titanic)

### 3\. \[Geek Alert!\] Inference in the Cloud

ภาพรวม communications protocol เพื่อที่จะทำ cloud deployment ของ machine learning services สามารถสรุปได้ดังนี้

![https://docs.zama.ai/concrete-ml/get-started/cloud](https://storage.googleapis.com/papyrus_images/7815541eaff9a752c3e09aade53abf7baba717062f1118b016ffc3e5274dd866.avif)

https://docs.zama.ai/concrete-ml/get-started/cloud

1.  **Model Deployment**: ผู้พัฒนาโมเดล deploy ตัว compiled ML model ซึ่งรวม cryptographic parameters ไปที่ server. ทำให้ server พร้อมที่จะทำ private inference
    
2.  **Client request**: client ส่งคำขอ cryptographic parameters (client specs) ซึ่งหลังจากที่ client ได้รับ cryptographic parameters จาก server แล้ว _secret_ และ _evaluation_ keys จะถูก generated
    
3.  **Key exchanges**: client ส่ง _evaluation_ key ไปยัง server ทำให้ server พร้อมตอบรับ requests จาก client จากนั้น client จึงส่ง encrypted data
    
4.  **Private inference**: server ใช้งาน _evaluation_ key ในการรัน prediction, training และ pre-processing บนข้อมูล client อย่างปลอดภัยและส่งกลับผลลัพธ์ที่ถูก encrypted
    
5.  **Decryption**: client จึง decrypt ผลลัพธ์ที่ได้ และสามารถส่ง requests ใหม่ๆต่อได้
    

### 4\. \[Geek Alert!\] Concrete ML Model Life Cycle

ในส่วนนี้จะเป็นการอธิบายขั้นตอนต่างๆผ่านการใช้งาน Concrete ML แบบ e2e

**I. Model Development**

1.  **Training:** โมเดลถูกเทรนบนข้อมูลที่เป็น plaintext รวมถึง encrypted ไว้แล้ว
    
2.  [**Quantization**](https://docs.zama.ai/concrete-ml/explanations/quantization)**:** ทำให้ข้อมูล inputs, model weights และ intermediate values ของการทำ inference นั้นอยู่ในรูป integer equivalent โดยจะมีสองรูปแบบขึ้นกับประเภทโมเดลที่ใช้
    
    *   **During Training (Quantization Aware Training)**: เป็นการเพิ่ม quantization layers ในโมเดล NN โดย weights สามารถเป็น discrete และ activation quantization parameters ถูก optimized ผ่าน gradient descent หากใช้ QAT จะต้องมีการ re-training NN บน quantization layers.
        
    *   **After Training (Post Training Quantization)**: floating point neural network ถูกคงไว้และขั้นตอนการ calibration step จะกำหนด quantization parameters สำหรับแต่ละ layer ซึ่งไม่จำเป็นต้อง re-training จึงไม่จำเป็นต้องมี training data หรือ labels สำหรับการแปลง NN เป็นรูปแบบ FHE ผ่านการใช้ PTQ
        
3.  [**Simulation**](https://docs.zama.ai/concrete-ml/explanations/compilation#fhe-simulation)**:** สามารถ execute โมเดลที่ถูก quantized เพื่อวัด accuracy ใน FHE และประเมิน การ modifications ในการทำให้ FHE compatible
    
4.  [**Compilation**](https://docs.zama.ai/concrete-ml/explanations/compilation#fhe-simulation)**:** หลังจาก quantizing model และมั่นใจว่าโมเดลมี good FHE accuracy ผ่าน simulation โมเดลจะต้องถูก compiled ผ่าน Concrete's FHE Compiler เพื่อสร้าง equivalent FHE circuit โดย circuit is represented as an [MLIR program](https://mlir.llvm.org/) รวบรวม low level cryptographic operations ต่างๆไว้
    
5.  **Inference:** โมเดลที่ถูก compiled แล้วจะถูก executed บน encrypted data หลังจาก proper keys ถูก generated ขึ้นแล้ว model สามารถที่จะถูก deployed ไปที่ server และใช้ในการ run private inference บน encrypted inputs
    

**II. Model Deployment**

1.  **Pre-processing:** Client/Data Owners สามารถสร้าง keys สำหรับ encrypt/decrypt ข้อมูลในรูปแบบ df (DataFrame) สำหรับทำ processing บน server ด้วย pre-compiled circuits เพื่อที่จะเตรียมตัวสำหรับทำ encrypted training/inference ในขั้นตอนถัดไป
    
2.  **Client/Server Model Deployment:** โมเดล Concrete ML สามารถถูก exported เพื่อที่จะให้ client สามารถสร้าง encrypt, decrypt keys รวมถึงทำ compiled model ที่สามารถรันบน server เพื่อทำ inference บน encrypted data
    
3.  **Key Generation:** ฝั่ง client ต้องสร้าง private encryption key สำหรับ encrypt/decrypt ข้อมูล/ผลลัพธ์ และ public evaluation key สำหรับการทำ model's FHE evaluation บน server
    
4.  **Ciphertext Formats:** application ฝั่ง server สามารถถูกปรับแต่งเพื่อรองรับ ciphertexts รูปแบบต่างๆจาก client
    

[

Production deployment | Concrete ML
-----------------------------------

This document explains the deployment workflow and the model serving pattern for deploying Fully Homomorphic Encryption machine learning models in a client/server setting using Concrete ML. The steps to prepare a model for encrypted inference in a client/server setting is illustrated as follows: The training of the model and its compilation to FHE are performed on a development machine.

https://docs.zama.ai

![](https://storage.googleapis.com/papyrus_images/e826c398564ac997278637fd2087b486b0783bdcaed836ed89d885e116b84519.png)

](https://docs.zama.ai/concrete-ml/guides/client_server)

Conclusion
----------

Zama เป็นโปรเจ็คระดับตัวแบกของ FHE industry ที่จะมาปฏิวัติเรื่องของ Privacy ทั้งอุตสาหกรรม Blockchain และ AI (Web2 และ Web3) ผู้เขียนจึงขอเลือกที่จะไปต่อกับโปรเจคนี้ในไตรมาสที่สาม ทั้งนี้ผู้อ่านสามารถติดตามรายละเอียดต่างๆเกี่ยวกับโปรเจ็ค Zama ได้ผ่านลิ้งค์ต่างๆดังนี้

*   [github.com/zama-ai/awesome-zama](http://github.com/zama-ai/awesome-zama)
    
*   [fhe.org/resources/#conference-resources](http://fhe.org/resources/#conference-resources)
    

Reference
---------

*   [docs.zama.ai/concrete-ml/get-started/getting-started](http://docs.zama.ai/concrete-ml/get-started/getting-started)

---

*Originally published on [lordachita](https://paragraph.com/@lordachita/zama-part-3-1-concrete-ml-no-code-introduction)*
