poem_loop
This commit is contained in:
parent
cb549c5988
commit
5058285c72
5 changed files with 180 additions and 49 deletions
46
Cargo.lock
generated
46
Cargo.lock
generated
|
@ -26,6 +26,31 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-deque"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d"
|
||||
dependencies = [
|
||||
"crossbeam-epoch",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-epoch"
|
||||
version = "0.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.1.6"
|
||||
|
@ -82,9 +107,30 @@ name = "pearls"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"itertools",
|
||||
"rayon",
|
||||
"sha2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon"
|
||||
version = "1.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa"
|
||||
dependencies = [
|
||||
"either",
|
||||
"rayon-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon-core"
|
||||
version = "1.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2"
|
||||
dependencies = [
|
||||
"crossbeam-deque",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.10.8"
|
||||
|
|
|
@ -5,4 +5,5 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
itertools = "0.13.0"
|
||||
rayon = "1.10.0"
|
||||
sha2 = "0.10.8"
|
||||
|
|
19
extract_poems.rb
Normal file
19
extract_poems.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
MIN_8S = 0
|
||||
|
||||
def max_8s(str)
|
||||
(str.scan(/8+/).max || '').length
|
||||
end
|
||||
|
||||
$stdin.read.split('poem: ')
|
||||
.map(&:strip)
|
||||
.reject(&:empty?)
|
||||
.to_set
|
||||
.map { [_1, `printf "#{_1}" | openssl sha256`.strip] }
|
||||
.filter { |(_, hash)| max_8s(hash) >= MIN_8S }
|
||||
.sort_by { |(_, hash)| max_8s hash }
|
||||
.each do |(amulet, hash)|
|
||||
puts amulet
|
||||
puts "#{max_8s hash} #{hash}#{amulet.length > 64 ? ' too long!' : ''}"
|
||||
end
|
52
poem_loop.rb
Normal file
52
poem_loop.rb
Normal file
|
@ -0,0 +1,52 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
LLAMA_PATH = "#{Dir.home}/Downloads/Meta-Llama-3-8B-Instruct.Q5_K_M.llamafile"
|
||||
|
||||
PROMPT = <<~END_OF_PROMPT
|
||||
poem: If you can't write poems,
|
||||
write me
|
||||
|
||||
poem: IN THE SPRING MY LUNGS
|
||||
STILL SOMEHOW EXPAND.
|
||||
|
||||
poem: A MAN ONCE MAILED ME
|
||||
A PIECE OF HIS HEART
|
||||
|
||||
poem: THIS AMULET
|
||||
AT ANY PRICE
|
||||
FELT LIKE THE TRUTH
|
||||
|
||||
poem: this amulet is a simple token which proves my love's truth
|
||||
|
||||
poem: sphinx of black quartz, judge my vow
|
||||
|
||||
poem: DON'T WORRY.
|
||||
|
||||
poem: in the early hours of the new year
|
||||
i lie on my back
|
||||
waiting.
|
||||
|
||||
poem: All my life I had this
|
||||
image of what a poet
|
||||
should be
|
||||
|
||||
poem: Winter evening, a leaf, a blue sky above.
|
||||
|
||||
poem: Lethargically good.
|
||||
|
||||
poem:
|
||||
END_OF_PROMPT
|
||||
.strip
|
||||
|
||||
def doit!
|
||||
r, w = IO.pipe
|
||||
spawn("#{LLAMA_PATH} --no-display-prompt --gpu APPLE -n 128 -p \"#{PROMPT}\"", out: w, err: '/dev/null')
|
||||
spawn('ruby extract_poems.rb', in: r)
|
||||
Process.wait
|
||||
# just in case
|
||||
r.close
|
||||
w.close
|
||||
end
|
||||
|
||||
doit!
|
||||
doit!
|
111
src/main.rs
111
src/main.rs
|
@ -1,7 +1,11 @@
|
|||
use std::process::exit;
|
||||
|
||||
use itertools::Itertools;
|
||||
use rayon::prelude::*;
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
// we could be smart with prefixes
|
||||
#[allow(clippy::too_many_lines)]
|
||||
fn main() {
|
||||
let choices = [
|
||||
vec![
|
||||
|
@ -40,47 +44,47 @@ fn main() {
|
|||
vec!["this sentence", "this message", "this piece of digitext"],
|
||||
vec![" has "],
|
||||
vec![
|
||||
"seven",
|
||||
"7",
|
||||
"7 (seven)",
|
||||
"seven (7)",
|
||||
"7!",
|
||||
"7(!)",
|
||||
"seven!",
|
||||
"seven(!)",
|
||||
"7!!",
|
||||
"7(!!)",
|
||||
"seven!!",
|
||||
"seven(!!)",
|
||||
"7!!!",
|
||||
"7(!!!)",
|
||||
"seven!!!",
|
||||
"seven(!!!)",
|
||||
"7!!!!!!!",
|
||||
"7(!!!!!!!)",
|
||||
"seven!!!!!!!",
|
||||
"seven(!!!!!!!)",
|
||||
"ten",
|
||||
"10",
|
||||
"10 (ten)",
|
||||
"ten (10)",
|
||||
"10!",
|
||||
"10(!)",
|
||||
"ten!",
|
||||
"ten(!)",
|
||||
"10!!",
|
||||
"10(!!)",
|
||||
"ten!!",
|
||||
"ten(!!)",
|
||||
"10!!!",
|
||||
"10(!!!)",
|
||||
"ten!!!",
|
||||
"ten(!!!)",
|
||||
"10!!!!!!!!!!",
|
||||
"10(!!!!!!!!!!)",
|
||||
"ten!!!!!!!!!!",
|
||||
"ten(!!!!!!!!!!)",
|
||||
],
|
||||
vec![" "],
|
||||
vec![
|
||||
"7s",
|
||||
"sevens",
|
||||
"7s!",
|
||||
"7s(!)",
|
||||
"sevens!",
|
||||
"sevens(!)",
|
||||
"7s!!",
|
||||
"7s(!!)",
|
||||
"sevens!!",
|
||||
"sevens(!!)",
|
||||
"7s!!!",
|
||||
"7s(!!!)",
|
||||
"sevens!!!",
|
||||
"sevens(!!!)",
|
||||
"7s!!!!!!!",
|
||||
"7s(!!!!!!!)",
|
||||
"sevens!!!!!!!",
|
||||
"sevens(!!!!!!!)",
|
||||
"0s",
|
||||
"zeroes",
|
||||
"0s!",
|
||||
"0s(!)",
|
||||
"zeroes!",
|
||||
"zeroes(!)",
|
||||
"0s!!",
|
||||
"0s(!!)",
|
||||
"zeroes!!",
|
||||
"zeroes(!!)",
|
||||
"0s!!!",
|
||||
"0s(!!!)",
|
||||
"zeroes!!!",
|
||||
"zeroes(!!!)",
|
||||
"0s!!!!!!!!!!",
|
||||
"0s(!!!!!!!!!!)",
|
||||
"zeroes!!!!!!!!!!",
|
||||
"zeroes(!!!!!!!!!!)",
|
||||
],
|
||||
vec![" "],
|
||||
vec![
|
||||
|
@ -101,16 +105,25 @@ fn main() {
|
|||
vec![" "],
|
||||
vec!["somewhat ", "pretty ", "quite ", "very ", "decently ", ""],
|
||||
vec!["fun", "nice", "sweet", "pleasant", "cool", "interesting"],
|
||||
vec![" "],
|
||||
vec![
|
||||
":)", ":D", ":))", ":)))", "XD", ":B", ">:)", ">:D", ">XD", ">:B", "B)", "BD", ">B)",
|
||||
">BD", "(:", "((:", "(((:", "(:<",
|
||||
],
|
||||
];
|
||||
for selection in choices.into_iter().multi_cartesian_product() {
|
||||
let mut hasher = Sha256::new();
|
||||
for choice in &selection {
|
||||
hasher.update(choice);
|
||||
}
|
||||
let digest = hasher.finalize();
|
||||
if format!("{digest:x}").contains("7777777") {
|
||||
println!("{}", selection.join(""));
|
||||
println!("{digest:x}");
|
||||
}
|
||||
}
|
||||
choices
|
||||
.into_iter()
|
||||
.multi_cartesian_product()
|
||||
.par_bridge()
|
||||
.for_each(|selection| {
|
||||
let mut hasher = Sha256::new();
|
||||
for choice in &selection {
|
||||
hasher.update(choice);
|
||||
}
|
||||
let digest = hasher.finalize();
|
||||
if format!("{digest:x}").contains("0000000000") {
|
||||
println!("{}\n{digest:x}", selection.join(""));
|
||||
exit(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue