Large Language Models (โมเดลภาษาขนาดใหญ่)

เมื่อคุณผสม neural network เข้าไปนิดหน่อย 4 ผสมกับ Markov chain algorithm น่ารัก ๆ อีกนิด บวกกับเนื้อหาทั้งหมดของ Library of Congress ทุกหน้าบน Web และงานวิจัยทั้งหมดในห้องสมุดมหาวิทยาลัยทุกแห่ง คุณก็จะได้ผลลัพธ์ที่น่าประหลาดใจไม่น้อยเลยทีเดียว

4 . ตามนิยามอย่างใดอย่างหนึ่งของคำว่า "นิดหน่อย"

น่าประหลาดใจก็จริง แต่ไม่ได้แปลว่าฉลาดมากนัก

หรือบางทีผมควรจะพูดว่า บางครั้งผลลัพธ์ก็ดูฉลาด แต่ไม่เคยสร้างสรรค์หรือมีเอกลักษณ์เฉพาะตัวเลย และถ้าผลลัพธ์ดูฉลาด นั่นก็ไม่ได้มาจากสติปัญญาโดยกำเนิดใด ๆ ที่อยู่ในตัว software LLM เอง แต่สติปัญญาใด ๆ ที่คุณรับรู้ได้นั้น ล้วนเป็นผลมาจากสติปัญญาของงานเขียนที่ LLM ถูกฝึกมาจากนั่นเอง

เห็นไหมครับ LLM เป็นตัวอย่างที่ดีเยี่ยมของหลักการ GIGO นั่นคือ garbage in, garbage out (ใส่ขยะเข้าไป ก็ได้ขยะออกมา) ตัวอย่างเช่น ถ้าคุณเทรน software LLM ด้วยงานเขียนของอาชญากร คุณก็จะได้ผลลัพธ์แบบอาชญากรออกมาเป็นจำนวนมาก หรือถ้าคุณเทรนมันด้วยงานเขียนของพวกฆ่าล้างเผ่าพันธุ์สุดโต่ง คุณก็จะได้ความคิดแบบฆ่าล้างเผ่าพันธุ์ออกมามาก และถ้าคุณบังเอิญเทรนมันด้วยงานเขียนของคนที่ค่อนข้างฉลาด คุณก็จะได้ความฉลาดในระดับหนึ่งออกมา บางครั้งก็เป็นเช่นนั้น

แต่ไม่ว่าในกรณีใดก็ตาม คุณจะไม่มีทางได้อะไรที่มีเอกลักษณ์หรือสร้างสรรค์ออกมาเลย

ตัวอย่างเช่น ผมลองขอให้ LLM ชื่อดังตัวหนึ่งพูดอะไรที่ฟังดูเฉลียวฉลาดสักหน่อย คำตอบที่ได้คือ:

คลิกที่นี่เพื่อดูภาพโค้ด

Life is a journey where the beauty lies not just in reaching the
destination, but in savoring each step of the way. Embrace the
lessons, cherish the moments, and find wisdom in the tapestry of
experiences that shape your unique story.

ถ้าคุณไม่ได้กลอกตาตอนนี้ คุณก็คงอายุต่ำกว่า 30 ปี Life is a journey เนี่ยนะ? จริงหรือ? คือ โอเค ก็ได้ แต่คำคมเก่าแก่นี้มีมานานมากแล้ว จนฝังรากลึกอยู่ในหัวของพวกเราแทบทุกคนไปแล้ว ถ้าคุณอายุเกิน 30 นะ

ผมลองขอให้ LLM ตัวเดียวกันพูดอะไรที่มีเอกลักษณ์เฉพาะตัวสักหน่อย มันตอบว่า:

คลิกที่นี่เพื่อดูภาพโค้ด

In the symphony of existence, each individual is a note,
contributing a unique melody to the grand composition of the
universe. Embrace the rarity of your own tune, for it is in the
harmonious diversity of all notes that the true beauty of life’s
music is revealed.

ผมรู้ครับ ขอโทษด้วยที่ทำให้กล้ามเนื้อตาของคุณต้องทำงานหนัก มันคงจะเมื่อยไม่น้อยหลังจากนั้น ยังไงก็ลองค้นหาคำว่า "In the symphony of existence" ใน DuckDuckGo ดูสิครับ แล้วจะเห็นว่าประโยคนั้นมีเอกลักษณ์เฉพาะตัวแค่ไหน

มันไม่ยากเลยที่จะโน้มน้าวตัวเองว่า LLMs ไม่ได้ฉลาดจริง คำตอบสำหรับสองคำถามข้างต้นนั้นไม่ผ่านการทดสอบทัวริง ไม่มีมนุษย์ที่ฉลาดและอายุเกิน 30 คนไหนจะตอบคำถามเหล่านั้นแบบนี้หรอก เว้นแต่ว่ากำลังแสดงตลกล้อเลียนเกี่ยวกับ large language models อยู่

นี่ไม่ได้หมายความว่า LLMs ไม่มีประโยชน์นะครับ มันมีประโยชน์จริง ๆ และมักจะเป็นทางเลือกที่ดีกว่าเสิร์ชเอนจิ้นด้วยซ้ำ ตัวอย่างเช่น ผมถามมันว่า “Who wrote: In the symphony of existence, each individual is a note?” และมันตอบว่า:

Me.

ไม่จริงน่า! จริงเหรอ? ลองนึกภาพดูสิ! ผมไม่มีทางเดาได้เลย (หลับตาแล้วกดขมับสักสองสามวินาที น่าจะช่วยลดอาการปวดหัวได้)

จากนั้นผมก็ถามมันว่า: “Who wrote about the symphony of life?”

และมันบอกผมว่านี่คือ:

คลิกที่นี่เพื่อดูภาพโค้ด

common metaphor used by various writers, philosophers, and
speakers over time.

ครับ ผมรู้แล้ว ขอบใจนะ

แต่พอกันทีกับการล้อเลียนแบบนี้ ลองมาทำอะไรที่มีประโยชน์กับมันดูบ้างดีกว่า: “Write a Java program to calculate 50!”

และแล้ว มันก็ตอบกลับมาว่า:

คลิกที่นี่เพื่อดูภาพโค้ด

Certainly! Calculating the factorial of 50 (50!) is a large
number, and it may not fit into standard data types like int or
long. Therefore, it’s common to use a data type with arbitrary
precision, such as BigInteger in Java. Here’s a simple Java
program to calculate 50! using BigInteger:

import java.math.BigInteger;
public class FactorialCalculator {
    public static void main(String[] args) {
        int n = 50;
        BigInteger result = calculateFactorial(n);

        System.out.println(n + "! = " + result);
    }
    private static BigInteger calculateFactorial(int n) {
        BigInteger factorial = BigInteger.ONE;
        for (int i = 1; i <= n; ++i) {
            factorial = factorial.multiply(BigInteger.valueOf(i));
        }
        return factorial;
    }
}

In this program:

▪ We use the BigInteger class to handle large numbers.
▪ The calculateFactorial method iterates from 1 to 50, multiplying
  the current value of factorial by the loop variable at each
  step.
▪ The final result is then printed to the console.

Compile and run this Java program to see the value of 50! printed
to the console. Keep in mind that the result will be a very large
number.

โอเค ถ้าเราไม่นับรวมบุลเล็ตพอยต์ที่น่ารำคาญและซ้ำซ้อนโดยสิ้นเชิงตอนท้าย ก็ต้องบอกว่าค่อนข้างน่าประทับใจทีเดียว ผมคอมไพล์และรันโปรแกรมนั้น แล้วมันก็พิมพ์ผลลัพธ์ออกมาว่า:

คลิกที่นี่เพื่อดูภาพโค้ด

50! =
    30414093201713378043612608166064768844377641568960512000000000000

คุณคิดว่า LLM เขียนโค้ดนั้นขึ้นมาเองหรือเปล่า? หรือมันไปเจอโค้ดนั้นที่ไหนสักแห่งบนอินเทอร์เน็ตแล้วก็แค่เอามาแสดงซ้ำ? หรือเป็นการผสมผสานกันทั้งสองอย่าง?

ผมว่าน่าจะเป็นอย่างแรกมากกว่าอย่างหลัง แม้ว่าผมจะหาสำเนาที่ตรงกันเป๊ะ ๆ ไม่เจอก็ตาม ดังนั้น LLM ตัวนี้น่าจะปะติดปะต่อมันขึ้นมาเอง ผมเดาว่า LLM ตัวนี้ถูกเทรนมาเป็นพิเศษด้าน Java และน่าเสียดายที่รวมถึงสไตล์การเขียนเอกสารประกอบโปรแกรมแบบบุลเล็ตพอยต์ด้วย

ลองทำอะไรที่ยากขึ้นอีกนิดดู: “Write a Java program that multiplies its input by a succession of every other prime number and counts the number of multiplications until the product exceeds a trillion.”

คลิกที่นี่เพื่อดูภาพโค้ด

import java.util.ArrayList;
public class PrimeMultiplication {

    public static void main(String[] args) {
        long input = 2; // Initial input
        long limit = 1_000_000_000_000L; // Trillion
        int primeIndex = 0;

        while (input <= limit) {
            input *= getNextPrime(primeIndex);
            primeIndex += 2; // Move to every other prime number
        }

        System.out.println("Final product: " + input);
        System.out.println("Number of multiplications: " +
                           (primeIndex / 2));
    }

    private static long getNextPrime(int index) {
        ArrayList<Long> primes = new ArrayList<>();
        long num = 2;

        while (primes.size() <= index) {
            if (isPrime(num)) {
                primes.add(num);
            }
            num++;
        }
        return primes.get(index);
    }

    private static boolean isPrime(long num) {
        if (num < 2) {
            return false;
        }
        for (long i = 2; i <= Math.sqrt(num); i++) {
            if (num % i == 0) {
                return false;
            }
        }
        return true;
    }
}

ผมต้องยอมรับว่าค่อนข้างแปลกใจที่ LLM สามารถแปลความหมายคำถามของผมและตีความได้ถูกต้องพอที่จะสร้างโค้ดที่ใช้งานได้จริง และผมก็แปลกใจไม่น้อยเช่นกันว่าโค้ดนั้นแย่ขนาดไหน คือ มันทดสอบเลข 4 ว่าเป็นจำนวนเฉพาะหรือไม่ . มัน สร้างจำนวนเฉพาะทั้งหมดขึ้นมาใหม่ จนถึงตำแหน่งดัชนีนั้นทุกครั้งที่มีการคูณ นี่ไม่ใช่โค้ดที่เขียนโดย programmer ที่มีสติสัมปชัญญะแน่ ๆ นี่คือโค้ดที่เขียนโดยเครื่องจักรที่ตัดแปะโค้ดจากแหล่งต่าง ๆ แล้วเอามาต่อกัน น่าประทับใจไหม? ใช่ครับ

ฉลาดไหม? ไม่เลย

อีกสักตัวอย่าง: “Write a Java program that prints the 97th digit of pi.”

คลิกที่นี่เพื่อดูภาพโค้ด

import org.apache.commons.math3.analysis.function.Constant;
import org.apache.commons.math3.util.FastMath;

public class PiDigit {

    public static void main(String[] args) {
        // Get the 97th digit of pi
        int digitIndex = 97;
        char piDigit = getPiDigit(digitIndex);

        System.out.println("The 97th digit of pi is: " +
                           piDigit);
    }

    private static char getPiDigit(int digitIndex) {
        // Calculate pi using Apache Commons Math
        double pi = FastMath.PI;

        // Convert pi to a string and get the desired digit
        String piString = Double.toString(pi);
        return piString.charAt(digitIndex);
    }
}

เอ่อ ไม่ครับ วิธีนี้ใช้ไม่ได้หรอก อีกครั้งหนึ่ง ไม่มี programmer ที่มีสติสัมปชัญญะคนไหนจะเสนอวิธีแก้แบบนี้ และนั่นแหละคือประเด็น LLM ไม่ใช่ programmer ที่มีสติสัมปชัญญะ อันที่จริง LLM ไม่มีสติสัมปชัญญะเลยด้วยซ้ำ การใช้คำว่า สติสัมปชัญญะ กับ LLM นั้นเป็นความผิดพลาดเชิงประเภท (category error) LLMs ไม่ได้มีสติหรือไร้สติ เพราะมันไม่มีความรู้สึกนึกคิดตั้งแต่แรก

แต่มันก็ยังมีประโยชน์อยู่ดี: “What is the octal code for a Ctrl-L?”

คลิกที่นี่เพื่อดูภาพโค้ด

The octal code for the Ctrl-L (Control-L) character is \f or
\014. The Ctrl-L character represents the form feed control
character, which is used for various purposes depending on the
context, such as page breaks in printers or clearing the screen
in terminal emulators.

โอเค ข้อมูลเยอะเกินความจำเป็น แต่โดยหลักแล้วถูกต้อง ในทางกลับกัน โค้ด octal ของ Ctrl-L นั้นไม่ใช่ \f อันที่จริงมันไม่ใช่แม้แต่ \014 ด้วยซ้ำ มันคือแค่ 14 8 เท่านั้น ผมไม่ได้ถามหารูปแบบการแทนค่าแบบภาษา C ผมแค่อยากรู้ตัวเลข octal เฉย ๆ การให้ข้อมูลมากเกินไปบางครั้งก็ทำให้เข้าใจผิดได้พอ ๆ กับการให้ข้อมูลน้อยเกินไป

ลองอีกอันหนึ่ง: “What year was the Magna Carta signed?”

คลิกที่นี่เพื่อดูภาพโค้ด

The Magna Carta, also known as the Great Charter, was signed on
June 15, 1215, during the reign of King John of England. It was a
historic document that outlined certain legal rights and limited
the powers of the monarchy. The signing of the Magna Carta took
place at Runnymede, near Windsor, and it played a significant
role in the development of constitutional law and the protection
of individual liberties.

อีกครั้งหนึ่งกับข้อมูลเยอะเกินความจำเป็น ผมแค่อยากได้คำตอบว่า “1215” ก็พอใจแล้ว ได้โปรดอย่าให้คำตอบมาเป็นย่อหน้ายาว ๆ ตอนที่ผมถามหาแค่วันที่

“In Clojure, how do I transpose a two-dimensional table?”

คลิกที่นี่เพื่อดูภาพโค้ด

In Clojure, you can use the map function along with the apply
function to transpose a two-dimensional table. Here’s a simple
example:

(defn transpose [table]
  (apply map vector table))

(def example-table
  [[1 2 3]
   [4 5 6]
   [7 8 9]])

(def transposed-table (transpose example-table))

(println "Original Table:")
(doseq [row example-table]
  (println row))

(println "Transposed Table:")
(doseq [row transposed-table]
  (println row))

In this example, the transpose function takes a two-dimensional
table as input and uses map and vector to transpose it. The
resulting transposed table is then printed out for demonstration.

Make sure to adapt this code to fit the structure of your
specific two-dimensional table if needed.

ครับ นั่นคือ idiom ที่ลอกมาจาก Stack Overflow ตรง ๆ เลย มีข้อมูลเยอะเกินความจำเป็นเพียบ พูดตามตรงผมไม่ต้องการตัวอย่างเล็ก ๆ น้อย ๆ ที่ไม่จำเป็นแบบนั้น และความคิดเห็นปิดท้ายก็ไร้ประโยชน์พอ ๆ กัน

ดังนั้น ใช่ครับ มันมีประโยชน์มากในฐานะเสิร์ชเอนจิ้น แต่ไม่ใช่นักเขียนที่มีสติสัมปชัญญะ ผลลัพธ์จาก LLMs ไม่ผ่านการทดสอบทัวริง ถ้าคุณนำเสนอผลลัพธ์ของมันราวกับว่ามนุษย์เป็นคนเขียน คุณ จะ ถูกจับได้แน่นอน แม้แต่ตัว LLMs เองก็ยัง “รู้” เรื่องนี้ด้วยซ้ำ:

“Write a paragraph on why you will get caught it you present LLM output as if a human wrote it.”

คลิกที่นี่เพื่อดูภาพโค้ด

Presenting LLM output as if a human wrote it poses a risk of
detection due to distinctive characteristics inherent in the
AI-generated text. While an LLM excels at generating coherent and
contextually relevant responses, it lacks the nuanced
understanding and personal experience that a human writer
possesses. The responses may occasionally exhibit
inconsistencies, lack of real-world knowledge beyond its training
data cutoff, or unusual patterns that astute readers or
evaluators could identify. Furthermore, the LLM might
inadvertently generate information or opinions that are outdated
or incorrect. Moreover, the lack of a consistent personal voice
and the absence of a genuine individual's perspective could raise
suspicions. In scenarios where authenticity and credibility are
paramount, presenting LLM output as human-generated may risk
exposure, emphasizing the importance of transparency in
communicating the use of AI-generated content.