FsBERTTokenizer 1.0.0

.NET Standard 2.1
dotnet add package FsBERTTokenizer --version 1.0.0
NuGet\Install-Package FsBERTTokenizer -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FsBERTTokenizer" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FsBERTTokenizer --version 1.0.0
#r "nuget: FsBERTTokenizer, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install FsBERTTokenizer as a Cake Addin
#addin nuget:?package=FsBERTTokenizer&version=1.0.0

// Install FsBERTTokenizer as a Cake Tool
#tool nuget:?package=FsBERTTokenizer&version=1.0.0


A helper library to split a string into tokens suitable for consumption by BERT-based models. BERT requires that some words be split furhter into smaller tokens called 'word pieces'.

Tokenization requires a vocabluary dictionary. The standard text BERT vocabulary file can be loaded using the following helper function:

let vocab = BERTTokenizer.Vocabulary.loadFromFile vocabFile

The simplest way to use the tokenizer is as follows:

let sampleText = """Unos has been around for ever, & I feel like this restaurant chain peak in popularity..."""

let contextText = ""

let vocab = BERTTokenizer.Vocabulary.loadFromFile <path>
let toLowerCase = true //for 'uncased' BERT models
let maxSeqLen   = 512

let ftrs = BERTTokenizer.Featurizer.toFeatures vocab toLowerCase maxSeqLen sampleText contextText

BERT Tokenizer takes two strings. Internally it will join the two strings with a separator in between and return the token sequence. This format is used for question/answer type tasks. The second string can be empty for other tasks such as text classification.

The returned 'ftrs' record contains token data, e.g token id, separator type ids, mask, etc. The data from this record can be converted to tensors for model consumption

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.1
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 723 11/19/2021