项目
在 GitHub 查看
chengchingwen/Transformers.jl
关于
Transformer 模型的 Julia 实现
人工智能与机器学习实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- -1
- 1个月
- 0
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文
Julia implementation of transformer-based models, with Flux.jl.
notice: The current version is almost completely different from the 0.1.x version. If you are using the old version, make sure to update the changes or stick to the old version.
Installation
In the Julia REPL:
]add Transformers
Example
Using pretrained Bert with Transformers.jl.
using Transformers
using Transformers.TextEncoders
using Transformers.HuggingFace
textencoder, bert_model = hgf"bert-base-uncased"
text1 = "Peter Piper picked a peck of pickled peppers"
text2 = "Fuzzy Wuzzy was a bear"
text = [[ text1, text2 ]] # 1 batch of contiguous sentences
sample = encode(textencoder, text) # tokenize + pre-process (add special tokens + truncate / padding + one-hot encode)
@assert reshape(decode(textencoder, sample.token), :) == [
"[CLS]", "peter", "piper", "picked", "a", "peck", "of", "pick", "##led", "peppers", "[SEP]",
"fuzzy", "wu", "##zzy", "was", "a", "bear", "[SEP]"
]
bert_features = bert_model(sample).hidden_state
See example folder for the complete example.
For more information
If you want to know more about this package, see the document
and read code in the example folder. You can also tag me (@chengchingwen) on Julia's slack or discourse if
you have any questions, or just create a new Issue on GitHub.
探索相关项目
加载中…