科大讯飞AI大赛(多模态RAG方向)

优化了一部分代码,暂时还不够发博客。先这样放着

       results = []
        if selected_indices:
            # 引入time模块用于延时
            import time
            batch_size = 100  # 每批处理100个
            delay_minutes = 5  # 延迟5分钟
            total_batches = (len(selected_indices) + batch_size - 1) // batch_size

            for batch_idx in range(total_batches):
                # 计算当前批次的起始和结束索引
                start_idx = batch_idx * batch_size
                end_idx = min((batch_idx + 1) * batch_size, len(selected_indices))
                batch_indices = selected_indices[start_idx:end_idx]

                print(f'处理批次 {batch_idx + 1}/{total_batches},共 {len(batch_indices)} 个任务')

                # 使用线程池处理当前批次
                with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
                    batch_results = list(tqdm(executor.map(process_one, batch_indices), 
                                              total=len(batch_indices), 
                                              desc=f'批次 {batch_idx + 1} 处理'))
                    results.extend(batch_results)

                # 如果不是最后一批,延迟5分钟
                if batch_idx < total_batches - 1:
                    print(f'批次 {batch_idx + 1} 处理完成,开始延迟 {delay_minutes} 分钟...')
                    time.sleep(delay_minutes * 60)  # 转换为秒
                    print('延迟结束,继续处理下一批次')

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值