Spaces:
No application file
No application file
Download src/utils/utilities.py from sid-0313/rag-based-search: direct link, hf CLI and curl.
- Browser
- Download file 156 Bytes
-
https://huggingface.co/spaces/sid-0313/rag-based-search/resolve/main/src/utils/utilities.py
- Command line
-
hf download hf://spaces/sid-0313/rag-based-search/src/utils/utilities.py
-
curl -L -o utilities.py https://huggingface.co/spaces/sid-0313/rag-based-search/resolve/main/src/utils/utilities.py
156 Bytes
| import tiktoken | |
| def count_num_tokens(text: str, model: str) -> int: | |
| encoding = tiktoken.encoding_for_model(model) | |
| return len(encoding.encode(text)) |