evhub / point-free-transformer

A point-free implementation of a one-layer transformer in Coconut.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

point-free-transformer

A point-free implementation of a one-layer transformer in Coconut.

See the full highlighted source here.

Some help for those that don't read Coconut:

  • ..> is forward function composition (so f ..> g is g . f in Haskell)
  • f$(<args>) is partial application (so f$(<args>) is functools.partial(f, <args>) in Python)
  • lift “lifts” a function so that all of its arguments become unary functions (for a binary function, lift is the S' combinator, or liftA2 in Haskell—e.g. lift(f)(g, h) is equivalent to lambda x: f(g(x), h(x)) in Python)
  • (<op>) is the operator function for <op> (so (+) is operator.add in Python)
  • (. <op> <arg>) is equivalent to <op>$(?, <arg>) (? is a placeholder that means that argument isn't partially applied)
  • .method(<args>) is equivalent to lambda x: x.method(<args>) in Python

Also, einsum here is better_einsum.einsum.

About

A point-free implementation of a one-layer transformer in Coconut.

License:Apache License 2.0


Languages

Language:Python 57.9%Language:HTML 40.1%Language:CSS 1.8%Language:Makefile 0.3%