-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Encode() returns tokens' string representation too
- Loading branch information
Daulet Zhanguzin
committed
Jul 7, 2023
1 parent
c220985
commit 19c010f
Showing
7 changed files
with
124 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,26 @@ | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
|
||
struct Buffer { | ||
uint32_t *ids; | ||
char *tokens; | ||
uint32_t len; | ||
}; | ||
|
||
void *from_bytes(const uint8_t *config, uint32_t len); | ||
|
||
void *from_bytes_with_truncation(const uint8_t *config, uint32_t len, uint32_t max_len, uint8_t direction); | ||
|
||
void *from_file(const char *config); | ||
|
||
void free_tokenizer(void *ptr); | ||
|
||
uint32_t *encode(void *ptr, const char *message, uint32_t *len, bool add_special_tokens); | ||
struct Buffer encode(void *ptr, const char *message, bool add_special_tokens); | ||
|
||
char *decode(void *ptr, const uint32_t *ids, uint32_t len, bool skip_special_tokens); | ||
|
||
uint32_t vocab_size(void *ptr); | ||
|
||
void free_tokenizer(void *ptr); | ||
|
||
void free_buffer(struct Buffer buffer); | ||
|
||
void free_string(char *string); |