g1-flash: Using glm-4-flash to Create O1-like Reasoning Chains
g1-flash is an early prototype that utilizes prompting techniques to generate O1-like reasoning chains, aiming to improve the accuracy of AI-generated outputs. Powered by the glm-4-flash model from ZhipuAI, this application provides fast and detailed reasoning steps to user queries through an interactive web interface built with Gradio.
This project is a fork of the open-source g1 repository, modified by Zhu Rui to integrate glm-4-flash as the underlying language model.
- Step-by-Step Reasoning: Generates detailed reasoning steps to provide comprehensive answers.
- Fast Processing: Leverages glm-4-flash for quick response times.
- Interactive Interface: User-friendly web interface built with Gradio.
- Customizable Steps: Allows users to set the maximum number of reasoning steps.
- Python 3.7 or higher
- An API key for glm-4-flash from ZhipuAI
git clone https://github.com/yourusername/g1-flash.git
cd g1-flashInstall the required Python packages using pip:
pip install -r requirements.txtDependencies include:
gradiozhipuaijson
-
Obtain an API Key: Sign up on ZhipuAI to get your glm-4-flash API key.
-
Run the Application:
python app.py
-
Access the Interface: Open your web browser and navigate to the URL provided in the terminal (e.g.,
http://127.0.0.1:7860). -
Enter Your API Key: Input your glm-4-flash API key in the designated field.
-
Submit a Query:
- Enter your question or prompt in the "Enter your query" textbox.
- Adjust the "Max steps" slider to set the desired number of reasoning steps.
- Click on the Generate Response button.
-
View the Results: The application will display the reasoning steps and the final answer. Each step includes:
- Title: A brief description of the step.
- Content: Detailed reasoning for that step.
- Thinking Time: Time taken to generate the step.
Sample Query:
How many 'R's are in the word strawberry?
Steps Generated:
-
Step 1: Analyzing the Word
- Content: Break down the word "strawberry" to identify each letter.
- Thinking Time: 0.5 seconds
-
Step 2: Counting the Letter 'R'
- Content: Count the number of times 'R' appears in "strawberry".
- Thinking Time: 0.4 seconds
-
Final Answer
- Content: There are two 'R's in the word "strawberry".
Total Thinking Time: 1.2 seconds
This project is licensed under the MIT License.
- Original Author: bklieger-groq
- Modifier: Zhu Rui
- Powered By: glm-4-flash from ZhipuAI
- Built With: Gradio
Feel free to contribute to the project by submitting issues or pull requests. For major changes, please open an issue first to discuss what you would like to change.
For any questions or feedback, please issue.
g1-flash:使用 glm-4-flash 创建类似 O1 的推理链
g1-flash 是一个早期的原型,它利用提示技术来生成类似 O1 的推理链,旨在提高 AI 生成输出的准确性。该应用由 ZhipuAI 的 glm-4-flash 模型驱动,通过 Gradio 构建的交互式网页界面,为用户的查询提供快速而详细的推理步骤。
该项目是开源 g1 仓库 的一个分支,由Zhu Rui修改,集成了 glm-4-flash 作为底层语言模型。
- 逐步推理:生成详细的推理步骤,提供全面的答案。
- 快速处理:利用 glm-4-flash,实现快速的响应时间。
- 交互式界面:采用 Gradio 构建的用户友好型网页界面。
- 可定制步骤:允许用户设置推理步骤的最大数量。
- Python 3.7 或更高版本
- 从 智谱 AI 获取的 glm-4-flash API 密钥
git clone https://github.com/yourusername/g1-flash.git
cd g1-flash使用 pip 安装所需的 Python 包:
pip install -r requirements.txt依赖项包括:
gradiozhipuaijson
-
获取 API 密钥:在 智谱 AI 注册,获取你的 glm-4-flash API 密钥。
-
运行应用程序:
python app.py
-
访问界面:打开你的网页浏览器,导航到终端中提供的 URL(例如,
http://127.0.0.1:7860)。 -
输入 API 密钥:在指定字段中输入你的 glm-4-flash API 密钥。
-
提交查询:
- 在“输入你的查询”文本框中输入你的问题或提示。
- 调整“最大步骤”滑块,设置所需的推理步骤数量。
- 点击 “生成响应” 按钮。
-
查看结果:应用程序将显示推理步骤和最终答案。每个步骤包括:
- 标题:步骤的简要描述。
- 内容:该步骤的详细推理。
- 思考时间:生成该步骤所花费的时间。
示例查询:
单词 "strawberry" 中有多少个字母 'R'?
生成的步骤:
-
步骤 1:分析单词
- 内容:将单词 "strawberry" 分解,识别每个字母。
- 思考时间:0.5 秒
-
步骤 2:计数字母 'R'
- 内容:计算 "strawberry" 中出现 'R' 的次数。
- 思考时间:0.4 秒
-
最终答案
- 内容:单词 "strawberry" 中有两个字母 'R'。
总思考时间:1.2 秒
本项目采用 MIT 许可证 。
- 原作者: bklieger-groq
- 修改者:zhurui
- 技术支持:来自智谱 AI 的 glm-4-flash
- 构建工具: Gradio
欢迎通过提交问题或拉取请求来为本项目做出贡献。对于重大更改,请先打开一个问题进行讨论。
如有任何问题或反馈,请在项目中提交 Issue。

