dspy icon indicating copy to clipboard operation
dspy copied to clipboard

tree-of-thoughts-implementation

Open JamesScharf opened this issue 1 year ago • 5 comments
trafficstars

Hello! I think it would be very helpful for there to be a tutorial on how to add new primitive modules (e.g., Chain of Thought, Chain of Thought with Hint, etc.). It's not clear to me how I would add a method like Tree of Thoughts, for example.

If there's a rather straightforward way to do this and I've missed something, I'd be happy to throw together a tutorial notebook.

JamesScharf avatar Dec 03 '23 15:12 JamesScharf

@saifulhaq8 is working on something directly related

okhat avatar Dec 28 '23 01:12 okhat

When implementing Tree Of Thought in the past, I've found that you can save a lot of compute if your language model supports Key/Value caching. That is, when you branch from a node, you typically give each child all the text input/output of its ancestors. But it's not efficient running the transformer model on all of those identical tokens again.

Obviously you can't do key/value caching with most API'ed models, like OpenAI's. But you can do with with hugging face's transformer library.

thomasahle avatar Feb 01 '24 21:02 thomasahle

Sglang does this well

AriMKatz avatar Feb 01 '24 22:02 AriMKatz

I implemented Tree of Thought in DSPy here: https://github.com/stanfordnlp/dspy/compare/main...thomasahle:dspy:main But it is not very good yet. Comments are very welcome.

thomasahle avatar Feb 02 '24 07:02 thomasahle

It was merged into main? Can you please drop a link to PR.

It was merged into main? Can you please drop a link to PR.

Somebi avatar Apr 09 '24 11:04 Somebi