-
I want to generate a list of elements of variable length (this is decided based on additional context provided) and also want each element in the list to follow a particular regex. A trivial example is generating a list of single digit numbers llama2 = models.Transformers("meta-llama/Llama-2-7b-hf", echo=False)
with block("my_text"):
lm = llama2
lm = llama2 + '1 2' + one_or_more(gen(regex='\d', max_tokens=20)) I would assume that this generates something like However, it generates |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I have the same question, the only solution I can think of right now is to prompt the llm to decide how large the list should be using |
Beta Was this translation helpful? Give feedback.
-
Good prompt is the key here. One option would be to prompt the LLM to output "END" when it has completed its list. Another is to increase the temperature and tune other parameters to lean towards random sampling. Giving examples to the LLM really helps as well. |
Beta Was this translation helpful? Give feedback.
I have the same question, the only solution I can think of right now is to prompt the llm to decide how large the list should be using
gen
then use the control flow to then generate a list of the length decided by the model.