
2025/12/14 5:19
I fed 24 years of my blog posts to a Markov model
RSS: https://news.ycombinator.com/rss
要約▶
Japanese Translation:
この記事では、GitHub(github.com/susam/mvs)にホストされている「Mark V. Shaney Junior」という30行程度の小さなPythonプログラムを紹介しています。これはシンプルさを優先した軽量マルコフテキストジェネレータで、速度や精度よりも簡潔さを重視しています。コードはデフォルトで三項モデル(順序 2)を使用しますが、コマンドラインオプションで順序を変更できるようになっており、順序が高くなるほど出力は少しずつ一貫性が増します。一方、順序 5になると著者自身のブログ投稿を逐語的に引用する傾向があり、結果として乾燥した文章になります。
学習データは作者の24年間分のブログ記事(約20万語)で構成されており、意図的に500件のコメント(約4万語)は除外されています。READMEに掲載されている例出力は、コーパスの200語サブセットと全24年分を用いて生成したものです。ジェネレータは初期プロンプトを受け取ることができ、例えば
./mvs 2 100 'Finally we' < susam.txt のように実行すると100語程度のサンプルが作られます。
著者はマルコフ連鎖は現代の大規模言語モデル(LLM)と比べて長距離の文脈を持たないことを指摘しています。このプロジェクトは同名の1980年代プログラムに触発され、作者が探索的スクリプトをディスク上に保持し、それらをGitHubとCodebergの両方でリポジトリとして公開する習慣を反映しています。各リポジトリには README.md と CHANGES.md が付属しています。生成されるゴブストは作者自身の投稿から抜粋されたフラグメント(例: 「Lisp source file」や「self‑esteem」)を含むことが多いです。その制約にもかかわらず、最小限の実装であるため、重いリソースを必要とせずに言語モデリングを試したいホビイストや教育者にとってアクセスしやすい入門点となります。
本文
Susam Pal(2025年12月13日)
昨日、私は GitHub(github.com/susam/mvs)で Mark V. Shaney Junior という小さなプログラムを共有しました。これは、1980年代の伝説的な Mark V. Shaney プログラムからインスパイアされたマルコフテキストジェネレータの最小実装です。知らない方は Wikipedia をご覧ください。
このプログラムは Python で約30行ほどと、効率よりもシンプルさを重視しています。趣味として、私は「アイデアやトピックを純粋に遊びながら探求する」探索的コードを書きます。マルコフ連鎖をさまざまな状態空間で試すためのスニペットを何十個も書いており、その都度最新の実験コードを調整して一回限りの Git リポジトリとして公開しています。
README をスクロールすると、プログラムが生成したガビア(文字列)の例が掲載されています。最初の数例は A Christmas Carol(チャールズ・ディケンズ著)を学習させたものです。デキンズは必要以上に語彙を減らすことで知られ、極小マルコフモデルのテストに理想的な作者とされています。生成されたテキスト自体はここでは省略しますが、README の Gibberish セクションでご確認いただけます。
プロジェクトを共有した後、私のブログ投稿(24 年分)すべてを入力してみたらどんなガビアになるか気になりました。以下はその一例です。
$ ./mvs < susam.txt while a query replace operation is approved by the user. The above variable defines the build job. It can be incredibly useful while working on assembly language and machine code. In fact, all internal resources like the result to refine the search prompt changes from bck-i-search: to fwd-i-search:. Now type C-SPC (i.e. ctrl+space) to set a mark causes Emacs to use 32‑bit registers like EBP, ESP, etc. Thus the behaviour is undefined. Such code may behave differently when compiled with the readily available GNU tools like the shape of 8. Flipping "P" horizontally makes it a proper quine: cat $0
これは、200 本以上(約20万語)を学習させた後に出てきたテキストです。ブログにはコメント欄があり、500 件以上(≈4 万語)ありますが、これらは学習から除外しています。
もう一例をご紹介します。
$ ./mvs < susam.txt enjoy asking "what happens if" and then type M‑x zap-up-to-char RET b. The buffer for this specific video, the actual fare for 8.3 km and 11 are all written from scratch. No prior knowledge is expected to slow down in future. For now, I will add a statement like x = 0.999..., the inner corner square as discussed in the code segment into the REPL window. Unlike Slimv, Vlime can work with and debug executable files, it can be more convenient. M‑x: Execute Extended Command The key sequence M‑q invokes the command cat and type TAB to indent the
さらに、特にまとまりのない面白い例です。
$ ./mvs < susam.txt Then open a new Lisp source file and the exact answer could harm students' self-esteem. Scientists have arbitrarily assumed that an integral domain. However, the string and comment text. To demonstrate how a build job can trigger itself, pass input to standard output or standard error), Eshell automatically runs the following command in Vim and Emacs will copy the message length limit of 512 characters, etc. For example, while learning to play the game between normal mode to move the point is on an old dictionary lying around our house and that is moving to the small and supportive community
「Lisp ソースファイルを開くと誰かの自尊心が傷つく」という主張は決して言っていません。ジェネレータは私の Lisp in Vim と From Perl to Pi という投稿からそれぞれ「Lisp source file」と「self‑esteem」を拾った結果です。
デフォルトでは、このプログラムは三語連(トリグラム)を見ます。最初の二語がキーになり、第三語がその値としてリストに追加されます。モデルは隣接する単語ペアと次の単語を記録し、ランダムにキーを選んでフォロワーから一つを取り出す仕組みです。
2025 年では大規模言語モデル(LLM)が主流ですが、マルコフモデルはそれほど印象的に見えません。LLM と異なり、単純なマルコフモデルはグローバル構造や長距離依存を捉えられず、完全に局所的な語彙遷移統計に頼ります。それでもそのシンプルさが言語モデリングへの入り口として優れているのです。
実装ではコマンドライン引数でキーサイズ(モデルの階数)を設定できます。デフォルトは 2(順序 2)ですが、3 や 4 に増やすと少しだけまとまりのあるテキストが生成されます。以下にその例を示します。
$ ./mvs 4 < susam.txt It is also possible to search for channels by channel names. For example, on Libera Chat, to search for all channels with 'python' in its name, enter the IRC command: /msg alis list python. Although I have used Libera Chat in the examples above, there are plenty of infinite fields, so they must all be integral domains too. Consider the field of rational numbers Q. Another quick way to arrive at this fact is to observe that when one knight is placed on a type D square, only two positions for the second knight such that the two knights attack
ほんの数個の突発的で意味不明な遷移を除けば、テキストは大体まとまりがあります。階数を高くしすぎると出力が乾燥し、ブログ投稿をそのまま引用するようになります。
最後に、「Finally we」で始まる 100 語を生成させた例です。
$ ./mvs 2 100 'Finally we' < susam.txt Finally we divide this number by a feed aggregrator for Emacs‑related blogs. The following complete key sequences describe the effects of previous evaluations shall have taken a simple and small to contain bad content. This provides an interactive byte‑compiled Lisp function in MATLAB and GNU bash 5.1.4 on Debian is easily reproducible in Windows XP. Older versions might be able to run that server for me it played a significant burden …
もし私が実際にガビアを話すとしたら、こんな風になるでしょう。