Skip to main content

Markov chain generator with rudimentary prompt response

Project description

Conversational Markov

LLMs don't normally sound like they're talking to you. The LLM in its most basic state simply continues the text it's given. LLMs sound like they're talking to you when they're set up to complete one side of a conversation.

Technically, there's nothing stopping you from making a Markov chain that does this, too. Train it on runs that have a prompt and a response, delineated by a sentinel token, and then, during inference, you can make the starting state any given prompt followed by the sentinel, and it will autocomplete something that sounds like a fitting response.

This project explores that.
Now, practically, there are reasons Markov chains are not typically used this way: state size would increase linearly with every extra word you want to be able to prompt with, and model size will correspondingly increase exponentially. With just a handful of prompt words and a decent sized corpus, you'll be running out of memory trying to load the whole thing.
But still, I wanted to try it, because LLM inference takes a lot of compute, meanwhile Markov chain generators don't. What I can get away with on a €5 Hetzner box?

This project is a naïve example of a framework around a Markov chain which sets it up to respond to prompts. It uses a state size of 3, enough to allow it to process just the first and last word of a prompt plus the sentinel token. When you prompt it with something it's seen before, it really does make more coherent-seeming responses than a conventional Markov chain does from a random state.

Avenues for improvement:

  • Decouple token length of prompt from state size of response generation. I.e., allow a longer starting state to increase number of tokens that can be included in the prompt without also having to increase the state size used to generate the response. State size of 3 is already pretty large for making remotely original sounding responses, but at the same time, it's really small for ingesting a prompt. A Dynamic State Size Markov Chain?

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

conversational_markov-0.1.4.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

conversational_markov-0.1.4-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file conversational_markov-0.1.4.tar.gz.

File metadata

  • Download URL: conversational_markov-0.1.4.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for conversational_markov-0.1.4.tar.gz
Algorithm Hash digest
SHA256 b2a81312a25aca1a75d459bf1c7524c201d6d8f599311fba68e6bc3c11081e64
MD5 c164b86fccd210c722176487cd807a11
BLAKE2b-256 5592918b734e053e708a649139a5deacdf06bb3f1096b25263323ff386ef7d8a

See more details on using hashes here.

Provenance

The following attestation bundles were made for conversational_markov-0.1.4.tar.gz:

Publisher: python-publish.yml on nate-kean/conversational-markov

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file conversational_markov-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for conversational_markov-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 0d29a5ed30b38527cdc5a3de4af91642e0c9c3cc2f2709f77f0872ac5f726048
MD5 76f645b64b4b611befbfdc21ab63dbe6
BLAKE2b-256 db92311db260d1b600528a3bdff6d26464f60c4684c54e8f63ff0320ba1574c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for conversational_markov-0.1.4-py3-none-any.whl:

Publisher: python-publish.yml on nate-kean/conversational-markov

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page