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

细胞医疗 网站模版投资公司网站建设

细胞医疗 网站模版,投资公司网站建设,企业邮箱地址格式,系统搭建方案论文: https://arxiv.org/abs/2004.05150 目录 库安装 LongformerForQuestionAnswering 库安装 首先保证电脑上配置了git. git环境配置: https://blog.csdn.net/Andone_hsx/article/details/87937329 3.1、找到git安装路径中bin的位置,如:D:\Prog…

论文:

https://arxiv.org/abs/2004.05150

目录

库安装

LongformerForQuestionAnswering


库安装

首先保证电脑上配置了git.

git环境配置:

https://blog.csdn.net/Andone_hsx/article/details/87937329

3.1、找到git安装路径中bin的位置,如:D:\Program Files\Git\bin

        找到git安装路径中git-core的位置,如:D:\Program Files\Git\libexec\git-core;

        注:"D:\Program Files\Git\"是安装路径,可能与你的安装路径不一样,要按照你自己的路径替换"D:\Program Files\Git\"

        3.2、右键“计算机”->“属性”->“高级系统设置”->“环境变量”->在下方的“系统变量”中找到“path”->选中“path”并选择“编辑”->将            3.1中找到的bin和git-core路径复制到其中->保存并退出

        注:“path”中,每个路径之间要以英文输入状态下的分号——“;”作为间隔

D:\Program Files\Git\mingw64\bin

D:\Program Files\Git\mingw64\libexec\git-core

安装环境

conda create --name longformer python=3.7

y

conda activate longformer

conda install cudatoolkit=10.0

y

pip install git+https://github.com/allenai/longformer.git

报错:

ERROR: Could not find a version that satisfies the requirement pandas>=0.20.3 (from test-tube) (from versions: none)

ERROR: No matching distribution found for pandas>=0.20.3

No module named 'pandas'

Install装不上, 在anaconda navigator装的

更换清华源后似乎可以继续运行了, 参考:

https://www.cnblogs.com/raiuny/p/15950043.html

conda config --add channels Index of /anaconda/cloud/pytorch/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror

conda config --set show_channel_urls yes

conda config --set auto_activate_base false

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

好几次报错128, 也许是RP问题, 总之重新运行几次后安装成功了.

环境安装成功会显示successful.

接着跑tests文件夹的test_readme.py, 注意需要下载longformer-base-4096.tar.gz

这个文件我放在项目目录下的/tmp文件夹和tests/tmp都无法读取, 因此修改了self.model_dir路径为绝对路径, 并注释下载解压代码, 就可以运行了:

LongformerForQuestionAnswering

1)test_readme中默认使用的Longformer模型输出是embedding, 缺少LMHead把embedding映射成tokenid或logits等, 无法输出文字. 如果使用Longformer完成最终任务, 需要自己写映射并训练.

2)文档其它longformer模型. 大部分为分类模型. 其中LongformerForQuestionAnswering符合extractive summarization

3)coding过程中可以参考huggingface上的文档例子从transformers库里面调用其它种类的longformer

from transformers import AutoTokenizer, LongformerForQuestionAnswering

import torch

tokenizer = AutoTokenizer.from_pretrained("allenai/longformer-large-4096-finetuned-triviaqa")

model = LongformerForQuestionAnswering.from_pretrained("allenai/longformer-large-4096-finetuned-triviaqa")

question, text = "Who was Jim Henson?", "Jim Henson was a nice puppet"

encoding = tokenizer(question, text, return_tensors="pt")

input_ids = encoding["input_ids"]

# default is local attention everywhere

# the forward method will automatically set global attention on question tokens

attention_mask = encoding["attention_mask"]

outputs = model(input_ids, attention_mask=attention_mask)

start_logits = outputs.start_logits

end_logits = outputs.end_logits

all_tokens = tokenizer.convert_ids_to_tokens(input_ids[0].tolist())

answer_tokens = all_tokens[torch.argmax(start_logits) : torch.argmax(end_logits) + 1]

answer = tokenizer.decode(

    tokenizer.convert_tokens_to_ids(answer_tokens)

)  # remove space prepending space token

如果加载其它qa模型(longformer_base_4096_QA_SQUAD)不配套会报错:

Some weights of the model checkpoint at tmp/longformer_base_4096_QA_SQUAD were not used when initializing LongformerForQuestionAnswering: ['classifier.dense.weight', 'classifier.dense.bias', 'classifier.out_proj.weight', 'classifier.out_proj.bias']

按照示例代码加载longformer-large-4096-finetuned-triviaqa后报错

start_logits = outputs.start_logits

AttributeError: 'tuple' object has no attribute 'start_logits'

这个报错的意思是返回值不是对象而是元组, 因此判断如果是元组, 则手动解析

if isinstance(outputs, tuple):

    loss,start_logits, end_logits,hidden_states,attentions = outputs

else:

    start_logits = outputs.start_logits

    end_logits = outputs.end_logits

库中LongformerForQuestionAnswering类代码有两处可能返回

1.

output = (start_logits, end_logits) + outputs[2:]

2.

return SequenceClassifierOutput(

            loss=loss,

            logits=logits,

            hidden_states=outputs.hidden_states,

            attentions=outputs.attentions,

        )

http://www.yayakq.cn/news/647923/

相关文章:

  • 免费自助建站系统平台 贴吧深圳推广优化公司
  • 自己做聊天背景网站男女做暖暖到网站
  • 网站禁止pingdedecms手机网站模板
  • 域名到期网站精品课程网站开发
  • 做简单网站需要学什么软件有哪些内容做直播网站宽带
  • 沈阳网站设计开发公司占酷设计网站官网入口
  • 网站开发后端语言有哪些做网站跟桌面程序差别大吗
  • 商服网站模板python自学
  • 太原中小企业网站制作上海做网站的知名企业
  • 东营网站建设培训学校线上运营怎么做
  • 兰州专业做网站的公司有哪些公司logo怎么设计
  • 兰陵住房建设局网站辽宁省建设工程造价管理协会网站
  • 开源php建站系统清远新闻最新
  • 北京网站建设yi wl制作网站参考案例
  • 宜宾网站建设08keji自己做的网站出现广告
  • 政务网站建设经验交流发言搜索引擎优化师工资
  • 仿同程网 连锁酒店 网站模板个人网站名称要求
  • 最大的网站佛山制作网站公司推荐
  • wordpress 标签列表页搜索引擎优化是做什么的
  • 西安网站建设资讯wordpress 首页不更新
  • 网站空间便宜网站空间 价格
  • 网站设计方案谁写seo顾问张智伟
  • 昆明网站建设培训班怎么做网站注册系统
  • 域名拍卖网站百度上免费创建网站
  • 一流的上海网站建设公一般网站建设
  • 天猫交易网站厦门 网站制作
  • 个人免费网站如何做asp服装网站模板
  • 建设网站教程2016网站建设相关视频
  • 北京 公司网站 备案中 开通访问如何根据网址攻击网站
  • 怎样做代刷网站合购8登录WordPress