SpydazWeb.AI.PositionalEncoder 1.0.0

dotnet add package SpydazWeb.AI.PositionalEncoder --version 1.0.0
NuGet\Install-Package SpydazWeb.AI.PositionalEncoder -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="SpydazWeb.AI.PositionalEncoder" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SpydazWeb.AI.PositionalEncoder --version 1.0.0
#r "nuget: SpydazWeb.AI.PositionalEncoder, 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 SpydazWeb.AI.PositionalEncoder as a Cake Addin
#addin nuget:?package=SpydazWeb.AI.PositionalEncoder&version=1.0.0

// Install SpydazWeb.AI.PositionalEncoder as a Cake Tool
#tool nuget:?package=SpydazWeb.AI.PositionalEncoder&version=1.0.0

Positional Encoder Decoder (VB.NET)

The Positional Encoder Decoder is a Visual Basic .NET class that provides functionality for encoding and decoding tokens and sentences using positional embeddings. It allows you to convert between string tokens and their corresponding embeddings, and vice versa.

Features

  • Encode string tokens and get their positional embeddings as lists of doubles.
  • Encode token embeddings and get their positional embeddings as lists of doubles.
  • Encode lists of string tokens and get their positional embeddings as lists of lists of doubles.
  • Encode lists of token embeddings and get their positional embeddings as lists of lists of doubles.
  • Decode positional embeddings and get the corresponding string tokens.
  • Decode positional embeddings and get the corresponding token embeddings as lists of doubles.

Usage

  1. Create an instance of the PositionalEncoderDecoder class by providing the necessary parameters: Dmodel (embedding model size), MaxSeqLength (maximum sentence length), and vocabulary (a list of known vocabulary).
Dim encoderDecoder As New PositionalEncoderDecoder(Dmodel, MaxSeqLength, vocabulary)
  1. Encoding:
  • Encode a string token and get its positional embedding:
Dim token As String = "example"
Dim embedding As List(Of Double) = encoderDecoder.EncodeTokenStr(token)
  • Encode a token embedding and get its positional embedding:
Dim tokenEmbedding As List(Of Double) = GetTokenEmbedding() ' Get the token embedding from somewhere
Dim embedding As List(Of Double) = encoderDecoder.EncodeTokenEmbedding(tokenEmbedding)
  • Encode a list of string tokens and get their positional embeddings:
Dim sentence As New List(Of String) From {"This", "is", "an", "example"}
Dim embeddings As List(Of List(Of Double)) = encoderDecoder.EncodeSentenceStr(sentence)
  • Encode a list of token embeddings and get their positional embeddings:
Dim sentenceEmbeddings As List(Of List(Of Double)) = GetSentenceEmbeddings() ' Get the token embeddings from somewhere
Dim embeddings As List(Of List(Of Double)) = encoderDecoder.EncodeSentenceEmbedding(sentenceEmbeddings)
  1. Decoding:
  • Decode a list of positional embeddings and get the corresponding string tokens:
Dim embeddings As New List(Of List(Of Double)) From {embedding1, embedding2, embedding3}
Dim tokens As List(Of String) = encoderDecoder.DecodeSentenceStr(embeddings)
  • Decode a list of positional embeddings and get the corresponding token embeddings:
Dim embeddings As New List(Of List(Of Double)) From {embedding1, embedding2, embedding3}
Dim tokenEmbeddings As List(Of List(Of Double)) = encoderDecoder.DecodeSentenceEmbedding(embeddings)
  • Decode a positional embedding and get the corresponding string token:
Dim embedding As List(Of Double) = GetPositionalEmbedding() ' Get the positional embedding from somewhere
Dim token As String = encoderDecoder.DecodeTokenStr(embedding)
  • Decode a positional embedding and get the corresponding token embedding:
Dim embedding As List(Of Double) = GetPositionalEmbedding() ' Get the positional embedding from somewhere
Dim tokenEmbedding As List(Of Double) = encoderDecoder.DecodeTokenEmbedding(embedding)

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! Please feel free to open an issue or submit a pull request.

About

This PositionalEncoderDecoder class was developed as part of a project to enable token and sentence encoding/decoding using positional embeddings.

Credits

The PositionalEncoderDecoder class is developed by [LEroySamuelDyer@hotmail.co.uk].

Product Compatible and additional computed target framework versions.
.NET Framework net472 is compatible.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

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 162 7/20/2023

Created for use in Building a Transofrmer in VB.NET