随着学习的不断深入,我们肯定会越来越不满足只在 Jupyter Notebook 中写一些小任务。我们可能会希望做一个 Web 应用,或者一个小程序,甚至是一个 APP。对于这种系统性的工程项目,框架就必不可少了,它可以极大地提高我们的效率。这节课我们就以 Python 的 Django 框架为例来开发一个小的 Web 应用程序。
Python 小白快速从入门到放弃:在结束后
这个系列的课程的目标在《在开始前》已经说得很清楚了:解决重复劳动或自己做好玩儿的小项目;尝试新的思维方式。这短短的几节课要想把 Python 的相关知识面面俱到是不可能的,但我觉得已经给出了一个全图景,大家只要围绕这个做,达到目标应该是不成问题的。我想说的还是一直提倡的:Just do it,在实践中不断成长。
Python 小白快速从入门到放弃:阅读源码
学编程最重要的就是写代码、读代码。上节提到了要阅读大神的或优秀的代码,之前也一直在强调要动手实践,这节咱们关注下如何阅读源代码。好的源代码不仅能让我们学到关于编程的知识,而且还有如何思考问题、抽象业务、设计架构等等方面知识。
Python 小白快速从入门到放弃:使用模块
上节介绍了函数,简单理解就是实现特定功能的一组代码,方便复用。本节介绍的模块其实就是把函数组合起来作为模块,让更加便利地完成任务。使用模块我们可以非常迅速地实现很多任务,而不用自己动手实现。Python 中的模块分为内置的(Python 安装后就有的)和社区模块(需要通过 pip install xxx 安装的)。
Python 小白快速从入门到放弃:基础知识
当一句或一段代码运行时,Python 解释器将源代码转为字节码,然后进行词法、语法分析,检查是否有错,如果没有错误就编译并执行,然后将结果返回给。这个流程都由 Jupyter Notebook 自动完成。
CTRL 论文+代码+实践笔记
paper: [1909.05858] CTRL: A Conditional Transformer Language Model for Controllable Generation
code: salesforce/ctrl: Conditional Transformer Language Model for Controllable Generation
核心思想:借鉴多任务,将文本标签作为输入的一部分(放在开头)控制文本生成。
Abstract
文本生成最大的问题是难以对其进行控制,本文发布了一个 1.6 billion 参数的条件 transformer language model,训练能够 govern 风格、内容、特定任务行为等的控制代码。控制代码来自与原始文本共现的结构,保留了无监督学习的优点,同时提供对文本生成更明确的控制。这些控制代码还允许 CTRL 预测训练数据的哪些部分最有可能给出序列。
GraphQL Glance
This is a quick and simple glance to the raw document (in the references), maybe you could treat it as a brief note. Hope it’s helpful to u.
At its core, GraphQL enables declarative data fetching where a client can specify exactly what data it needs from an API. GraphQL is a query language for APIs - not databases.
REST vs GraphQL
- Data Fetching: multiple endpoints VS single query
- Over-fetching and Under-fetching (n+1) : fixed data structure VS given exact data
- Rapid Product Iterations on the Frontend: adjust with data change VS flexible
- Insightful Analytics on the Backend: fine-grained insights about the data
- Benefits of a Schema & Type System: type system => schema, frontend and backends can do their work without further communication
GraphQL Elixir Glance
There are several problems with the origin docs, so I reproduced this quick glance. It’s much simple and only contains the brief information. Hope this is helpful to u.
Getting Started
Schema-Driven Development
- Define your types and the appropriate queries and mutations for them.
- Implement functions called resolvers to handle these types and their fields.
- As new requirements arrive, go back to step 1 to update the schema, and continue through the other steps.
1 | # Step1: create |
You should see two pieces of items in the links table.
Bert 论文笔记
Paper: https://arxiv.org/pdf/1810.04805.pdf
Code: https://github.com/google-research/bert
Bert 的核心思想:MaskLM 利用双向语境 + MultiTask。
Abstract
BERT 通过联合训练所有层中的上下文来获取文本的深度双向表示。
Introduction
两种应用 pre-trained model 到下有任务的方法:
- feature-based:比如 ELMo,将 pre-trained 表示作为额外的特征
- fine-tuning:比如 OpenAI GPT,引入少量特定任务参数,在下游任务中 fine-tuning 所有的参数
现在的技术有个限制,就是只能采用从左到右的单向机制,这对有些任务是不适合的,比如问答。
Bert 通过 “masked language model” 缓和了这个限制,即随机 mask 输入中的一些 token,目标是只根据上下文(左边和右边)预测 mask 掉的原始 vocabulary id。
同时,还联合训练了一个 “next sentence prediction” 的任务用来表示文本对。
Transformer 论文笔记
Paper: https://arxiv.org/pdf/1706.03762.pdf
Code: https://github.com/tensorflow/models/tree/master/official/nlp/transformer
Tool: https://github.com/tensorflow/tensor2tensor
Attention 核心思想:Multi-Head Attention 关注不同位置不同表示子空间的信息,且更容易训练。
Abstract
一个完全基于 Attention 的架构。更容易并行训练,提高训练速度。
Introduction
RNN 的固有属性使其难以并行化(即使通过 factorization tricks 和 conditional computation 可以得到改善),Attention 对依赖关系建模,不考虑输入输出的距离。本文提出的 Transformer 采用了完全的 Attention 机制描述输入和输出的整体依赖关系,在训练速度和效果上都有明显提升。