zou-group / textgrad

Automatic ''Differentiation'' via Text -- using large language models to backpropagate textual gradients.
http://textgrad.com/
MIT License
944 stars 67 forks source link

How to use with RAG? #34

Open v5out opened 6 days ago

v5out commented 6 days ago

TextGrad is exciting! Very much appreciate your efforts.

How to apply textgrad to retrieval-augmented-generation (RAG) for question & answer?

With RAG there are three inputs: the source material (text), the question and the answer (which needs to be evaluated and improved).

Not clear to me how to handle those with one or more Variables, etc.

Something like?

x = Variable("Source material: "+ + " and a question about it: " + [question], role_description="Answering a question on source material", requires_grad=True)