亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

python tiktoken的簡介、安裝、使用方法

 更新時間:2023年10月20日 14:28:21   作者:一個處女座的程序猿  
tiktoken是OpenAI于近期開源的Python第三方模塊,該模塊主要實現(xiàn)了tokenizer的BPE(Byte pair encoding)算法,并對運行性能做了極大的優(yōu)化,本文將介紹python tiktoken的簡介、安裝、使用方法,感興趣的朋友跟隨小編一起看看吧

tiktoken的簡介

tiktoken是一個用于OpenAI模型的快速BPE標記器。

1、性能:tiktoken比一個類似的開源分詞器快3到6倍

tiktoken的安裝

pip install tiktoken
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tiktoken
C:\Windows\system32>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tiktoken
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting tiktoken
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/91/cf/7f3b821152f7abb240950133c60c394f7421a5791b020cedb190ff7a61b4/tiktoken-0.5.1-cp39-cp39-win_amd64.whl (760 kB)
     |████████████████████████████████| 760 kB 726 kB/s
Requirement already satisfied: regex>=2022.1.18 in d:\programdata\anaconda3\lib\site-packages (from tiktoken) (2022.3.15)
Requirement already satisfied: requests>=2.26.0 in d:\programdata\anaconda3\lib\site-packages (from tiktoken) (2.31.0)
Requirement already satisfied: charset-normalizer<4,>=2 in d:\programdata\anaconda3\lib\site-packages (from requests>=2.26.0->tiktoken) (2.0.12)
Requirement already satisfied: urllib3<3,>=1.21.1 in d:\programdata\anaconda3\lib\site-packages (from requests>=2.26.0->tiktoken) (1.26.9)
Requirement already satisfied: idna<4,>=2.5 in d:\programdata\anaconda3\lib\site-packages (from requests>=2.26.0->tiktoken) (3.3)
Requirement already satisfied: certifi>=2017.4.17 in d:\programdata\anaconda3\lib\site-packages (from requests>=2.26.0->tiktoken) (2021.10.8)
Installing collected packages: tiktoken
Successfully installed tiktoken-0.5.1

tiktoken的使用方法

1、基礎(chǔ)用法

(1)、用于OpenAI模型的快速BPE標記器

import tiktoken
enc = tiktoken.get_encoding("cl100k_base")
assert enc.decode(enc.encode("hello world")) == "hello world"
# To get the tokeniser corresponding to a specific model in the OpenAI API:
enc = tiktoken.encoding_for_model("gpt-4")

(2)、幫助可視化BPE過程的代碼

from tiktoken._educational import *
# Train a BPE tokeniser on a small amount of text
enc = train_simple_encoding()
# Visualise how the GPT-4 encoder encodes text
enc = SimpleBytePairEncoding.from_tiktoken("cl100k_base")
enc.encode("hello world aaaaaaaaaaaa")

到此這篇關(guān)于python tiktoken的簡介、安裝、使用方法的文章就介紹到這了,更多相關(guān)python tiktoken安裝使用內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • keras讀取訓(xùn)練好的模型參數(shù)并把參數(shù)賦值給其它模型詳解

    keras讀取訓(xùn)練好的模型參數(shù)并把參數(shù)賦值給其它模型詳解

    這篇文章主要介紹了keras讀取訓(xùn)練好的模型參數(shù)并把參數(shù)賦值給其它模型詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-06-06
  • pytorch 中transforms的使用詳解

    pytorch 中transforms的使用詳解

    本文主要介紹了pytorch中transforms的使用詳解,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2022-06-06
  • 如何向scrapy中的spider傳遞參數(shù)的幾種方法

    如何向scrapy中的spider傳遞參數(shù)的幾種方法

    這篇文章主要介紹了如何向scrapy中的spider傳遞參數(shù)的幾種方法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-11-11
  • Python實現(xiàn)Youku視頻批量下載功能

    Python實現(xiàn)Youku視頻批量下載功能

    前段時間由于收集視頻數(shù)據(jù)的需要,自己搗鼓了一個YouKu視頻批量下載的程序。下面小編把實現(xiàn)過程分享到腳本之家平臺,供大家參考
    2017-03-03
  • python實現(xiàn)Dijkstra靜態(tài)尋路算法

    python實現(xiàn)Dijkstra靜態(tài)尋路算法

    這篇文章主要介紹了python實現(xiàn)Dijkstra靜態(tài)尋路算法,常用于路由算法或者作為其他圖算法的一個子模塊,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-01-01
  • Python的多態(tài)性實例分析

    Python的多態(tài)性實例分析

    這篇文章主要介紹了Python的多態(tài)性,以實例形式深入淺出的分析了Python在面向?qū)ο缶幊讨卸鄳B(tài)性的原理與實現(xiàn)方法,需要的朋友可以參考下
    2015-07-07
  • python3 lambda表達式詳解

    python3 lambda表達式詳解

    本文主要給大家詳細介紹的是Python3中的lambda表達式的語法和用法,非常的詳細,有需要的小伙伴可以參考下
    2021-05-05
  • 詳解python文件的操作和異常的處理

    詳解python文件的操作和異常的處理

    這篇文章主要為大家介紹了python文件的操作和異常的處理,具有一定的參考價值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來幫助
    2021-12-12
  • 完美解決python遍歷刪除字典里值為空的元素報錯問題

    完美解決python遍歷刪除字典里值為空的元素報錯問題

    下面小編就為大家?guī)硪黄昝澜鉀Qpython遍歷刪除字典里值為空的元素報錯問題。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-09-09
  • Python可變參數(shù)會自動填充前面的默認同名參數(shù)實例

    Python可變參數(shù)會自動填充前面的默認同名參數(shù)實例

    今天小編就為大家分享一篇Python可變參數(shù)會自動填充前面的默認同名參數(shù)實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-11-11

最新評論