g1_demo.1.mp4
仅仅 streamlit run o1_groq.py
更新了最新界面
This is an early prototype of using prompting strategies to improve the LLM's reasoning capabilities through o1-like reasoning chains. This allows the LLM to "think" and solve logical problems that usually otherwise stump leading models. Unlike o1, all the reasoning tokens are shown, and the app uses an open source model.
g1 is experimental and being open sourced to help inspire the open source community to develop new strategies to produce o1-like reasoning. This experiment helps show the power of prompting reasoning in visualized steps, not a comparison to or full replication of o1, which uses different techniques. OpenAI's o1 is instead trained with large-scale reinforcement learning to reason using Chain of Thought, achieving state-of-the-art performance on complex PhD-level problems.
g1 demonstrates the potential of prompting alone to overcome straightforward LLM logic issues like the Strawberry problem, allowing existing open source models to benefit from dynamic reasoning chains and an improved interface for exploring them.
g1 powered by Llama3.1-70b creates reasoning chains, in principle a dynamic Chain of Thought, that allows the LLM to "think" and solve some logical problems that usually otherwise stump leading models.
At each step, the LLM can choose to continue to another reasoning step, or provide a final answer. Each step is titled and visible to the user. The system prompt also includes tips for the LLM. There is a full explanation under Prompt Breakdown, but a few examples are asking the model to “include exploration of alternative answers” and “use at least 3 methods to derive the answer”.
The reasoning ability of the LLM is therefore improved through combining Chain-of-Thought with the requirement to try multiple methods, explore alternative answers, question previous draft solutions, and consider the LLM’s limitations. This alone, without any training, is sufficient to achieve ~70% accuracy on the Strawberry problem (n=10, "How many Rs are in strawberry?"). Without prompting, Llama-3.1-70b had 0% accuracy and ChatGPT-4o had 30% accuracy.
Important
g1 is not perfect, but it can perform significantly better than LLMs out-of-the-box. From initial testing, g1 accurately solves simple logic problems 60-80% of the time that usually stump LLMs. However, accuracy has yet to be formally evaluated. See examples below.
- Prompt: "Use at least 3 methods to find the number of Rs in the word 'strawberry'."
- Step 1: Count characters manually.
- Step 2: Check the result by comparing against other similar words.
- Step 3: Analyze common patterns and mistakes in character counting.
-
Llama-3.1 70b on Groq: The original implementation utilizes the Llama-3.1 70b model hosted on Groq, known for its capability to handle complex reasoning tasks.
-
Ollama Local Models: For those preferring to run models locally, o1 supports the Ollama environment, allowing the use of various open-source models on personal machines.
Here’s a step-by-step guide to setting up o1 with both Streamlit and Gradio interfaces.
-
Create a virtual environment:
python3 -m venv venv source venv/bin/activate
-
Install dependencies:
pip3 install -r requirements.txt
-
Set environment variable:
export GROQ_API_KEY=gsk...
-
Run the app:
streamlit run o1_groq.py
For those preferring Gradio, follow these steps:
-
Navigate to the Gradio folder:
cd gradio
-
Install dependencies:
pip3 install -r requirements.txt
-
Run the app:
python3 o1_groq.py
-
Create a virtual environment:
python3 -m venv venv source venv/bin/activate
-
Install dependencies:
pip3 install -r requirements.txt
-
Configure your
.env
file: Add the following environment variables:OLLAMA_URL=your_ollama_url OLLAMA_MODEL=model_name
-
Run the app:
streamlit run o1_ollama.py
Answer: Yes.
Watch the step-by-step guide for setting up and using o1-flow:
docs/tutor.mp4