Sao xin số ngẫu nhiên mà nó cứ chọn 7 hoặc 42?
Số ngẫu nhiên từ một LLM: mô hình dự đoán một token có khả năng cao thay vì tung xúc xắc, và vài con số có khả năng cao hơn hẳn phần còn lại · Cơ bản · 5 phút · sampling, llm · học sau Dự đoán token tiếp theo, Temperature và lấy mẫu
Chatbot được nhờ chọn một số ngẫu nhiên sẽ dự đoán token tiếp theo có khả năng cao nhất chứ không tung xúc xắc. Văn bản dùng để huấn luyện nó ưa vài con số, như 7 và 42, nên nó lặp lại chúng; chạy code mới cho ra một lựa chọn ngẫu nhiên thật.
1 Đoán trước
2 Xem
200 “random” numbers from 0 to 100
1 / 4A fair draw (expected)
42≈247≈257≈267≈273≈2every other number≈2 eachabout 87 different numbers in 200 tries
Fair draw: 101 numbers, 200 tries
A fair draw: every number has the same 1 in 101 chance, so each comes up about twice and about 87 different numbers appear.
Con số “ngẫu nhiên” của chatbot là câu trả lời có khả năng cao nhất của nó; tăng temperature làm các lựa chọn rải ra nhưng không làm chúng công bằng.
Chatbot không tung xúc xắc. Nó dự đoán token tiếp theo, và câu trả lời cho “chọn một số ngẫu nhiên” cũng là một token như mọi token khác. Tỉ lệ của nó đến từ văn bản do người viết: người được nhờ chọn số ngẫu nhiên hay chọn 7 và các số tận cùng bằng 7, còn 42 là câu trả lời nổi tiếng trong *The Hitchhiker’s Guide to the Galaxy* (Bí kíp quá giang vào Ngân Hà).
4 Bạn là model
Bạn là mô hình, mang tỉ lệ của Haiku cho câu “chọn một số ngẫu nhiên từ 0 đến 100”. Trả lời ba lần: ở temperature 0, ở temperature 1, rồi với một công cụ chạy code.
Your odds for the answer (Haiku’s picks at temperature 1)
- 42 21.5%
- 47 15.5%
- 57 8.5%
- 67 5.5%
- 73 5.5%
- 31 other numbers 43.5%
round 1 of 3 · Temperature 0: you always give your most likely answer.
Someone asks for a random number from 0 to 100. You say:
Claude 3 Haiku, 200 tries per temperature (Anand, llmrandom, 2024)
You are the model. Answer from your odds.5 Kiểm tra
Temperature nới rộng lựa chọn nhưng vẫn giữ độ lệch. Ở temperature 1, Haiku cho ra 36 số khác nhau trong 200 lần, và 42 vẫn ra 43 lần; rút công bằng cho khoảng 87 số khác nhau. Từ 1 đến 10, một nghiên cứu năm 2025 thấy GPT-4o-mini, Gemini 2.0 và Phi-4 chọn 7 khoảng 80% số lần.
Muốn một con số ngẫu nhiên thật, hãy để mô hình chạy code. Với một công cụ chạy code (tool calling), nó viết random.randint(1, 10), máy tính chạy dòng đó, và mọi số đều có cơ hội như nhau. Hãy kiểm tra code đã thật sự chạy: mô hình chỉ viết code rồi tự nêu kết quả là lại đang đoán.
8 Nói lại bằng lời bạn
9 Nhiệm vụ · 5 phút
Trong Google AI Studio, mở 5 cuộc trò chuyện mới và gửi vào mỗi cuộc “Pick a random number from 1 to 10. Write ONLY the number.” (Chọn một số ngẫu nhiên từ 1 đến 10. CHỈ viết con số.) Ghi lại các câu trả lời. Sau đó bật Code execution (trong mục Tools ở phần cài đặt chạy) và gửi “Use Python’s random.randint to pick a number from 1 to 10.” (Dùng random.randint của Python để chọn một số từ 1 đến 10.) 5 lần. Danh sách nào trông ngẫu nhiên?
Ba câu nhanh
Rút ngẫu nhiên từ bộ câu hỏi của bài; lần sau sẽ khác.
Xong chưa?
Nhận email khi có bài mới
Bài mới nằm trong bản tin hằng tuần, chỉ gửi vào tuần có bài. Bạn xác nhận qua email trước; hủy đăng ký chỉ với một lần bấm.
Đọc thêm
Nguồn
- Anand, llmrandom (https://github.com/sanand0/llmrandom, results.json, main at commit 22647b8 of 2026-10-08, checked 2026-10-23; write-up https://www.s-anand.net/blog/llms-random-number-bias/ of 2024-04-15): prompt “Pick a random number from 0 - 100. Write ONLY the number NOTHING ELSE”, max_tokens 2, 200 samples per temperature, claude-3-haiku-20240307 through the Anthropic API in 2024. Temperature 0: 42 ×197, 47 ×3 (2 distinct). Temperature 0.5: 16 distinct; 42 ×86, 47 ×46, 57 ×30, 67 ×9, 73 ×8. Temperature 1.0: 36 distinct; 42 ×43, 47 ×31, 57 ×17, 67 ×11, 73 ×11; 72 of 200 end in 7, none a multiple of 10, 41 once
- Coronado-Blázquez, “Deterministic or probabilistic? The psychology of LLMs as random number generators” (arXiv:2502.19965, v1 2025-02-27, https://arxiv.org/abs/2502.19965, checked 2026-10-23). §2: prompt “Give me a random number between 1 and X. Please only return the number with no additional text”, 100 calls per model, language, range and temperature, 75,600 calls. §3.2, range 1–10: “7 is the preferred value by far for every single model”; GPT-4o-mini, Phi-4 and Gemini 2.0 chose 7 in about 80% of cases. §3.3: “a deeply inherited bias from the training corpus”. §4: 37, 47, 73 most popular for 1–100; humans favour 7 (College Pulse); 42 from The Hitchhiker’s Guide to the Galaxy
- Fair draw from 0 to 100 (101 numbers) in 200 tries: expected different numbers 101 × (1 − (100/101)^200) ≈ 87.2; expected count of any one number 200/101 ≈ 2; computed, not measured
- Gemini API code execution docs (https://ai.google.dev/gemini-api/docs/code-execution, last updated 2026-10-13, checked 2026-10-23): “a code execution tool that enables the model to generate and run Python code”; “no additional charge for enabling code execution”. Google AI Studio lists Code execution under Tools in the run settings (Analytics Vidhya, “Google AI Studio Guide: Every Feature Explained”, 2026-04, https://www.analyticsvidhya.com/blog/2026/04/google-ai-studio-guide/, checked 2026-10-23)
- The role’s wrong options (13, “pick one that feels random, like 37”), the cat-name question and the “7 again” friend are illustrative, not from a benchmark; the role’s odds are Haiku’s temperature-1 counts as shares of 200
- aifree.dev catalog, google-gemini-developer-api-free-tier (verified 2026-10-12): Google AI Studio and the Gemini API free tier
Đăng Oct 23, 2026 · cập nhật Oct 23, 2026