当前位置: 首页 > news >正文

网络设计方案书主要包括哪些内容seo 知乎

网络设计方案书主要包括哪些内容,seo 知乎,如何做网站客户端,电子商务网页设计试题文章目录 解决tiktoken库调用get_encoding时SSL超时1. 获取词表文件url2. 手动下载词表文件并保存到本地3. 复制并重命名文件4. 环境变量中设置tiktoken cache5. 使用tiktoken库参考资料 解决tiktoken库调用get_encoding时SSL超时 最近在看Build a Large Language Model (From… 文章目录 解决tiktoken库调用get_encoding时SSL超时1. 获取词表文件url2. 手动下载词表文件并保存到本地3. 复制并重命名文件4. 环境变量中设置tiktoken cache5. 使用tiktoken库参考资料 解决tiktoken库调用get_encoding时SSL超时 最近在看Build a Large Language Model (From Scratch) 这本书。在该书的第二章中作者尝试使用tiktoken库构建一个tokenizer。然而当我执行以下代码时程序报错。 import tiktoken tokenizer tiktoken.get_encoding(gpt2)ConnectTimeout: HTTPSConnectionPool(hostopenaipublic.blob.core.windows.net, port443): Max retries exceeded with url: /encodings/gpt2.tiktoken (Caused by ConnectTimeoutError(urllib3.connection.HTTPSConnection object at 0x7fd41b819630, Connection to openaipublic.blob.core.windows.net timed out. (connect timeoutNone)))这个错误的根本原因是构建tokenizer时tiktoken库尝试下载词表文件遇到网络问题而失败。一个可行的解决方案时先手动下载文件到本地然后让tiktoken直接从本地文件读取数据并构建tokenizer。 1. 获取词表文件url First, let’s grab the tokenizer blob URL from the source on your remote machine. If we trace the get_encoding function, we find it calls a function from tiktoken_ext.openai_public which has the blob URIs for each encoder. Identify the correct function, then print the source 首先需要查看一下构建我们所需的tokenizer需要哪些词表文件。我这里需要使用构建名为gpt2的tokenizer。从下面的输出信息可以看到还有 o200k_base, p50k_base等可供选择。结果显示构建gpt2tokenizer需要下载vocab.bpe和encoder.json两个文件。 import tiktoken_ext.openai_public import inspectprint(dir(tiktoken_ext.openai_public)) # The encoder we want is cl100k_base, we see this as a possible functionprint(inspect.getsource(tiktoken_ext.openai_public.gpt2)) # The URL should be in the load_tiktoken_bpe function call运行结果 [ENCODING_CONSTRUCTORS, ENDOFPROMPT, ENDOFTEXT, FIM_MIDDLE, FIM_PREFIX, FIM_SUFFIX, __builtins__, __cached__, __doc__, __file__, __loader__, __name__, __package__, __spec__, cl100k_base, data_gym_to_mergeable_bpe_ranks, gpt2, load_tiktoken_bpe, o200k_base, p50k_base, p50k_edit, r50k_base] def gpt2():mergeable_ranks data_gym_to_mergeable_bpe_ranks(vocab_bpe_filehttps://openaipublic.blob.core.windows.net/gpt-2/encodings/main/vocab.bpe,encoder_json_filehttps://openaipublic.blob.core.windows.net/gpt-2/encodings/main/encoder.json,vocab_bpe_hash1ce1664773c50f3e0cc8842619a93edc4624525b728b188a9e0be33b7726adc5,encoder_json_hash196139668be63f3b5d6574427317ae82f612a97c5d1cdaf36ed2256dbf636783,)return {name: gpt2,explicit_n_vocab: 50257,# The pattern in the original GPT-2 release is:# rs|t|re|ve|m|ll|d| ?[\p{L}]| ?[\p{N}]| ?[^\s\p{L}\p{N}]|\s(?!\S)|\s# This is equivalent, but executes faster:pat_str: r(?:[sdmt]|ll|ve|re)| ?\p{L}| ?\p{N}| ?[^\s\p{L}\p{N}]|\s(?!\S)|\s,mergeable_ranks: mergeable_ranks,special_tokens: {ENDOFTEXT: 50256},}2. 手动下载词表文件并保存到本地 根据步骤1获得的url手动下载词表文件并保存到本地。 3. 复制并重命名文件 新建一个文件夹.tiktoken将下载的词表文件复制至该文件夹。重命名各文件新的文件值可以通过执行以下代码获取。blobpath是步骤1中获取的该文件对应的url值。 import hashlibblobpath your_blob_url_here cache_key hashlib.sha1(blobpath.encode()).hexdigest() print(cache_key)比如对于我刚刚下载的encoder.json文件结果如下 import hashlibblobpath https://openaipublic.blob.core.windows.net/gpt-2/encodings/main/encoder.json cache_key hashlib.sha1(blobpath.encode()).hexdigest() print(cache_key)6c7ea1a7e38e3a7f062df639a5b80947f075ffe6于是将encoder.json重命名为6c7ea1a7e38e3a7f062df639a5b80947f075ffe6注意重命名后的文件不带.json后缀。 4. 环境变量中设置tiktoken cache 执行以下代码指定tiktoken cache为.titoken文件夹。注意每次使用tiktoken库时都要运行下述代码。 import ostiktoken_cache_dir path_to_folder_containing_tiktoken_file os.environ[TIKTOKEN_CACHE_DIR] tiktoken_cache_dir# validate assert os.path.exists(os.path.join(tiktoken_cache_dir, cache_key))5. 使用tiktoken库 现在应该可以正常使用tiktoken库构建tokenizer。 encoding tiktoken.get_encoding(gpt2) encoding.encode(Hello, world)[15496, 11, 995]参考资料 [1] SSLError: HTTPSConnectionPool(host‘openaipublic.blob.core.windows.net’, port443): Max retries exceeded with url · Issue #281 · openai/tiktoken (github.com) [2] python - how to use tiktoken in offline mode computer - Stack Overflow
http://www.hkea.cn/news/14376808/

相关文章:

  • 建设用地规划查询网站淘金网站建设推广
  • 四川微信网站建设wordpress级简主题
  • 网站建设广告素材辽宁建设工程信息网公司评分
  • 怎么做一个赚钱得网站wordpress百度云插件
  • 哪些是实名制网站网页设计图片与文字对齐左对齐
  • 上海企业建站工具中小型网站服务器搭建方案
  • 天津网站推广宣传wordpress上传速度
  • 儿童故事网站建设qq浏览器收录网站提交入口
  • 德阳网站建设公司建筑交流平台
  • 贵阳做网站开发的公司服务外包公司是干什么的
  • wordpress能做流量站吗哈尔滨寸金网站建设价格
  • 做网站数据库有哪些wordpress 手机端 广告
  • 东莞网站建设报价方案wordpress 获取category id
  • 合肥网站建设ahyedawordpress 文章数据
  • 微官网建设贵州seo培训
  • 网站建设专业简介企业概况的模板
  • 见网页制作的公司网站wordpress常见问题
  • 网站app免费制作软件新网站收录多少关键词
  • 备案关闭网站建设影响点金网站建设
  • 网站空间域名费wordpress 获取 图片说明
  • 众筹网站建设公司手机网站建设用乐云seo
  • 怎么做网站劳务中介红帽linux安装wordpress
  • 主播网站怎么建设设计家官网室内设计视频
  • 阿里培训网站建设石家庄学做网站建设培训学校
  • 福建福州建设局网站石家庄24号解封通知
  • 河南郑州网站制作别人用我的备案信息做网站
  • 彩票网站开发制作需要什么图片编辑器在线制作
  • 蒙icp备网站建设阿里云wordpress在哪里设置
  • 网站建设推广是什么工作wordpress未验证邮箱用户
  • 顶呱呱网站开发广东模板网站建设