[AI助力] CS143学习笔记(AI测试向)

编程入门 行业动态 更新时间:2024-10-10 12:17:58

CS143 Course Overview

文章目录

  • CS143 Course Overview
  • AI summary
  • AI notes👇
    • Introduction:
    • Interpreters:
    • Compilers:
    • History:
    • Conclusion:
  • AI flowchart流程图
  • AI flashcards抽认卡
  • AI费曼学习法
  • workflow 总结
  • 关于prompt
  • 相关资源
  • 之后想做的

以下笔记为AI生成+我部分修改,详见workflow

AI summary

  • A lecture by Professor Alex at Stanford University on the topic of compilers and interpreters. The lecture discusses the differences between compilers and interpreters, and their respective advantages and disadvantages. It also provides a brief history of how compilers and interpreters were first developed, starting with the Speedcoding project by John Bacchus in 1953, which was an early example of an interpreter, and leading to the development of FORTRAN, one of the first successful compilers.

AI notes👇

Introduction:

  • Course on compilers and implementation of programming languages presented by Alex Aiken from Stanford University
  • Two major approaches to implementing programming languages: compilers and interpreters
  • Course mainly focuses on compilers but briefly explains interpreters in the first lecture

Interpreters:

  • Takes a program and input data as input and produces output directly without preprocessing the program
  • Interpreter is online and part of running the program
  • Faster to develop programs using an interpreter but interpreted programs are usually slower than compiled or handwritten ones

Compilers:

  • Takes a program as input and produces an executable program as output, which can be run on different inputs to produce output
  • Compiler is offline and preprocesses the program first before producing an executable that can be run multiple times without recompilation

History:

  • Development of machines such as the IBM 704 in the 1950s led to high software costs, resulting in efforts to improve software productivity
  • Speed coding, an early interpreter developed by John Backus, was faster to develop programs but slower than handwritten ones
  • Backus developed Fortran, a successful high-level language with a significant impact on computer science

Conclusion:

  • Programming languages require theory and engineering skills
  • Compilers and interpreters have different advantages and disadvantages
  • Both have played important roles in the development of programming languages.

AI flowchart流程图

下面是chatgpt给我的mermaid代码生成的flowchart!

Welcome to this course on compilers Two major approaches to implementing programming languages Compilers Interpreters Offline Produces executable Online Produces output directly History of compilers and interpreters IBM 704 Machine Speed Coding Early Example of Interpreter Much Faster to Develop Programs 10-20 times slower 300 bytes of memory Not popular John Backus Formula Translation Project Translate formula into a form that the machine could execute directly High-level programming Allowed for high level programming while still executing machine code Took three years to complete Enormous theoretical work 50% of all code by 1958

AI flashcards抽认卡

把整段的字幕放进去加上制卡prompt会出大问题,因为它一次处理不了那么多token,所以下面这段是用的制卡示范的例子加上 概括后的字幕 , 也就是对概括后的笔记进行制卡。

下面这套抽认卡内容上来说有许多地方不太可取,但是形式上让我看到了很多可能性!!!!!

问题答案
这门课程是关于什么的?编译器和编程语言实现。
有哪两种主要的实现编程语言的方法?编译器和解释器。
这门课程主要关注哪种方法?编译器。
第一节课中,Aiken简要解释了什么?解释器。
解释器如何处理程序?将程序和输入数据作为输入,直接产生输出,不需要事先处理程序。
解释器是在线的还是离线的?在线的。
使用解释器开发程序更快还是编译器更快?解释器更快。
解释器处理的程序比编译器产生的程序慢还是快?比编译器产生的程序慢。
编译器如何处理程序?将程序作为输入,产生一个可执行程序作为输出,可以在不重新编译的情况下多次运行该程序。
编译器是在线的还是离线的?离线的。
什么是速度编码?一种早期的解释器,由John Backus开发。
速度编码开发程序更快还是手写更快?开发程序更快。
速度编码处理的程序比手写的程序慢还是快?比手写的程序慢。
什么是Fortran?成功的高级语言,对计算机科学产生了重大影响。
编程语言需要什么?理论和工程技能的良好掌握。
编译器和解释器有什么优缺点?优缺点不同,都在编程语言的发展中发挥了重要作用。

AI费曼学习法

What is the difference between an interpreter and a compiler?

  • An interpreter takes the program and data as input, and produces the output directly, without processing the program beforehand. It is an online process. In contrast, a compiler takes the program as input, and produces an executable program as output. This executable can be run on different data sets, without having to recompile or process the program again. Thus, the compiler is an offline process, where the program is pre-processed before execution.

What is an advantage of using an interpreter?

  • Interpreters allow for faster program development, making programmers more productive.

What is a disadvantage of using an interpreter?

  • Programs implemented with an interpreter are typically slower than those written by hand or with a compiler.

What was the Speed Coding project, and who developed it?

  • Speed Coding was a project developed in 1953 by John Backus, which was an early example of an interpreter.

What was the Formula Translation project, and how did it improve upon Speed Coding?

  • The Formula Translation project, also known as FORTRAN, was born out of John Backus’ idea that if formulas were translated into a form that the machine could execute directly, the code would be faster, while still allowing the programmer to write the programs at a high level. Thus, FORTRAN was a compiler that translated programs written in high-level languages into executable programs that could be run on different data sets without having to recompile the program each time. FORTRAN raised the level of abstraction, improved programming productivity, and allowed for better use of computers.

workflow 总结

  • 缺陷:

    • 字幕不准确,比如Fortran 字幕里面搞成了 fortune

    • token限制,可能只概括了一部分

      • 思路可以参考 简悦 AI 的那个网页概括,它是先拆分,再概括整合

        简悦插件 · 基于 OpenAI 的语境理解 AI 系统 - 王磊-Kenshin的文章 - 知乎 https://zhuanlan.zhihu/p/606650433

  • slide导入scispace

    • • Compiling is almost this simple, but there are many pitfalls • Example: How to handle erroneous programs? • Language design has big impact on compiler -Determines what is easy and hard to compile -Course theme: many trade-offs in language design
      • Once sentence structure is understood, we can try to understand “meaning” -But meaning is too hard for compilers • IRs are useful because lower levels expose features hidden by higher levels – registers – memory layout– raw pointers etc.
      • But lower levels obscure high-level meaning – Classes– Higher order functions– Even loops… Lexical analysis not trivial

    • 效果不太好,这玩意还是适合读论文

  • slide用edge dev版打开,并提问

  • 谷歌插件:YouTube Summary with ChatGPT

    • 那个点进去直接概括的功能现在好像失效了,但是它那个提取字幕的还是很好用的

  • 文本的长度问题之后需要解决

关于prompt

  • markdown笔记

    "Can you break down the main points or arguments in the text into distinct sections or bullet points? Consider using headings (denoted by `#`) for each section and bullet points (denoted by `-`) for each argument or sub-point. Additionally, are there any key quotes or phrases that you want to highlight or emphasize? You can use bold (denoted by `**`) or italic (denoted by `*`) formatting to make them stand out."
    
  • flashcard参考了叶哥的卡片笔记(知乎)

    • 给ChatGPT施咒,让它为你制作Anki卡片——Prompt工程案例 - 叶峻峣的文章 - 知乎 https://zhuanlan.zhihu/p/609413004

    • 上面那个卡片的prompt如下

      按markdown表格形式整理为抽认卡,下面是一个例子:
      文本:
      衰老细胞的特征是细胞内的水分减少,结果使细胞萎缩,体积变小,细胞代谢的速率减慢。细胞内多种酶的活性降低。细胞核的体积增大,核膜内折,染色质收缩、染色加深。细胞膜通透性改变,使物质运输功能降低。
      一套卡片:
      | 问题 | 答案 |
      |---|---|
      |衰老细胞的体积会怎么变化?|变小。|
      |衰老细胞的体积变化的具体表现是什么?|细胞萎缩。|
      |衰老细胞的体积变化原因是什么?|细胞内的水分减少。|
      |衰老细胞内的水分变化对细胞代谢的影响是什么?|细胞代谢的速率减慢。 |
      |衰老细胞内的酶活性如何变化?|活性降低。|
      |衰老细胞的细胞核体积如何变化?|体积变大。|
      |衰老细胞的细胞核的核膜如何变化?|核膜内折。 |
      |衰老细胞的细胞核的染色质如何变化?|染色质收缩。|
      |衰老细胞的细胞核的染色质变化对细胞核形态的影响是?|染色加深。|
      |衰老细胞的物质运输功能如何变化?|物质运输功能降低。|
      |衰老细胞的物质运输功能为何变化?|细胞膜通透性改变。|
      
      下面是你要整理的内容:
      Introduction
      This is a course on compilers and the implementation of programming languages, presented by Alex Aiken, a professor at Stanford University. There are two major approaches to implementing programming languages: compilers and interpreters. This course mainly focuses on compilers, but in the first lecture, Aiken briefly explains interpreters.
      
      Interpreters
      An interpreter takes a program and input data as its input and produces the output directly without processing the program beforehand. The interpreter is online, meaning that it is part of running the program. It is faster to develop programs using an interpreter, but interpreted programs are usually slower than compiled or handwritten ones.
      
      Compilers
      A compiler takes a program as its input and produces an executable program as its output, which can be run on different inputs to produce the output. The compiler is offline, meaning that it preprocesses the program first, then produces an executable that can be run multiple times without recompilation.
      
      History
      The 1950s saw the development of machines such as the IBM 704, which had high hardware costs. As a result, software costs became the dominant expense, leading to efforts to improve software productivity. One such effort was speed coding, an early example of an interpreter developed by John Backus. It was faster to develop programs with speed coding, but they were slower than handwritten ones. Backus developed a new project, the formula translation project or Fortran, which was a successful high-level language with a significant impact on computer science.
      
      Conclusion
      Programming languages require a good grasp of theory and engineering skills. Compilers and interpreters have different advantages and disadvantages, and both have played important roles in the development of programming languages.
      
  • 整理成mermaid流程图:

    • 一开始让它给flowchart代码它听不懂
      • 给了个例子他懂了
    • 直接说mermaid它能懂
    • 其他流程图
      • 油管上看到一个画latex流程图的:ChatGPT Tutorial: From Text to Flowchart in Minutes
    • 下面这个甘特图orz… 是我看的这篇博客里面的https://blog.ouseful.info/2022/12/12/generating-diagrams-from-text-generated-by-chatgpt/
Mon 06 Make soup Serve soup Prepare fish and chips Cook fish and chips Serve fish and chips Soup Fish and Chips Soup and Fish and Chips Meal Plan

相关资源

  • 课程网站

    • CS143: Compilers (stanford.edu)
  • B站 【斯坦福大学】CS143 编译器(完结·中英字幕·机翻·人工校对中)

  • https://csdiy.wiki/%E7%BC%96%E8%AF%91%E5%8E%9F%E7%90%86/CS143/

  • 油管视频

  • 经验贴

    • 编译原理课程推荐 | 斯坦福大学 CS143 : Compilers - 源码被猫吃了的文章 - 知乎 https://zhuanlan.zhihu/p/350614886
Compilation Interpretation Programming Language Source Code Machine Code Output

之后想做的

  • 持续探索更多的学习模态和方法… (powered with artificial intelligence)

  • 如下:

    你好,这是Bing。我可以帮你用OpenAI的API来做文本摘要。😊

    根据1和2,你可以使用OpenAI Python库34来调用GPT-3模型,它可以根据文本的内容生成概括的总结,并添加一个“tl;dr:”(太长不看)的标签在最后。

    为了处理很长的文本,你可以先把它分成多个段落,然后对每个段落调用API,最后把所有的总结拼接起来。这样就可以避免token的限制。

    我给你一个Python代码的示例:

    import openai
    openai.api_key = "sk-xxxxxxxxxxxxxxxxxxxxxx" # 你自己的API密钥
    
    # 读取很长的文本文件
    with open("long_text.txt", "r", encoding="utf-8") as f:
        text = f.read()
    
    # 把文本分成多个段落,每个段落不超过2048个字符
    paragraphs = []
    start = 0
    end = 2048
    while start < len(text):
        paragraphs.append(text[start:end])
        start = end
        end += 2048
    
    # 对每个段落调用API,生成总结,并添加tl;dr:标签
    summaries = []
    for paragraph in paragraphs:
        response = openai.Completion.create(
            engine="davinci",
            prompt=paragraph + "\ntl;dr:",
            max_tokens=64,
            temperature=0.3,
            stop=["\n"]
        )
        summary = response["choices"][0]["text"]
        summaries.append(summary)
    
    # 把所有的总结拼接起来,生成markdown格式的输出
    output = ""
    for i, summary in enumerate(summaries):
        output += f"- 段落{i+1}{summary}\n"
    print(output)
    
    

更多推荐

[AI助力] CS143学习笔记(AI测试向)

本文发布于:2023-06-13 08:16:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1364489.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:助力   学习笔记   测试   AI

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!