News for hackers. Stuff that matters.
Re:Using a Markov chain to generate readable nonsense with 2... by abetusk on Monday January 01, 2024 @03:56AM (#38830524)
As many know and point out, this idea is now very old (40+ years?). The big problem is that it creates "word salad" [0]. In the generative art and procgen community, the term "10,000 bowls of oatmeal" problem has been used [1].

Taking a step back, this is a perennial problem, even with AI old and new. I've heard that the early (good) chess bots, after Deep Blue, had a problem of only being locally context sensitive and being easily fooled by longer range attack planning. We even see it, to a certain extent, in LLMs where they forget or contradict themselves with what was just said. I have no doubt that LLMs will just keep getting better but, as a snapshot of right now, you can see shades of this "word salad" problem, just a few steps removed to become a "logic salad" problem.

[0] https://en.wikipedia.org/wiki/Word_salad

[1] https://galaxykate0.tumblr.com/post/139774965871/so-you-want...

Re:Using a Markov chain to generate readable nonsense with 2... by tgv on Monday January 01, 2024 @08:24AM (#38831622)
Also: it works much better in English than in other languages I know. English grammar is simple, and many of the function words carry a strong prediction for the next tokens.
Re:Using a Markov chain to generate readable nonsense with 2... by echelon on Monday January 01, 2024 @09:06AM (#38831844)
Which languages are harder for LLMs? Is there any writeup or analysis of this?
Re:Using a Markov chain to generate readable nonsense with 2... by tgv on Monday January 01, 2024 @11:29AM (#38833004)
Idk. First, the obvious candidates: those with small, low quality text corpora. Second, I expect LLMs to perform less on long distance dependencies. English has a pretty strict word order, and the constituents are close to each other. There's also a lot of input available, so there are more large gaps to learn from. But (some) Germanic languages have some weird rules which allows constituents to move far away, so it's likely LLMs will make more errors there. Also, free word order languages might be a problem, although I've always suspected that those languages aren't that free in reality: speakers probably have strong preferences.
Re:Using a Markov chain to generate readable nonsense with 2... by tahnyall on Monday January 01, 2024 @10:24AM (#38832383)
If I had to guess, from my time working with ASR (Advanced Speech Recognition) languages and its difficulty with the Indian (country of) accent; I'd guess Indian languages.
Re:Using a Markov chain to generate readable nonsense with 2... by java_beyb on Tuesday January 02, 2024 @09:44AM (#38842101)
what's advanced speech recognition?
Re:Using a Markov chain to generate readable nonsense with 2... by justsomehnguy on Monday January 01, 2024 @11:04AM (#38832771)
Any with inflections and particularly with grammatical gender.
Re:Using a Markov chain to generate readable nonsense with 2... by 3abiton on Monday January 01, 2024 @08:50AM (#38831752)
Any suggestiob on the background of the method?
Re:Using a Markov chain to generate readable nonsense with 2... by tempodox on Monday January 01, 2024 @09:24AM (#38831975)
Do a web search for “Markov chain”.
Re:Using a Markov chain to generate readable nonsense with 2... by tempodox on Monday January 01, 2024 @09:22AM (#38831961)
And the logic salad problem will not be solved by LLMs because there is nothing in their construction that makes them capable of understanding logic.
Re:Using a Markov chain to generate readable nonsense with 2... by brookst on Monday January 01, 2024 @12:01PM (#38833247)
Can you elaborate? I would argue that logic has even stronger token prediction characteristics than language.

As a total handwave, I would expect an LLM trained on formal logic and a huge corpus of proofs to produce pretty strong logic output.

Re:Using a Markov chain to generate readable nonsense with 2... by YeGoblynQueenne on Monday January 01, 2024 @10:32AM (#38832453)
The output is "word salad" because the probabilities of the model are uniform, albeit implicitly- eyballing the python, it selects the next n-gram uniformly at random. A better n-gram model would calculate the probability of an n-gram following another n-gram according to their frequency in the training corpus. With a larger corpus and better training techniques (some smoothing for one thing) you'd get much more coherent output.

And of course, if you trained a gigantic model on the entire web, then you'd get a very smooth approximation of the text in the corpus and very fluent, grammatical output. So basically, an LLM.

>> As many know and point out, this idea is now very old (40+ years?).

More like 110 years. Markov Chains were proposed in 1913 (by Markov) and popularised by Shannon in 1948 (in "A Mathematical Theory of Communication", the work that introduced information theory):

The underlying mathematics of the n-gram was first proposed by Markov (1913), who used what are now called Markov chains (bigrams and trigrams) to predict whether an upcoming letter in Pushkin’s Eugene Onegin would be a vowel or a con- sonant. Markov classified 20,000 letters as V or C and computed the bigram and trigram probability that a given letter would be a vowel given the previous one or two letters. Shannon (1948) applied n-grams to compute approximations to English word sequences. Based on Shannon’s work, Markov models were commonly used in engineering, linguistic, and psychological work on modeling word sequences by the 1950s. In a series of extremely influential papers starting with Chomsky (1956) and including Chomsky (1957) and Miller and Chomsky (1963), Noam Chomsky argued that “finite-state Markov processes”, while a possibly useful engineering heuristic, were incapable of being a complete cognitive model of human grammatical knowl- edge. These arguments led many linguists and computational linguists to ignore work in statistical modeling for decades.

https://web.archive.org/web/20220522005827/https://web.stanf...

(Note the usual shaking of angry fists at Chomsky. The NLP community continued on its path anyway, and built smooth, fluent generators of total bullshit and absolutely no progress towards a "cognitive model of human grammatical knowledge").

Re:Using a Markov chain to generate readable nonsense with 2... by danieldk on Monday January 01, 2024 @11:56AM (#38833200)
The output is "word salad" because the probabilities of the model are uniform, albeit implicitly- eyballing the python, it selects the next n-gram uniformly at random.

From a quick look, it doesn't seem to sample uniformly. w3 is added to a list for the context w1, w2, not a set. So, say word A occurs twice as often in a particular context as B, it will be in the list twice as often. So, even though a uniform choice function is used, the probability of A getting samples is twice as high.

You get a word salad because a trigram model has to little context to do anything else. This is a well-known issue with Markov and hidden Markov models.

(Fun fact: some hidden Markov model taggers switch to a different trigram distribution for V2 languages after seeing the finite verb, otherwise they often fail catastrophically in the verb cluster due to the limited context.)

Re:Using a Markov chain to generate readable nonsense with 2... by YeGoblynQueenne on Monday January 01, 2024 @06:49PM (#38836421)
>> From a quick look, it doesn't seem to sample uniformly. w3 is added to a list for the context w1, w2, not a set. So, say word A occurs twice as often in a particular context as B, it will be in the list twice as often. So, even though a uniform choice function is used, the probability of A getting samples is twice as high.

Yeah, you're right. I had to squint a bit but it's like you say, the code is sampling uniformly from a list with possible multiples. Don't make me squint man! I'll get wrinkles :P

Squinting a bit more, that's not the way I know how to build n-grams. If you gave me the string (the cat sat on the bat) I'd give you bi-grams ($s the), (the cat), (cat sat), (sat on), (on the), (the bat), (bat $e). That way, after the first bigram, the next word only depends on the second word in the last bigram, because every bigram (w1 w2) is only ever followed by a bigram (w2 w3). So you're sliding a window of length 2 over the corpus, guided by the probability of the next word.

>> You get a word salad because a trigram model has to little context to do anything else. This is a well-known issue with Markov and hidden Markov models.

Yes, it's the Markov property that makes for word salad, ultimately, but you get less salad-y output if you can calculate better probabilities, and if you do it in the way I say above. And you can always build a string by selecting the next bigram that maximises the probability of the entire string. That's how I've always done it. I guess that's not Markovian any more but gives you reasonable output especially for small-ish corpora with not huge variance.

>> (Fun fact: some hidden Markov model taggers switch to a different trigram distribution for V2 languages after seeing the finite verb, otherwise they often fail catastrophically in the verb cluster due to the limited context.)

Thanks, I didn't know that.

Re:Using a Markov chain to generate readable nonsense with 2... by shawnz on Monday January 01, 2024 @11:07AM (#38832802)
> A better n-gram model would calculate the probability of an n-gram following another n-gram according to their frequency in the training corpus. With a larger corpus and better training techniques (some smoothing for one thing) you'd get much more coherent output.

I don't understand what you mean here, isn't that exactly what an n-gram model is already designed to achieve where n > 1? Since this is a 2-gram model isn't it already doing this?

Re:Using a Markov chain to generate readable nonsense with 2... by YeGoblynQueenne on Monday January 01, 2024 @07:14PM (#38836576)
That's right, but a bi-gram model is just a big table of bi-grams and their probabilities (which are really their frequencies in a corpus normalised over the number of all bigrams in the corpus). You can use those probabilities in two ways: to calculate the probability of a string, by taking the bigrams in the string and multiplying their probabilities together; or by starting with some bigram (e.g. a search term entered by a user) and then selecting the next bigram according to its probability (i.e. its frequency in the corpus), or according to the probability of the entire string so-far (which you get by multiplying the probabilities of the bigrams so far); and repeat until you reach some maximum string-length.

So you're right that my comment is a bit confusing: I refer to the way you sample from a bi-gram model, so as to generate a string. Sorry!

Re:Using a Markov chain to generate readable nonsense with 2... by jameshart on Monday January 01, 2024 @02:51PM (#38834777)
> absolutely no progress towards a "cognitive model of human grammatical knowledge"

The thing is, it's only if you buy fully into Chomskyan thinking that you think a "cognitive model of human grammatical knowledge" might even be useful. Or that it's a particularly special thing compared to any other cognitive model of human knowledge.

Re:Using a Markov chain to generate readable nonsense with 2... by doubloon on Monday January 01, 2024 @12:28PM (#38833470)
i put Alexis De Tocqueville through this and the results were legible but hard to read.

Then I put a demagogue politician speech through this and the results were almost like a speech that politician would have given. It was hard to tell the difference between the original and the generated.

in other words, if the public admires word salad, and someone speaks in word salad, then word salad output would not be considered as problematic by a large number of people.

Re:Using a Markov chain to generate readable nonsense with 2... by hermitcrab on Monday January 01, 2024 @01:20PM (#38833943)
I did a markov reworking of some of Trump's speeches and got:

"Hillary brought death and disaster to Iraq, Syria and Libya, she empowered Iran, and she unleashed ISIS. Now she wants to raise your taxes very substantially. Highest taxed nation in the world is a tenant of mine in Manhattan, so many great people. These are people that have been stolen, stolen by either very stupid politicians ask me the question, how are you going to get rid of all the emails?” “Yes, ma’am, they’re gonna stay in this country blind. My contract with the American voter begins with a plan to end government that will not protect its people is a government corruption at the State Department of Justice is trying as hard as they can to protect religious liberty"

Details at: https://successfulsoftware.net/2019/04/02/bloviate/

Re:Using a Markov chain to generate readable nonsense with 2... by vorticalbox on Monday January 01, 2024 @01:59PM (#38834343)
When ngrams is high (10) how do you pick "what" to start from?
Re:Using a Markov chain to generate readable nonsense with 2... by hermitcrab on Monday January 01, 2024 @02:23PM (#38834548)
IIRC it starts with the same few characters as the source text.
Re:Using a Markov chain to generate readable nonsense with 2... by chuckadams on Monday January 01, 2024 @12:52PM (#38833667)
I recall one site way back that used a Markov chain generator to mash up Karl Marx and Ayn Rand. Was fairly plausible reading, actually.
Re:Using a Markov chain to generate readable nonsense with 2... by nurettin on Monday January 01, 2024 @01:34PM (#38834112)
I imagine that's like mixing different kinds of salad.
Re:Using a Markov chain to generate readable nonsense with 2... by chuckadams on Wednesday January 03, 2024 @01:57PM (#38858141)
It definitely gives you some whiplash, but most of the time it's just righteous ranting about ... whatever. The whole site was a trove of comedy, featuring quizzes like "Porn Star or My Little Pony?". I couldn't remember its name until I started typing this reply: lileks.com.