Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.Net: Removed GPT3Tokenizer and related files #2809

Merged
merged 7 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/_typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ extend-exclude = [
"_typos.toml",
"package-lock.json",
"*.bicep",
"encoder.json",
"vocab.bpe",
"GPT3TokenizerTests.cs",
"CodeTokenizerTests.cs",
"test_code_tokenizer.py",
]
Expand Down
2 changes: 1 addition & 1 deletion dotnet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Packages included in **Microsoft.SemanticKernel**:
engineering, semantic memory and semantic functions definition and orchestration.
1. **Microsoft.SemanticKernel.Connectors.AI.OpenAI**: connectors to OpenAI and Azure
OpenAI, allowing to run semantic functions, chats, image generation with GPT3,
GPT3.5, GPT4, DALL-E2. Includes also GPT tokenizers.
GPT3.5, GPT4, DALL-E2.

Other SK packages available at nuget.org:

Expand Down
92 changes: 0 additions & 92 deletions dotnet/samples/KernelSyntaxExamples/Example29_Tokenizer.cs

This file was deleted.

11 changes: 4 additions & 7 deletions dotnet/samples/KernelSyntaxExamples/Example55_TextChunker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.SemanticKernel.Connectors.AI.OpenAI.Tokenizers;
using Microsoft.SemanticKernel.Text;

// ReSharper disable once InconsistentNaming
Expand Down Expand Up @@ -49,8 +48,8 @@ private static void RunExampleWithCustomTokenCounter()
{
Console.WriteLine("=== Text chunking with a custom token counter ===");

var lines = TextChunker.SplitPlainTextLines(text, 40, TokenCounter);
var paragraphs = TextChunker.SplitPlainTextParagraphs(lines, 120, tokenCounter: TokenCounter);
var lines = TextChunker.SplitPlainTextLines(text, 40, CustomTokenCounter);
var paragraphs = TextChunker.SplitPlainTextParagraphs(lines, 120, tokenCounter: CustomTokenCounter);

WriteParagraphsToConsole(paragraphs);
}
Expand All @@ -68,10 +67,8 @@ private static void WriteParagraphsToConsole(List<string> paragraphs)
}
}

private static int TokenCounter(string input)
private static int CustomTokenCounter(string input)
{
var tokens = GPT3Tokenizer.Encode(input);

return tokens.Count;
return input.Length / 4;
dmytrostruk marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,4 @@
<PackageReference Include="Azure.AI.OpenAI" />
</ItemGroup>

<ItemGroup>
<None Remove="Tokenizers\Settings\encoder.json" />
<Content Include="Tokenizers\Settings\encoder.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PackageCopyToOutput>true</PackageCopyToOutput>
</Content>
<None Remove="Tokenizers\Settings\vocab.bpe" />
<Content Include="Tokenizers\Settings\vocab.bpe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PackageCopyToOutput>true</PackageCopyToOutput>
</Content>
</ItemGroup>

</Project>