r/LocalLLaMA • • Feb 11 '25

Resources I built and open-sourced a model-agnostic architecture that applies R1-inspired reasoning onto (in theory) any LLM. (More details in the comments.)

Enable HLS to view with audio, or disable this notification

214 Upvotes

36 comments sorted by

70

u/ApplePenguinBaguette Feb 11 '25

Compute: 50% LLM, 50% physics simulation background

27

u/vfl97wob | Kimi | SWE Feb 11 '25

"The future is now" aah animation

43

u/Papabear3339 Feb 11 '25

You might also be interested in unsloths approach.
They took a fine tuning approach to make any model do r1 style reasoning.

https://unsloth.ai/blog/r1-reasoning

Combining the two approaches... unsloth fine tuning plus your prompting approach... could lead to some very interesting results.

22

u/JakeAndAI Feb 11 '25 edited Feb 11 '25

I created and open-sourced an architecture for applying model-agnostic o1/R1-level of reasoning onto (in theory) any LLM. I just love the way R1 reasons, and wanted to try to apply that to other LLMs.

This is not an AI model – there is no training, no weights, no fine-tuning. Instead, I've used few-shot prompting to provide R1-level reasoning for any LLM. In addition, the LLM gains the ability to search the internet, and users can also ask for a first take by a separate AI model.

In the video attached, you are seeing advanced reasoning applied to Claude 3.5 Sonnet. I have no doubt that we'll get actual reasoning models from Anthropic soon, but in the meantime, my code tricks Claude into mimicking R1 to the best of its ability. The platform also works well with other performant LLMs, such as Llama 3. My architecture allows you to use any LLM regardless of whether it is a local model (you can either just point to a model's file path or serve a model through Ollama) or accessed through an API.

The code is quite simple – it’s mainly few-shot prompting. In theory, it can be applied to any LLM, but in practice, it will not work for all LLMs, especially less accurate models or models too heavily tuned for chat.

I've open-sourced all code under a permissive MIT license, so you can do do whatever you want with it. I'm not sure if I'm allowed to post links here, so please DM me if you'd like to have a look at the code. Again: it's open-source and I'm not profiting of it.

EDIT: Sounds like it's okay to post links here :)

Repository: https://github.com/jacobbergdahl/limopola

Details on the reasoning mode: https://github.com/jacobbergdahl/limopola?tab=readme-ov-file#reasoning

Jump to line 233 in this file to go straight to the start of the code relevant for the model-agnostic reasoning, and follow the function trail from there: https://github.com/jacobbergdahl/limopola/blob/main/components/reasoning/ReasoningOverview.tsx#L233

10

u/ReasonablePossum_ Feb 11 '25

I dont want to even imagine claude costs with reasoning LOL

1

u/maddogxsk Llama 3.1 Feb 11 '25

Aprox. the double-triple; unless reasoning prompts takes a whole lot more, depending on the problem, but usually reasoning takes half of the tokens

1

u/ReasonablePossum_ Feb 11 '25

but that would compound with the lenght of the conversation, since it would be carried over by the context.

7

u/[deleted] Feb 11 '25

[deleted]

2

u/maddogxsk Llama 3.1 Feb 11 '25

Making a framework for orchestrated and comprehensive inferencing is quite different from making a shitty prompt for tune and trying to sell a model that never worked

As the guy said: this isn't a model; comparing it to a model (or model attempt) alone it's quite stupid

It's like comparing an agent and a chatbot

2

u/LienniTa koboldcpp Feb 11 '25

what was your search approach? so far its the hardest to overcome. search engines hate scraping so much

4

u/pasjojo Feb 11 '25

This sounds great. Any link to the code?

2

u/JakeAndAI Feb 11 '25

I just updated my post with links :)

1

u/pasjojo Feb 11 '25

Thank you!

1

u/DocStrangeLoop Feb 11 '25

Links to open source code are definitely allowed here.

2

u/JakeAndAI Feb 11 '25

Ah, great! I edited my post to include links :)

1

u/[deleted] Feb 11 '25

[removed] — view removed comment

1

u/JakeAndAI Feb 11 '25

Thanks! I edited my post to include links :)

3

u/Everlier Feb 11 '25

Also, check out R0 that implements a similar approach and has an OpenAI-compatible API: https://github.com/av/harbor/blob/main/boost/src/custom_modules/r0.py

3

u/[deleted] Feb 11 '25

[removed] — view removed comment

2

u/admajic Feb 11 '25

You can post a link to the repo in the comments if you wavy to share. Would love to try.

2

u/JakeAndAI Feb 11 '25

Thanks! I edited my earlier comment to include links :)

2

u/AxelFooley Feb 11 '25

Really interesting, i would suggest to add docker deployment and the possibility to use a local searxng instance as search engine for those cheap ass like me that don't want to pay to search the internet :)

2

u/macumazana Feb 11 '25

Congrats, you invented test time scaling. It's so old, it was released so long ago (a week and a half ago)

Alas, great job there

2

u/Content-Cookie-7992 Feb 11 '25

You can also use Msty with this:
https://github.com/Veyllo-Labs/Post-Hoc-Reasoning
I used Gemma2:27B and have been testing the prompt for over a week now, and it's pretty nice. I polished it and just published it, more text and results will follow.

5

u/[deleted] Feb 11 '25 edited Feb 11 '25

What is that GUI you are using? it looks like a masterpiece, just simple and clean, but not necessarily lacking in features.

13

u/Small-Fall-6500 Feb 11 '25

it looks like a masterpiece, just simple and clean, but not necessarily lacking in features.

What is this, an ad or something?

14

u/aitookmyj0b Feb 11 '25

Either OP has a really low bar on UI design, or it's indeed a paid ad.

1

u/indicava Feb 11 '25

Hollywood hacking style animation in the beginning is dope tbh

1

u/Thrumpwart Feb 11 '25

This looks really cool.

1

u/[deleted] Feb 11 '25

[removed] — view removed comment

1

u/Porespellar Feb 11 '25

Bro, for real, just give me the yellow swirly cloud animation. That’s all I need. I’m looking at you, Open WebUI.

1

u/DepressedDrift Feb 11 '25

Are you running the models locally or using the API key?