simedw ~ $ claude -p "random number between 1 and 10"
7
simedw ~ $ claude -p "random number between 1 and 10"
7
simedw ~ $ claude -p "random number between 1 and 10"
7
simedw ~ $ claude -p "random number between 1 and 10"
7Overall, yeah don't generate passwords with LLMs but is this really a surprise that answers are simillar for the same prompt in every new chat with a LLM?
Some early testing I found that injecting a "seed" only somewhat helped. I would inject a sentance of random characters to generate output.
It did actually imrpove its ability to make unique content but it wasn't great.
It would be cool to formaile the test for something like password generation.
However, "make my a python script the generates a random password" works.
Skill issue.
If you say: "Generate a strong password using Python", then Claude will write code using the `secrets` module, execute it, and report the result, and you'll actually get a strong password.
To get good results out of an LLM, it's helpful to spend a few minutes understanding how they (currently) work. This is a good example because it's so simple.
Given that Claude already has the ability to write and execute code, it's not obvious to me why it should, in principle, need an explicit nudge. Surely it could just fulfil the first request exactly like it fulfils the second.
Maybe in the future companies making the models will train them specifically on when to require a source of true randomness and they might start writing code for it.
For example:
tr -cd "[:alnum:]" < /dev/urandom | fold -w 20 | sed 10q
Change "alnum" to "print" to get other characters. This will generate 10 20 characters passwords.
shuf -i 1-10 -n1
10
shuf -n1 /usr/share/dict/usa
saltier
# random 24 char
base64 /dev/urandom | tr -d '/+' | dd bs=24 count=1 2>/dev/null;echo
5seFtWG09vTUc0VCMb3BJ6Al
# random letter
base64 /dev/urandom | tr -d '/+' | sed s/[^[:alpha:]]//g | tr 'A-Z' 'a-z' | dd bs=1 count=1 2>/dev/null;echo
x
# bash
echo $RANDOM
21178 openssl rand --base64 18gpg --gen-random --armor 1 20
or:
pwgen