Finisky Garden

NLP, 软件工程, 产品设计

GPT2是一个很好的长文本生成模型,但官方版本并没有开源中文预训练好的模型。因此,最近用开源的中文新闻,wiki,评论等从头训练了一个中文GPT2用于文本生成任务。

预训练使用的是HuggingFace的transformers库,这库是个好东西,把当前主流的transfomer-based模型都封装了一遍,使用起来方便很多。但由于不同模型的结构、参数等等细节不同,封装成统一的interface还是有难度,因此此库上也有一些折衷,也并不像想像中那么好使。就pretrain和fine-tune来说,都是训练一个language model,理论上调用它examples/run_language_modeling.py即可。不过真训练起来发现还是有些坑:

  • 中文Tokenizer用什么?
  • 大规模语料爆内存
  • fp16混合精度训练?

最后一个问题坑有点深,nvidia的apex库用起来并不是那么顺滑,尝试了多次并未成功。此外听朋友说即使fp16也仅能提升约20%的训练速度,看起来并不太promising。另外inference时也要使用apex,增加了额外依赖,麻烦。

这里就说说前两个问题。

阅读全文 »

Windows下的emacs用起来体验不是太好,对中文的支持也不太行。偶尔打开一次需要输入个中文发现用Ctrl+Space或Win+Space都调不出第三方输入法(如腾讯或搜狗输入法)。

忘了在哪看到过一个简单解决方案:在emacs窗口中,按住Ctrl的同时按下鼠标左键会出现一个Buffer Menu,然后随意点一下别处将此Menu消除,再用预设的输入法切换快捷键(Ctrl+Space或Win+Space之类)即可。

emacs input method

感慨一句,emacs最近用得越来越少,尤其是在有了VSCode Remote Development Extention之后,在Windows下远程SSH到Linux下开发便捷许多,甚至可以远程像本地一样运行和DEBUG。

现在用emacs基本是SSH Linux时编辑些配置文件,不再有以前折腾各种插件和炫酷效果的激情,追求的是光速启动和直达目标,用的是肌肉记忆快捷键的情怀:-)

Recently, I found there were huge amount of files named .com.google.Chrome.* be created in my /tmp folder. Obviously the culprit is Chrome. However, after some research no solution is found to prevent Chrome creating these garbage.

/tmp$ du -csh .com.google.Chrome.*

8.0K    .com.google.Chrome.00OKwD
104K    .com.google.Chrome.013jYf
172K    .com.google.Chrome.015x5t
...
48K     .com.google.Chrome.Zytrhf
16K     .com.google.Chrome.zz233G
36K     .com.google.Chrome.ZzrsZY
163M    total
/tmp$  find /tmp -name ".com.google.Chrome*" -ls| wc -l
3468

Update 2020/12/12 I found there are lots of .com.google.Chrome.* files in /tmp/snap.chromium/tmp :-( . Look at the ncduresults:

--- /tmp/snap.chromium/tmp -------------------------------------------------------------------------
                         /..
    4.1 MiB [##########] /.com.google.Chrome.xTBobr
    4.1 MiB [######### ] /.com.google.Chrome.0hcsFR
    4.0 MiB [######### ] /.com.google.Chrome.YdhzL5
    4.0 MiB [######### ] /.com.google.Chrome.nJ5W3A
    4.0 MiB [######### ] /.com.google.Chrome.unS6es
...
 Total disk usage:   6.8 GiB  Apparent size:  12.1 GiB  Items: 482530
Now the cleanup script has been updated.

阅读全文 »

正确使用异常处理可以让代码逻辑变得清晰,使程序的鲁棒性更好,并可以准确捕捉到一些细节的错误。那么问题来了,异常的使用场景是什么,实践中又有哪些常见问题,本文简单讨论一二。

阅读全文 »

Yesterday, when I login to my VM I found that the disk is full. Even a tab command completion cannot be done. I immediately delete some unused files and the system works. However, when I reboot the system, it stucked at A start job is running for Create Volatile Files and Directories...:

阅读全文 »

半年前写过篇如何换启辉器和环形灯管,得,家里的老式日光灯又坏了,灯开着嗡嗡响,看起来像是镇流器出了问题,但环形灯管的头部也发黑了,灯的频闪也比较重,所以想买镇流器和灯管给换上。

老式荧光灯的构造比较复杂,启辉器+镇流器+灯管,T5/T8 22W 环形灯管20块左右,对应镇流器30块左右。用过日光灯的都知道,启辉器有多容易坏……花50块钱换一堆淘汰不禁用的东西,不大划算。 Old Lamp Original

阅读全文 »

After I changed the HOME folder to another place, I copied the ssh config folder from old HOME to the new place. Supposedly it should directly work, right? However, when I login the server with my private key, the server said: "Server Refused Our Key"...

阅读全文 »

Unity supports three ways of registering types:

  • Instance registration
  • Type registration
  • Factory registration

Typically, Instance registration and Type registration resolve dependencies through ResolvedParameter<T>, while Factory registration resolve dependencies by a factory delegate. In practice, when you want to resolve a List<T> or Dictionary<T1, T2>, Factory registration is what you want. Let's go through how to resolve a collection of customized classes.

阅读全文 »

SVM的函数间隔定义中会用到点到超平面距离的推导,《统计学习方法》中对此没有详细的解释,当然这个问题有许多解法,找到了一种比较直观的解法如下。

阅读全文 »
0%