gpt_3_encoder 1.0.1 copy "gpt_3_encoder: ^1.0.1" to clipboard
gpt_3_encoder: ^1.0.1 copied to clipboard

A pure Dart implementation of OpenAI's original Python encoder/decoder for GPT models.

example/gpt_3_encoder_example.dart

import 'package:gpt_3_encoder/gpt_3_encoder.dart';

void main() {
  // This is the text we want to encode and decode.
  final text = "Dart";

  // Encode the text.
  final encoded = GPT3Encoder.instance.encode(text);

  // Print the encoded text.
  print(
    "Your text contains ${encoded.length} tokens,w encoded as follows: $encoded",
  );

  // Decode the encoded text token by token and print the result.
  for (var token in encoded) {
    final decoded = GPT3Encoder.instance.decode([token]);
    print("Token: $token, decoded as: $decoded");
  }
}
2
likes
160
pub points
21%
popularity

Publisher

verified publishergwhyyy.com

A pure Dart implementation of OpenAI's original Python encoder/decoder for GPT models.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

More

Packages that depend on gpt_3_encoder