Spaces:
Runtime error
Runtime error
Download App_Function_Libraries/Tokenization_Methods_Lib.py from oceansweep/tldw: direct link, hf CLI and curl.
- Browser
- Download file 786 Bytes
-
https://huggingface.co/spaces/oceansweep/tldw/resolve/main/App_Function_Libraries/Tokenization_Methods_Lib.py
- Command line
-
hf download hf://spaces/oceansweep/tldw/App_Function_Libraries/Tokenization_Methods_Lib.py
-
curl -L -o Tokenization_Methods_Lib.py https://huggingface.co/spaces/oceansweep/tldw/resolve/main/App_Function_Libraries/Tokenization_Methods_Lib.py
786 Bytes
| # Tokenization_Methods_Lib.py | |
| ######################################### | |
| # Tokenization Methods Library | |
| # This library is used to handle tokenization of text for summarization. | |
| # | |
| #### | |
| import tiktoken | |
| # Import Local | |
| from typing import List | |
| #################### | |
| # Function List | |
| # | |
| # 1. openai_tokenize(text: str) -> List[str] | |
| # | |
| #################### | |
| ####################################################################################################################### | |
| # Function Definitions | |
| # | |
| def openai_tokenize(text: str) -> List[str]: | |
| encoding = tiktoken.encoding_for_model('gpt-4-turbo') | |
| return encoding.encode(text) | |
| # | |
| # | |
| ####################################################################################################################### | |