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

python tiktoken的簡(jiǎn)介、安裝、使用方法

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

tiktoken的簡(jiǎn)介

tiktoken是一個(gè)用于OpenAI模型的快速BPE標(biāo)記器。

1、性能:tiktoken比一個(gè)類(lèi)似的開(kāi)源分詞器快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標(biāo)記器

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過(guò)程的代碼

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的簡(jiǎn)介、安裝、使用方法的文章就介紹到這了,更多相關(guān)python tiktoken安裝使用內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

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

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

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

    pytorch 中transforms的使用詳解

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

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

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

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

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

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

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

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

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

    python3 lambda表達(dá)式詳解

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

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

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

    完美解決python遍歷刪除字典里值為空的元素報(bào)錯(cuò)問(wèn)題

    下面小編就為大家?guī)?lái)一篇完美解決python遍歷刪除字典里值為空的元素報(bào)錯(cuò)問(wèn)題。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2016-09-09
  • Python可變參數(shù)會(huì)自動(dòng)填充前面的默認(rèn)同名參數(shù)實(shí)例

    Python可變參數(shù)會(huì)自動(dòng)填充前面的默認(rèn)同名參數(shù)實(shí)例

    今天小編就為大家分享一篇Python可變參數(shù)會(huì)自動(dòng)填充前面的默認(rèn)同名參數(shù)實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2019-11-11

最新評(píng)論