使用 Gemini CLI 辅助学习
摘要
本课程展示了如何使用 Gemini CLI 作为学习伙伴和私人导师。讲师演示了通过 web 搜索为回答提供依据,确保学习资料的准确性。核心案例包括对 200 多页的计算机科学课程进行章节总结、生成学习指南,以及创建交互式网页模拟测试应用,充分利用 AI 工具提升学习效率。
要点
- Gemini CLI 可作为私人导师和学习伙伴,支持创建学习指南、抽认卡和练习测试等多种学习场景
- 对于大型文档(如超过 200 页的 PDF),使用
pypdf分块读取可避免上下文过载,提高处理效率 - Gemini CLI 能自动将章节总结保存到 Google Docs,并生成包含关键概念、方程和自测问题的学习指南
- 可要求 Gemini CLI 自主选择技术栈创建交互式网页应用,实现实时的知识测试与反馈
- 适用于学习新主题、备考、研究和头脑风暴等多种场景,显著提升学习效率
中文翻译
你还可以将 Gemini CLI 用作你的私人导师和学习伙伴。这是我们最近几个月看到的一个正在扩展的强大用例。在本节课中,你将学习如何利用网络搜索来为 Gemini CLI 的回答提供依据,从而确保你的学习资料准确且有引用来源。让我们开始吧。
本节课我们将涵盖几个具体示例,但这绝非全部。你可以将 Gemini CLI 应用于大量不同的用例。屏幕上显示的几个例子包括创建学习指南、抽认卡或进行练习测试。我经常做的另一个用例是将 Gemini CLI 用作私人导师。我会问它问题,它实际上会去进行 Google 搜索以获取更多知识。然后我会让它通过提问来面试我。接着我会反过来问 Gemini CLI 问题。这对于确保你真正扎实地理解了知识点非常有帮助。
这非常适合做研究,比如你在头脑风暴或者想找人交流想法的时候。你还可以使用 Gemini CLI 来看看是否已经有人在做这件事了,或者你的想法是否是新的。
设定一下用例场景,我们要扮演一个正在为计算机科学课程期末考试做准备的角色。我们将让 Gemini CLI 浏览超过 200 页的整个课程材料,然后让它为我们总结这些内容,帮助我们生成一些学习问题以及一些模拟试题。
我们将使用的课程实际上是由 Andrew 教授的一门计算机科学课程。这门课程包含超过 17 个不同的章节,长度超过 200 页。所以我们将进行交互,使用 Gemini CLI 来实际总结这些内容,为我们创建学习指南,并制作一个交互式的模拟考试。
因为我们的 PDF 超过 200 页,我们不想直接把上下文撑爆,一次性读取整个 PDF。为了解决这个问题,在这个学习文件夹的 GEMINI.md 文件中,我们实际上告诉它使用 pypdf(一个 Python 包)来分块读取,这样我们就可以小批量地迭代 PDF。这将帮助我们更高效地完成任务,而不是将整个 PDF 加载到上下文中。
我们在学习文件夹中启动了 Gemini CLI。然后我们会告诉 Gemini CLI 总结我们课程教材的每一章,并将其保存为 Google Doc,以便我们可以参考并看到类似"Spark Notes"版本的精简内容。Gemini CLI 会遵循我们的 GEMINI.md Markdown 文件,因为文件超过了一定大小,它会去创建一个脚本来分块读取 PDF。
它开始以较小的块读取 PDF,现在我们要实际创建那个 Google Doc。它再次使用那个 Workspace 扩展询问我们,是否要为 CS229 课程摘要创建一个新的 Google Doc。同样,我们将允许 Workspace 扩展的所有 MCP 服务器工具。Gemini CLI 现在正在逐章阅读,边读边总结,并将内容追加到我们的 Google Doc 中。
如果我们打开它为我们创建的 Google Doc,我们实际上可以看到摘要正在实时生成。比如一秒钟前,第六章还不在那里,现在我们可以看到 Google Doc 中有了第六章"支持向量机"的摘要。我们会让它逐章进行,等它完成后我们再回来。
Gemini CLI 现在说它已经完成了所有 17 章的总结。我们可以通过查看 Google Doc 本身来验证这一点,看看是否有了所有 17 个摘要。看起来我们在 Google Doc 中确实有了 17 个不同的章节摘要。
现在我们有了课程每一章的摘要,让我们要求 Gemini CLI 为每一章生成一份学习指南。它会给我们一些问题和答案。希望它能给我们一些好的练习题,以及每一章中我们在考试前应该知道的注意事项。我们会告诉它也将此保存到 Google Doc 中。于是它将为学习指南创建一个新文档,并开始向文档添加新信息。
这相当快。看起来它已经完成了任务。如果我们检查 Google Doc,看起来它确实做到了。我们可以看到关键概念、关键方程,还有这个"检查你的理解(Check Your Understanding)“部分,它问了我们一些问题,比如"为什么我们使用正规方程(Normal Equation)而不是梯度下降?“这是一个非常好的问题,我也应该去好好研究一下。
现在我们要更进一步,让 Gemini CLI 创建一些交互式的东西。仅仅阅读摘要和"检查你的理解"问题有点无聊。所以让我们让它为我们创建一个 Web 应用程序来测验我们,然后我们可以让它实时测试我们的知识,这有趣多了。我们并没有真正给它任何护栏或指示要使用什么技术栈。所以这将完全由 Gemini CLI 自己决定它想用什么来创建这个交互式应用程序。
看起来 Gemini CLI 创建了一个很棒的小 HTML 文件,我们可以直接在我们选择的浏览器中打开它。我们也可以直接使用 shell 模式,输入 open practice_test.html 来在你首选的浏览器中打开它。
我们有了 Gemini CLI 为我们创建的这个很棒的小型交互式模拟测试。我们可以快速测试一下。哎呀,看起来我们第一题做错了。它实际上会为我们提供关于正确信息的详细说明,这在你尝试学习时非常好用。
在几分钟内,我们用 Gemini CLI 做了很多不同的关于学习和复习的事情。我希望这个额外的课程能教你如何真正跳出思维定势,以各种不同的方式使用 Gemini CLI,让它成为你的导师,让它成为你的学习助手。
所以,下次当你学习新主题、准备考试,甚至只是做研究或对你的想法进行头脑风暴时,启动 Gemini CLI 并让它在这个过程中帮助你。我想你会发现事情变得更加高效,而且你实际上可以完成很多没有它就无法完成的事情。
English Script
You can also use Gemini CLI as your personal tutor and study companion. A powerful use case we’ve seen expand in recent months. In this lesson, you’ll learn how to ground Gemini CLI’s responses with web search to ensure accurate, cited information for your studies. Let’s get started.
We’ll cover a few specific examples in this lesson, but it is not exhaustive by any means. You can apply Gemini CLI to a ton of different use cases. A few of them on screen here are creating study guides, flash cards, or doing practice tests. Another one that I do quite often is using Gemini CLI as a personal tutor. I’ll ask it questions, it’ll actually go and do Google searches to get more knowledge. And then I’ll have it kind of interview me and ask me questions. And then I’ll go back and ask Gemini CLI questions. This is really helpful to kind of make sure you have a concrete understanding.
It’s great for doing research, if you’re brainstorming or wanting to bounce ideas off of someone. You can also use Gemini CLI to see if there’s anything out there already doing this or if your idea is, you know, new.
Setting the use case, we are going to kind of take on the persona as if we are studying for a final exam of a computer science course. We’ll have Gemini CLI go over the entire course material over 200 pages, and then it’s going to summarize that for us, help us generate some study questions as well as some practice exams.
The course we’ll be using is a computer science course, actually taught by Andrew. It’s a course that has over 17 different chapters and is over 200 pages long. So we’ll kind of interact and go through and use Gemini CLI to actually summarize this, create a study guide for us, and actually make an interactive practice exam.
Because our PDF is over 200 pages long, we don’t want to just explode our context and read the entire PDF at once. So to counterbalance this in our GEMINI.md file for this learning folder, we actually tell it to use pypdf, a Python package to go ahead and actually read in chunks so that we’re iterating over the PDF in small sizes. And this is going to help us get that task done much more efficiently instead of loading the entire PDF into context.
So we’ve started up Gemini CLI inside of our learning folder. So we’ll go ahead and then tell Gemini CLI to summarize each chapter of our course book and save it as a Google Doc so that we can reference and kind of see the spark notes version. Gemini CLI is adhering to our GEMINI.md markdown file because it’s over a certain size, it’s going to go ahead and actually create a script to read the PDF in different chunks.
It’s starting to read the PDF in smaller chunks and now we want to actually create that Google Doc. It’s asking us, again, using that workspace extension to create a new Google Doc for CS229 Course Summaries. Once again, we’ll allow all of the MCP server tools from the workspace extension. Gemini CLI is now reading through chapter by chapter and summarizing each as it goes and appending it to our Google Doc.
If we open the Google Doc it created for us, we can actually see the summaries coming in in real time. Like a second ago, chapter six wasn’t there, and now we can see we have a summary for chapter six, Support Vector Machines in our Google Doc. So we’ll let it go chapter by chapter and then we’ll come back once it’s finished.
So Gemini CLI is now saying it has completed the summarization of all 17 chapters. We can go ahead and verify this by taking a look at the Google Doc itself to see if we have all 17 summaries. Looks like we do have 17 different chapters that are summarized in our Google Doc.
Now that we have the summaries of each chapter of the course, let’s ask Gemini CLI to generate us a study guide for each chapter. And it’ll give us some questions, some answers. Hopefully it’ll give us some good kind of practice questions and things to consider for each chapter that we should know ahead of our exam. We’ll tell it to also save this to a Google Doc. So it’s going to create a new document for a study guide, and it’s going to start adding new information to the document.
So that was pretty quick. It looks like it’s already done the task. And if we check the Google Doc, it looks like it’s done just that. We can see that we have key concepts. Critical Equations and we have this Check Your Understanding where it’s asking us questions like why do we use the Normal Equation instead of Gradient Descent? Which is a very good question, one that I should probably go study for as well.
Now we’ll take it a step further and actually have Gemini CLI create something that’s interactive. It’s a bit boring just to read through the summarizations and the Check Your Understanding questions. So let’s go and actually have it create us a web application that will quiz us, and then we can have it test our knowledge live, which is way more fun. We haven’t really given it any guardrails or any indication of what technology stack to use for this. So it’s going to be fully Gemini CLI deciding on its own what it wants to use to create this interactive application.
It looks like Gemini CLI has created a nice little HTML file that we can just go ahead and open in the browser of our choice. We can also just use the shell mode using open practice_test.html to actually go ahead and open this in your preferred browser.
We have our nice little interactive practice test that Gemini CLI has created for us. We can go ahead and quickly test it out. Whoops, it looks like we got the first question wrong. It’s going to actually provide us with details on the correct information, which is really nice for when you’re trying to study.
In a matter of minutes, we did quite a lot of different things with Gemini CLI for learning and studying. I hope this bonus lesson kind of taught you how you can really think outside of the box and use Gemini CLI in various different ways, having it be a tutor, having it be a study helper.
So the next time you’re learning a new topic, studying for a test, or maybe even just doing research or brainstorming an idea you had, spin up Gemini CLI and actually have it help you with the process. I think you’ll find things are much more efficient and you can actually conquer a lot more that you couldn’t without it.