Attention Program

按Esc键可以调出 Attention Program,

可通过以下方法

1) CL命令:Set Attention Program (SETATNPGM) 
 影响当前job

2) User Profile
Attention program  . . . . . . . . . . . . :   QUSCMDLN  
  Library  . . . . . . . . . . . . . . . . :     *LIBL  
 
3)wrksysval QATNPGM 
 System value . . . . . :   QATNPGM           
 Description  . . . . . :   Attention program 
                                              
 Attention program  . . . . . :   *ASSIST     
   Library  . . . . . . . . . :              

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
from transformers import BertTokenizer, BertForQuestionAnswering import torch # 加载BERT模型和分词器 model_name = 'bert-base-uncased' tokenizer = BertTokenizer.from_pretrained(model_name) model = BertForQuestionAnswering.from_pretrained(model_name) # 输入文本和问题 context = "The Apollo program, also known as Project Apollo, was the third United States human spaceflight program carried out by the National Aeronautics and Space Administration (NASA), which succeeded in landing the first humans on the Moon from 1969 to 1972. Apollo was first conceived during the Eisenhower administration in early 1960 as a follow-up to Project Mercury. It was dedicated to President John F. Kennedy's national goal of landing Americans on the Moon before the end of the 1960s." question = "What was the goal of the Apollo program?" # 对输入进行编码 encoding = tokenizer.encode_plus(question, context, max_length=512, padding='max_length', truncation=True, return_tensors='pt') # 获取输入ids和注意力掩码 input_ids = encoding['input_ids'] attention_mask = encoding['attention_mask'] # 使用BERT模型进行问答 outputs = model(input_ids=input_ids, attention_mask=attention_mask) start_scores = outputs.start_logits end_scores = outputs.end_logits # 获取答案的起始和结束位置 start_index = torch.argmax(start_scores) end_index = torch.argmax(end_scores) # 解码答案 answer = tokenizer.convert_tokens_to_string(tokenizer.convert_ids_to_tokens(input_ids[0][start_index:end_index+1])) print(answer)
07-13

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值