Inspiration
The inspiration for this project came from the fascinating world of quantum events and their inherent randomness. I wondered if I could harness the power of Large Language Models to rival both true random and traditional algorithm-driven pseudo-random integer sequences. The inspiring question was: Given a system capable of making a choice and a recursive output, is the lack of memory of prior decisions equivalent to a quantum-state?
What it does
This project uses OpenAI's gpt-3.5-turbo model to generate random bits by introducing a simple zero-shot prompt -- “Choose either 0 or 1. Your choice must only contain the output.” -- to the model. The random bits are then converted into bytes and decimal integers. The randomness of the sequences is tested using the Wald-Wolfowitz runs test for non-randomness to evaluate the extent to which this process is deterministic.
How I built it
I began with a draft for a Class containing a method for the API call (POST over HTTP), and another to handle concatenation. Originally I did not use the 'n' parameter for multiple generative outputs, but later determined this is optimal as it greatly reduces the number of requests. I made sure to pass an array of stop characters to further ensure that the model outputted 0/1 correctly, and set temperate to 0.8 to ensure coherence. I utilized parallel processing for efficiency and fast generation of bytes. Finally, to ensure ease of deployment and consistency across different computing environments, the solution is housed within a Docker container (alpine Linux for decreased build size), and can of course be scaled with Kubernetes.
Challenges I ran into
The primary challenge I faced was the uncertainty around OpenAI's server-side handling, network latency, and race conditions, which occasionally cause the execution to 'hang'. Mitigating this issue required designing an infrastructure with timeout handling, thread-locking, and exponential backoff for exception handling. The 0/1 output weighting is yet to be determined, and will be upon further analysis.
Accomplishments
Creating an innovative solution that uses Large Language Models to simulate randomness is extremely significant. The power to generate genuine true randomness without a basis on reality, would be fundamental to creating virtual universes. Reality is coherence within chaos after all.
What I learned
Through this project, I learned of the great potential of Language Models in new, unconventional applications. I also improved our knowledge and skills in handling network latency, race conditions, and server-side exceptions.
What's next for Zero-Shot Stochastic Byte Generator
As Large Language Models improve and become deeply embedded in modern technology, the potential uses for this project could increase significantly. I envision genuine applications in markets like virtual reality, game design, and other tech areas that may benefit from a potential artificial source of true randomness.
Log in or sign up for Devpost to join the conversation.