Skip to content

How to provide the model with an example of a particular operation on text? #640

Closed Answered by LizeRaes
jarosik83 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @jarosik83 , you can use the few-shot approach where you 'fake' the memory: prefill a ChatMemory with a couple of examples (UserMessage: your short text; AiMessage: the keyword or result you want to get; UserMessage: another example; AiMessage: the desired result for that; ...). It works pretty awesome. You can see an example here (works pretty flawless with only 2 positive and 2 negative examples): https://github.com/langchain4j/langchain4j-examples/blob/main/tutorials/src/main/java/_06_FewShot.java

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jarosik83
Comment options

Answer selected by LizeRaes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants