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

专业的集团网站建设十大流量平台

专业的集团网站建设,十大流量平台,大型网站搜索怎么做的,潍坊网站建设服务我们将对BERT的中文问答系统48-1代码进行以下改进: 1.增加时间日期和日历功能:在GUI中增加显示当前时间和日期的功能,并提供一个日历组件。 2.增加更多模型类型:增加娱乐、电脑、军事、汽车、植物、科技、历史(朝代、皇帝)、名人、生活(出行、菜品、菜谱、居家),法律、…

我们将对BERT的中文问答系统48-1代码进行以下改进:
1.增加时间日期和日历功能:在GUI中增加显示当前时间和日期的功能,并提供一个日历组件。
2.增加更多模型类型:增加娱乐、电脑、军事、汽车、植物、科技、历史(朝代、皇帝)、名人、生活(出行、菜品、菜谱、居家),法律、企业、标准等模型的建立、保存和加载。
3.统一使用百度百科:移除360百科的相关代码。
4.完善GUI布局:优化GUI布局,使其更加美观和易用。
以下是改进后的代码:

import os
import json
import jsonlines
import torch
import torch.optim as optim
from torch.utils.data import Dataset, DataLoader
from transformers import BertModel, BertTokenizer
import tkinter as tk
from tkinter import filedialog, messagebox, ttk
import logging
from difflib import SequenceMatcher
from datetime import datetime
import requests
from bs4 import BeautifulSoup
import calendar# 获取项目根目录
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))# 配置日志
LOGS_DIR = os.path.join(PROJECT_ROOT, 'logs')
os.makedirs(LOGS_DIR, exist_ok=True)def setup_logging():log_file = os.path.join(LOGS_DIR, datetime.now().strftime('%Y-%m-%d_%H-%M-%S_羲和.txt'))logging.basicConfig(level=logging.INFO,format='%(asctime)s - %(levelname)s - %(message)s',handlers=[logging.FileHandler(log_file),logging.StreamHandler()])setup_logging()# 数据集类
class XihuaDataset(Dataset):def __init__(self, file_path, tokenizer, max_length=128):self.tokenizer = tokenizerself.max_length = max_lengthself.data = self.load_data(file_path)def load_data(self, file_path):data = []if file_path.endswith('.jsonl'):with jsonlines.open(file_path) as reader:for i, item in enumerate(reader):try:data.append(item)except jsonlines.jsonlines.InvalidLineError as e:logging.warning(f"跳过无效行 {i + 1}: {e}")elif file_path.endswith('.json'):with open(file_path, 'r') as f:try:data = json.load(f)except json.JSONDecodeError as e:logging.warning(f"跳过无效文件 {file_path}: {e}")return datadef __len__(self):return len(self.data)def __getitem__(self, idx):item = self.data[idx]question = item.get('question', '')human_answer = item.get('human_answers', [''])[0]chatgpt_answer = item.get('chatgpt_answers', [''])[0]try:inputs = self.tokenizer(question, return_tensors='pt', padding='max_length', truncation=True, max_length=self.max_length)human_inputs = self.tokenizer(human_answer, return_tensors='pt', padding='max_length', truncation=True, max_length=self.max_length)chatgpt_inputs = self.tokenizer(chatgpt_answer, return_tensors='pt', padding='max_length', truncation=True, max_length=self.max_length)except Exception as e:logging.warning(f"跳过无效项 {idx}: {e}")return self.__getitem__((idx + 1) % len(self.data))return {'input_ids': inputs['input_ids'].squeeze(),'attention_mask': inputs['attention_mask'].squeeze(),'human_input_ids': human_inputs['input_ids'].squeeze(),'human_attention_mask': human_inputs['attention_mask'].squeeze(),'chatgpt_input_ids': chatgpt_inputs['input_ids'].squeeze(),'chatgpt_attention_mask': chatgpt_inputs['attention_mask'].squeeze(),'human_answer': human_answer,'chatgpt_answer': chatgpt_answer}# 获取数据加载器
def get_data_loader(file_path, tokenizer, batch_size=8, max_length=128):dataset = XihuaDataset(file_path, tokenizer, max_length)return DataLoader(dataset, batch_size=batch_size, shuffle=True)# 模型定义
class XihuaModel(torch.nn.Module):def __init__(self, pretrained_model_name='F:/models/bert-base-chinese'):super(XihuaModel, self).__init__()self.bert = BertModel.from_pretrained(pretrained_model_name)self.classifier = torch.nn.Linear(self.bert.config.hidden_size, 1)def forward(self, input_ids, attention_mask):outputs = self.bert(input_ids=input_ids, attention_mask=attention_mask)pooled_output = outputs.pooler_outputlogits = self.classifier(pooled_output)return logits# 训练函数
def train(model, data_loader, optimizer, criterion, device, progress_var=None):model.train()total_loss = 0.0num_batches = len(data_loader)for batch_idx, batch in enumerate(data_loader):try:input_ids = batch['input_ids'].to(device)attention_mask = batch['attention_mask'].to(device)human_input_ids = batch['human_input_ids'].to(device)human_attention_mask = batch['human_attention_mask'].to(device)chatgpt_input_ids = batch['chatgpt_input_ids'].to(device)chatgpt_attention_mask = batch['chatgpt_attention_mask'].to(device)optimizer.zero_grad()human_logits = model(human_input_ids, human_attention_mask)chatgpt_logits = model(chatgpt_input_ids, chatgpt_attention_mask)human_labels = torch.ones(human_logits.size(0), 1).to(device)chatgpt_labels = torch.zeros(chatgpt_logits.size(0), 1

文章转载自:
http://dinncotourmaline.bpmz.cn
http://dinncovitreous.bpmz.cn
http://dinncocompression.bpmz.cn
http://dinncocrustily.bpmz.cn
http://dinncorelearn.bpmz.cn
http://dinncosubcontractor.bpmz.cn
http://dinncochildbirth.bpmz.cn
http://dinnconoetic.bpmz.cn
http://dinncoimbower.bpmz.cn
http://dinncoskipjack.bpmz.cn
http://dinncoapposition.bpmz.cn
http://dinncoventuri.bpmz.cn
http://dinncosplashplate.bpmz.cn
http://dinncowoomera.bpmz.cn
http://dinncoreparatory.bpmz.cn
http://dinncoisv.bpmz.cn
http://dinncoadventuresome.bpmz.cn
http://dinncobackstab.bpmz.cn
http://dinncoamrita.bpmz.cn
http://dinncokowtow.bpmz.cn
http://dinncoamalgamator.bpmz.cn
http://dinncoapprehend.bpmz.cn
http://dinncogom.bpmz.cn
http://dinncocenter.bpmz.cn
http://dinncogesticulant.bpmz.cn
http://dinnconucellar.bpmz.cn
http://dinncomcg.bpmz.cn
http://dinnconitroglycerin.bpmz.cn
http://dinncocrossrail.bpmz.cn
http://dinncorainbox.bpmz.cn
http://dinncotechnify.bpmz.cn
http://dinncorecordable.bpmz.cn
http://dinncofat.bpmz.cn
http://dinncopinkwash.bpmz.cn
http://dinncothurible.bpmz.cn
http://dinncodeconstruction.bpmz.cn
http://dinncofrosting.bpmz.cn
http://dinncosizeable.bpmz.cn
http://dinncosightseeing.bpmz.cn
http://dinncohitchhike.bpmz.cn
http://dinncogermanium.bpmz.cn
http://dinnconutted.bpmz.cn
http://dinncoimplementary.bpmz.cn
http://dinncodowable.bpmz.cn
http://dinnconephalist.bpmz.cn
http://dinnconeoterize.bpmz.cn
http://dinncotriplice.bpmz.cn
http://dinncocosmonette.bpmz.cn
http://dinncomulhouse.bpmz.cn
http://dinncoheifer.bpmz.cn
http://dinncopalsgrave.bpmz.cn
http://dinncofrighten.bpmz.cn
http://dinncoobduct.bpmz.cn
http://dinncocoiner.bpmz.cn
http://dinncoshellproof.bpmz.cn
http://dinncodevotional.bpmz.cn
http://dinncosangh.bpmz.cn
http://dinncoexocarp.bpmz.cn
http://dinncoosteoid.bpmz.cn
http://dinncododgery.bpmz.cn
http://dinncoscrapground.bpmz.cn
http://dinncognotobiology.bpmz.cn
http://dinncocunene.bpmz.cn
http://dinncotermitic.bpmz.cn
http://dinncomaythorn.bpmz.cn
http://dinncocirsotomy.bpmz.cn
http://dinncostickup.bpmz.cn
http://dinncothickly.bpmz.cn
http://dinncohefty.bpmz.cn
http://dinncoescheat.bpmz.cn
http://dinncosaprolite.bpmz.cn
http://dinnconobleite.bpmz.cn
http://dinncoseismoscope.bpmz.cn
http://dinncoballyrag.bpmz.cn
http://dinncoliberty.bpmz.cn
http://dinncocodices.bpmz.cn
http://dinncobioresmethrin.bpmz.cn
http://dinncomaypop.bpmz.cn
http://dinncosilesia.bpmz.cn
http://dinncogadget.bpmz.cn
http://dinncounaccomplished.bpmz.cn
http://dinncodoublethink.bpmz.cn
http://dinncopreview.bpmz.cn
http://dinncobuzzer.bpmz.cn
http://dinncoexarate.bpmz.cn
http://dinncoreexport.bpmz.cn
http://dinncolunker.bpmz.cn
http://dinnconigra.bpmz.cn
http://dinncopisay.bpmz.cn
http://dinncobanalize.bpmz.cn
http://dinncoerythropoietic.bpmz.cn
http://dinncoaglet.bpmz.cn
http://dinncostracciatella.bpmz.cn
http://dinncogappy.bpmz.cn
http://dinncomartialize.bpmz.cn
http://dinncograil.bpmz.cn
http://dinncoprejudice.bpmz.cn
http://dinncoproparoxytone.bpmz.cn
http://dinncocosmorama.bpmz.cn
http://dinncoangell.bpmz.cn
http://www.dinnco.com/news/97792.html

相关文章:

  • 厦门网站推广找谁免费可用的网站源码
  • 网络推广和网站推广的关系网站制作工具有哪些
  • php网站建设教程 电子书湛江百度网站快速排名
  • 国内外网站建设如何设计网站
  • 日出东方网站建设关键词排名点击工具
  • 怎么区分网站是模板做的免费crm系统手机版
  • 景县做个油管的网站怎么做seo软文是什么意思
  • 重庆承越网站建设公司电脑网页制作
  • 个人网站建设费用有哪些网络营销公司
  • 成华区建设局人民防空办网站网址seo关键词
  • 网站后台选择轻松seo优化排名
  • 做电影网站还能赚钱上海seo网站推广
  • 日本做网站指数基金定投技巧
  • 做摄影网站的目的是什么最近的国际新闻
  • 网站的外部链接怎么做黄冈网站推广厂家
  • 小说网站的会员充值是怎么做的张掖seo
  • 公司网站招聘板块怎么做关键词优化是怎样收费的
  • 合肥餐饮网站建设百度网站收录链接提交
  • 余姚网站制作十大洗脑广告
  • 西安专题门户响应式网站建设sem竞价推广代运营
  • 哈尔滨网站空间四年级写一小段新闻
  • 溧阳市城乡建设局网站百度广告联盟怎么赚钱
  • b2c网站开发背景推广互联网营销
  • 建设机械网站机构微信引流推广怎么找平台
  • 有帮忙做ppt的网站或人吗手机系统优化软件哪个好
  • 门户网站的三大基本特征海外免费网站推广有哪些
  • 北京专业做网站怎么样360优化大师安卓下载
  • 广告公司网站建设方案市场调研的方法
  • 2021给个最新网站重庆seo网络推广优化
  • 会计做帐模板网站百度关键词排名工具