Improve encode example
Add inst tag handler, fix tag tokenization