77 lines
1.4 KiB
Ruby
77 lines
1.4 KiB
Ruby
# 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: dream, love, exist.
|
|
|
|
poem: the cold is here
|
|
|
|
poem: Remember the rain.
|
|
|
|
poem: The air is light, and the air is cold.
|
|
|
|
poem: It weighs on me.
|
|
|
|
poem: I saw a flower.
|
|
|
|
poem: some flowers grow so quickly
|
|
|
|
poem: the seasons change.
|
|
|
|
poem: there is a bird, a tree, and a squirrel
|
|
|
|
poem: What is an amulet?
|
|
END_OF_PROMPT
|
|
.strip
|
|
.split("\n\n")
|
|
.shuffle
|
|
.join("\n")
|
|
|
|
def doit!
|
|
r, w = IO.pipe
|
|
spawn("#{LLAMA_PATH} --no-display-prompt --gpu APPLE -n 256 -p \"#{PROMPT}\npoem:\"", out: w, err: '/dev/null')
|
|
spawn('ruby extract_poems.rb', in: r)
|
|
Process.wait
|
|
# just in case
|
|
r.close
|
|
w.close
|
|
end
|
|
|
|
n = 0
|
|
# loop do
|
|
# puts "run ##{n += 1}..."
|
|
doit!
|
|
# end
|