Back to Articles

Building o1-Like Reasoning Chains with Prompt Engineering Alone

[ View on GitHub ]

Building o1-Like Reasoning Chains with Prompt Engineering Alone

Hook

Llama-3.1 70b can’t count the letter ‘R’ in ‘strawberry’—it gets it wrong 100% of the time. But with the right prompting strategy, that same model jumps to 70% accuracy. No fine-tuning, no reinforcement learning, just better instructions.

Context

When OpenAI released o1, the AI community was stunned by its reasoning capabilities on complex problems. But o1’s reasoning process is a black box—the chain-of-thought happens invisibly, and you only see the final answer. More critically, achieving o1-level performance requires large-scale reinforcement learning, putting it out of reach for most developers working with open-source models.

The g1 project asks a different question: How much reasoning improvement can we extract from prompting alone? It’s a proof-of-concept that demonstrates you don’t always need expensive model training to overcome common LLM failure modes. By forcing Llama-3.1 70b to show its work, explore alternative solutions, and question its own reasoning, g1 turns a model that completely fails at simple logic puzzles into one that succeeds most of the time. It’s transparency-first reasoning for developers who want to understand—and debug—how their models think.

Technical Insight

Query

Structured Prompt

JSON Response

title, content, next_action

continue

Update Display

Next Iteration

final_answer

Display Result

User Input

Question/Problem

System Prompt

CoT Instructions

Groq API

Llama-3.1 70b

JSON Parser

Extract Fields

next_action?

Reasoning Chain

Accumulate Steps

Streamlit/Gradio UI

Display Steps

Final Answer

Return to User

System architecture — auto-generated

At its core, g1 is a carefully crafted system prompt that transforms a standard LLM into a step-by-step reasoner. The architecture is deceptively simple: a single prompt that forces structured JSON output with three fields per reasoning step: ‘title’, ‘content’, and ‘next_action’. The model decides at each step whether to continue reasoning or provide a final answer.

Here’s the actual system prompt that powers g1:

You are an expert AI assistant that explains your reasoning step by step. 
For each step, provide a title that describes what you're doing in that 
step, along with the content. Decide if you need another step or if you're 
ready to give the final answer. Respond in JSON format with 'title', 
'content', and 'next_action' (either 'continue' or 'final_answer') keys. 
USE AS MANY REASONING STEPS AS POSSIBLE. AT LEAST 3. BE AWARE OF YOUR 
LIMITATIONS AS AN LLM AND WHAT YOU CAN AND CANNOT DO. IN YOUR REASONING, 
INCLUDE EXPLORATION OF ALTERNATIVE ANSWERS. CONSIDER YOU MAY BE WRONG, 
AND IF YOU ARE WRONG IN YOUR REASONING, WHERE IT WOULD BE. FULLY TEST ALL 
OTHER POSSIBILITIES. YOU CAN BE WRONG. WHEN YOU SAY YOU ARE RE-EXAMINING, 
ACTUALLY RE-EXAMINE, AND USE ANOTHER APPROACH TO DO SO. DO NOT JUST SAY 
YOU ARE RE-EXAMINING. USE AT LEAST 3 METHODS TO DERIVE THE ANSWER. 
USE BEST PRACTICES.

Notice the uppercase emphasis on critical instructions. This isn’t accidental formatting—it’s a deliberate prompt engineering technique that improves compliance. The model treats uppercase text as more important, which matters when you’re trying to override default behaviors.

The real innovation is in what the prompt forces the model to do. First, it mandates multiple reasoning steps (at least three, though real executions typically generate five to ten). This prevents the model from jumping to conclusions. Second, it explicitly reminds the model of its limitations—particularly important for tasks like counting characters, where LLMs typically fail because they process tokens, not individual letters. This reminder triggers better strategies, like breaking ‘strawberry’ into individual characters before counting.

Third, and most crucially, the prompt requires exploration of alternative answers and actual re-examination using different methods. This addresses a common failure mode where LLMs claim to be ‘double-checking’ but actually just rephrase their initial answer. By demanding at least three derivation methods, g1 forces genuine verification.

The JSON structure serves dual purposes: it provides machine-parseable output for the UI to render as a visual reasoning chain, and it forces the model into a more structured thinking mode. Each step becomes a discrete unit of reasoning rather than a continuous stream of consciousness.

The project uses Llama-3.1 70b running on Groq, which appears to enable responsive interaction with the multi-step reasoning chains. The project includes both Streamlit and Gradio UIs that visualize each reasoning step as it’s generated, creating a transparent window into the model’s thought process.

The difference in outcomes is stark. On the infamous ‘strawberry problem’ (counting Rs in ‘strawberry’), base Llama-3.1 70b scores 0% accuracy. With g1’s prompting strategy, it jumps to approximately 70% (n=10). The README notes that ChatGPT-4o had 30% baseline accuracy on this problem. The prompt works across different base models because it’s exploiting general properties of how LLMs respond to structured instructions, not model-specific quirks.

Gotcha

The most important limitation is right in the README: accuracy hasn’t been formally evaluated. The ‘60-80% success rate on simple logic problems’ comes from initial testing, and the strawberry problem accuracy is based on just 10 samples. This isn’t production-ready validation—it’s proof-of-concept data. You’re not getting benchmarked performance on standard reasoning datasets like GSM8K or MATH.

More fundamentally, prompting has a ceiling. g1 demonstrates that ceiling is higher than most developers assume, but it’s still a ceiling. OpenAI’s o1 uses reinforcement learning to train reasoning capabilities directly into the model. That’s a different league of performance, especially on complex problems requiring many reasoning steps or deep domain knowledge. On PhD-level physics or advanced mathematics, g1 will fail where o1 succeeds. The project is explicit about this: it’s not trying to replicate o1, just show what prompting alone can achieve. You’re also still bound by the base model’s knowledge cutoff and capabilities—clever prompting can’t inject knowledge the model never learned or overcome fundamental architectural limitations.

Verdict

Use g1 if you’re working with open-source models and hitting failure modes on logic puzzles, need transparent reasoning chains for debugging or educational purposes, want a starting point for building custom reasoning prompts, or need cost-effective reasoning without paying for o1 API calls. It’s particularly valuable for prototyping, understanding prompt engineering techniques, or cases where seeing the intermediate steps matters more than peak accuracy. Skip g1 if you need state-of-the-art performance on complex reasoning tasks (use o1 or o1-mini instead), require formally validated accuracy for production systems, are already getting acceptable results from standard prompting, or need reasoning on problems that exceed the base model’s fundamental capabilities. Treat this as an educational demonstration and prompt engineering laboratory, not a replacement for trained reasoning models.

// ADD TO YOUR README
[![Featured on Starlog](https://starlog.is/api/badge/infrastructure/build-with-groq-g1.svg)](https://starlog.is/api/badge-click/infrastructure/build-with-groq-g1)