[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-PolyAI-LDN--conversational-datasets":3,"tool-PolyAI-LDN--conversational-datasets":61},[4,18,26,36,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",144730,2,"2026-04-07T23:26:32",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":32,"last_commit_at":42,"category_tags":43,"status":17},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107888,"2026-04-06T11:32:50",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":32,"last_commit_at":50,"category_tags":51,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[52,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":10,"last_commit_at":59,"category_tags":60,"status":17},4487,"LLMs-from-scratch","rasbt\u002FLLMs-from-scratch","LLMs-from-scratch 是一个基于 PyTorch 的开源教育项目，旨在引导用户从零开始一步步构建一个类似 ChatGPT 的大型语言模型（LLM）。它不仅是同名技术著作的官方代码库，更提供了一套完整的实践方案，涵盖模型开发、预训练及微调的全过程。\n\n该项目主要解决了大模型领域“黑盒化”的学习痛点。许多开发者虽能调用现成模型，却难以深入理解其内部架构与训练机制。通过亲手编写每一行核心代码，用户能够透彻掌握 Transformer 架构、注意力机制等关键原理，从而真正理解大模型是如何“思考”的。此外，项目还包含了加载大型预训练权重进行微调的代码，帮助用户将理论知识延伸至实际应用。\n\nLLMs-from-scratch 特别适合希望深入底层原理的 AI 开发者、研究人员以及计算机专业的学生。对于不满足于仅使用 API，而是渴望探究模型构建细节的技术人员而言，这是极佳的学习资源。其独特的技术亮点在于“循序渐进”的教学设计：将复杂的系统工程拆解为清晰的步骤，配合详细的图表与示例，让构建一个虽小但功能完备的大模型变得触手可及。无论你是想夯实理论基础，还是为未来研发更大规模的模型做准备",90106,"2026-04-06T11:19:32",[35,15,13,14],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":66,"readme_en":67,"readme_zh":68,"quickstart_zh":69,"use_case_zh":70,"hero_image_url":71,"owner_login":72,"owner_name":73,"owner_avatar_url":74,"owner_bio":75,"owner_company":76,"owner_location":76,"owner_email":77,"owner_twitter":76,"owner_website":78,"owner_url":79,"languages":80,"stars":93,"forks":94,"last_commit_at":95,"license":96,"difficulty_score":97,"env_os":98,"env_gpu":99,"env_ram":100,"env_deps":101,"category_tags":109,"github_topics":110,"view_count":32,"oss_zip_url":76,"oss_zip_packed_at":76,"status":17,"created_at":114,"updated_at":115,"faqs":116,"releases":147},5333,"PolyAI-LDN\u002Fconversational-datasets","conversational-datasets","Large datasets for conversational AI","conversational-datasets 是一个专为对话式人工智能研发打造的大型开源数据集集合。它旨在解决高质量、大规模对话训练数据稀缺的难题，帮助开发者构建更精准的自动回复与问答模型。\n\n该工具主要面向 AI 研究人员和机器学习工程师，提供了包括 Reddit 论坛线程、多语言电影字幕（OpenSubtitles）以及亚马逊商品问答（Amazon QA）在内的海量数据源。经过严格清洗与过滤，这些数据集包含了数亿条结构化的“上下文 - 回复”样本，非常适合用于模型的预训练及特定领域任务的微调。\n\n其独特的技术亮点在于“可复现性”。conversational-datasets 不直接提供处理好的静态数据文件，而是交付标准化的生成脚本。用户可以在本地运行脚本，自定义预处理和过滤逻辑，并自动生成确定性的训练集与测试集划分。这种机制不仅确保了不同研究之间的评估结果公平可比，也让使用者能完全掌控数据质量。无论是希望探索大模型潜力的学者，还是需要构建稳健对话系统的开发团队，都能从中获得强有力的数据支持。","[![CircleCI](https:\u002F\u002Fcircleci.com\u002Fgh\u002FPolyAI-LDN\u002Fconversational-datasets.svg?style=svg&circle-token=25d37b8026cb0c81306db68d098703f81dd74da9)](https:\u002F\u002Fcircleci.com\u002Fgh\u002FPolyAI-LDN\u002Fconversational-datasets)\n\n[![PolyAI](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FPolyAI-LDN_conversational-datasets_readme_f4095d03c28b.png)](https:\u002F\u002Fpoly-ai.com\u002F)\n\n# conversational-datasets\n\n*A collection of large datasets for conversational response selection.*\n\nThis repository provides tools to create reproducible datasets for training and evaluating models of conversational response. This includes:\n\n* [Reddit](reddit) - 3.7 billion comments structured in threaded conversations\n* [OpenSubtitles](opensubtitles) - over 400 million lines from movie and television subtitles (available in English and other languages)\n* [Amazon QA](amazon_qa) - over 3.6 million question-response pairs in the context of Amazon products\n\nMachine learning methods work best with large datasets such as these. At PolyAI we train models of conversational response on huge conversational datasets and then adapt these models to domain-specific tasks in conversational AI. This general approach of pre-training large models on huge datasets has long been popular in the image community and is now taking off in the NLP community.\n\nRather than providing the raw processed data, we provide scripts and instructions to generate the data yourself. This allows you to view and potentially manipulate the pre-processing and filtering. The instructions define standard datasets, with deterministic train\u002Ftest splits, which can be used to define reproducible evaluations in research papers.\n\n## Datasets\n\nEach dataset has its own directory, which contains a dataflow script, instructions for running it, and unit tests.\n\n|                                \t|                                     \t| Train set size \t| Test set size \t|\n|--------------------------------\t|-------------------------------------\t|----------------\t|---------------\t|\n| [Reddit](reddit)               \t| 2015 - 2019                         \t| 654 million    \t| 72 million    \t|\n| [OpenSubtitles](opensubtitles) \t| English (other languages available) \t| 286 million    \t| 33 million    \t|\n| [Amazon QA](amazon_qa)         \t| -                                   \t| 3 million      \t| 0.3 million   \t|\n\nNote that these are the dataset sizes after filtering and other processing. For instance, the Reddit dataset is based on a raw database of 3.7 billion comments, but consists of 726 million examples because the script filters out long comments, short comments, uninformative comments (such as `'[deleted]'`, and comments with no replies.\n\n\n## Benchmarks\n\nBenchmark results for each of the datasets can be found in [`BENCHMARKS.md`](BENCHMARKS.md).\n\n## Conversational Dataset Format\n\nThis repo contains scripts for creating datasets in a standard format -\nany dataset in this format is referred to elsewhere as simply a\n*conversational dataset*.\n\n\nDatasets are stored either as:\n\n* JSON text files, with one example per line\n* or as [Tensorflow record files](`https:\u002F\u002Fwww.tensorflow.org\u002Ftutorials\u002Fload_data\u002Ftf_records`) containing serialized [tensorflow example](https:\u002F\u002Fwww.tensorflow.org\u002Ftutorials\u002Fload_data\u002Ftf_records#data_types_for_tfexample) protocol buffers.\n\n\nThe training set is stored as one collection of examples, and\nthe test set as another. Examples are shuffled randomly (and not necessarily reproducibly) among the files. The train\u002Ftest split is always deterministic, so that whenever the dataset is generated, the same train\u002Ftest split is created.\n\nEach example contains a conversational context and a response that goes with that context. For example:\n\n```javascript\n{\n  'context\u002F1': \"Hello, how are you?\",\n  'context\u002F0': \"I am fine. And you?\",\n  'context': \"Great. What do you think of the weather?\",\n  'response': \"It doesn't feel like February.\"\n}\n```\n\nExplicitly, each example contains a number of string features:\n\n* A `context` feature, the most recent text in the conversational context\n* A `response` feature, the text that is in direct response to the `context`.\n* A number of *extra context features*, `context\u002F0`, `context\u002F1` etc. going\n  back in time through the conversation. They are named in reverse order so that `context\u002Fi` always refers to the `i^th` most recent extra context, so that no padding needs to be done, and datasets with different numbers of extra contexts can be mixed.\n\nDepending on the dataset, there may be some extra features also included in\neach example. For instance, in Reddit the author of the context and response are\nidentified using additional features.\n\n### Reading conversational datasets\n\n#### JSON format\n\nFor use outside of tensorflow, the JSON format may be preferable. To get JSON format datasets, use `--dataset_format JSON` in the dataset's `create_data.py` script. Each line will contain a single JSON object.\n\nBelow is some example python code for reading a JSON format dataset.\n\n```python\nimport json\nfrom glob import glob\n\n\nfor file_name in glob(\"dataset\u002Ftrain\u002F*.json\"):\n    for line in open(file_name):\n        example = json.loads(line)\n        # You can now access:\n        #   example['context']\n        #   example['response']\n        #   example['context\u002F0'] etc.\n```\n\n#### Tensorflow format\n\nThe [`tools\u002Ftfrutil.py`](tools\u002Ftfrutil.py) and [`baselines\u002Frun_baseline.py`](baselines\u002Frun_baseline.py) scripts demonstrate how to read a Tensorflow example format conversational dataset in Python, using functions from the tensorflow library.\n\nYou can use [`tools\u002Ftfrutil.py`](tools\u002Ftfrutil.py) to compute the number of examples in a tensorflow record file:\n\n```\n$ python tools\u002Ftfrutil.py size data\u002Freddit-test\n726158\n```\n\nIt can also be used to display the examples in a readable format:\n\n```\n$ python tools\u002Ftfrutil.py pp data\u002Freddit-test\n\nExample 0\n--------\n[Context]:\n\tAirplane? What is it?\n[Response]:\n\tAirplane! The movie. It's an amazing parody of plane movies which sounds terrible but it is actually 10\u002F10.\n\nExtra Contexts:\n\t[context\u002F2]:\n\t\tUnfortunately, they all had the fish for dinner.\n\t[context\u002F1]:\n\t\tThis is some sort of reference? I don't get it.\n\t[context\u002F0]:\n\t\tAirplane. Drop everything and watch it right now\n\nOther features:\n\t[context_author]:\n\t\tDoctor_Insano_MD\n\t[response_author]:\n\t\tThegreatandpowerfulR\n\t[subreddit]:\n\t\ttodayilearned\n\t[thread_id]:\n\t\t41ar0l\n--------\n...\n```\n\nBelow is some example tensorflow code for reading a conversational dataset\ninto a tensorflow graph:\n\n```python\n\nnum_extra_contexts = 10\nbatch_size = 100\npattern = \"gs:\u002F\u002Fyour-bucket\u002Fdataset\u002Ftrain-*.tfrecord\"\n\nif not tf.gfile.Glob(pattern):\n    raise ValueError(\"No files matched pattern \" + pattern)\n\ndataset = tf.data.Dataset.list_files(pattern)\ndataset = dataset.apply(\n    tf.contrib.data.parallel_interleave(\n        lambda file: tf.data.TFRecordDataset(file),\n        cycle_length=8))\ndataset = dataset.apply(\n    tf.data.experimental.shuffle_and_repeat(\n        buffer_size=8 * batch_size))\ndataset = dataset.batch(batch_size)\n\ndef _parse_function(serialized_examples):\n    parse_spec = {\n        \"context\": tf.FixedLenFeature([], tf.string),\n        \"response\": tf.FixedLenFeature([], tf.string)\n    }\n    parse_spec.update({\n        \"context\u002F{}\".format(i): tf.FixedLenFeature(\n            [], tf.string, default_value=\"\")\n        for i in range(num_extra_contexts)\n    })\n    return tf.parse_example(serialized_examples, parse_spec)\n\ndataset = dataset.map(_parse_function, num_parallel_calls=8)\ndataset = dataset.prefetch(8)\niterator = dataset.make_one_shot_iterator()\ntensor_dict = iterator.get_next()\n\n# The tensorflow graph can now access\n# tensor_dict[\"context\"], tensor_dict[\"response\"] etc.\n# as batches of string features (unicode bytes).\n```\n\n## Getting Started\n\nConversational datasets are created using [Apache Beam pipeline](https:\u002F\u002Fbeam.apache.org\u002F) scripts, run on [Google Dataflow](https:\u002F\u002Fcloud.google.com\u002Fdataflow\u002F). This parallelises the data processing pipeline across many worker machines. Apache Beam requires python 2.7, so you will need to set up a python 2.7 virtual environment:\n\n```bash\npython2.7 -m virtualenv venv\n. venv\u002Fbin\u002Factivate\npip install -r requirements.txt\n```\n\nThe Dataflow scripts write conversational datasets to Google cloud storage, so you will need to [create a bucket](https:\u002F\u002Fcloud.google.com\u002Fstorage\u002Fdocs\u002Fcreating-buckets) to save the dataset to.\n\nDataflow will run workers on multiple Compute Engine instances, so make sure you have a sufficient [quota](https:\u002F\u002Fcloud.google.com\u002Fdataflow\u002Fquotas) of `n1-standard-1` machines. The READMEs for individual datasets give an idea of how many workers are required, and how long each dataflow job should take.\n\nLastly, you will need to [set up authentication](https:\u002F\u002Fcloud.google.com\u002Fdocs\u002Fauthentication\u002Fgetting-started) by creating a service account with access to Dataflow and Cloud Storage, and set `GOOGLE_APPLICATION_CREDENTIALS`:\n\n```bash\nexport GOOGLE_APPLICATION_CREDENTIALS={{json file key location}}\n```\n\nThis should be enough to follow the instructions for creating each individual dataset.\n\n\n## Evaluation\n\nOf course you may evaluate your models in any way you like.\nHowever, when publishing results, we encourage you to include the\n1-of-100 ranking accuracy, which is becoming a research community standard.\n\nThe 1-of-100 ranking accuracy is a *Recall@k* metric. In general *Recall@k*\ntakes *N* responses to the given conversational context, where only one response is relevant. It indicates whether the relevant response occurs in the top *k* ranked candidate responses.\nThe 1-of-100 metric is obtained when *k=1* and *N=100*.\nThis effectively means that, for each query, we indicate if the correct response is the top ranked response among 100 candidates. The final score is the average across all queries.\n\nThe 1-of-100 metric is computed using random batches of 100 examples so that the responses from other examples in the batch are used as random negative candidates. This allows for efficiently computing the metric across many examples in batches. While it is not guaranteed that the random negatives will indeed be 'true' negatives, the 1-of-100 metric still provides a useful evaluation signal that correlates with downstream tasks.\n\nThe following tensorflow code shows how this metric can be computed for a dot-product style encoder model, where the score for each context and response is a dot product between corresponding vectors:\n\n```python\n# Encode the contexts and responses as vectors using tensorflow ops.\n# The following are both [100, encoding_size] matrices.\ncontext_encodings = _encode_contexts(tensor_dict['context'])\nresponse_encodings = _encode_responses(tensor_dict['response'])\n\nscores = tf.matmul(\n  context_encodings, response_encodings,\n  transpose_b=True)  # A [100, 100] matrix.\n\nbatch_size = tf.shape(context_encodings)[0]\n\naccuracy_1_of_100 = tf.metrics.accuracy(\n  labels=tf.range(batch_size),\n  predictions=tf.argmax(scores, 1)\n)\n```\n\nSee also the [baselines](baselines) for example code computing the 1-of-100 metric.\n\nMany studies have used *Recall@k* in the context of retrieval-based dialogue, including the following papers:\n\n* [*The Ubuntu Dialogue Corpus: A Large Dataset for Research in Unstructured Multi-Turn Dialogue Systems*](https:\u002F\u002Faclweb.org\u002Fanthology\u002FW15-4640), Lowe et al. SIGDIAL 2015.\n\n* [*Neural Utterance Ranking Model for Conversational Dialogue Systems*](https:\u002F\u002Fwww.aclweb.org\u002Fanthology\u002FW16-3648), Inaba and Takahashi. SIGDIAL 2016.\n\n* [*Strategy and Policy Learning for Non-task-oriented Conversational Systems*](https:\u002F\u002Faclweb.org\u002Fanthology\u002FW16-3649), Yu et al. SIGDIAL 2016.\n\n* [*Training End-to-End Dialogue Systems with the Ubuntu Dialogue Corpus*](http:\u002F\u002Fdad.uni-bielefeld.de\u002Findex.php\u002Fdad\u002Farticle\u002Fview\u002F3698), Lowe et al. Dialogue and Discourse 2017.\n\n* [*Sequential Matching Network: A New Architecture for Multi-turn Response Selection in Retrieval-based Chatbots*](https:\u002F\u002Faclweb.org\u002Fanthology\u002FP17-1046), Wu et al. ACL 2017.\n\n* [*Improving Response Selection in Multi-turn Dialogue Systems by Incorporating Domain Knowledge*](http:\u002F\u002Faclweb.org\u002Fanthology\u002FK18-1048),\nChaudhuri et al. CoNLL 2018.\n\n* [*Data Augmentation for Neural Online Chats Response Selection*](https:\u002F\u002Faclweb.org\u002Fanthology\u002FW18-5708), Du and Black. SCAI 2018.\n\n* [*Customized Nonlinear Bandits for Online Response Selection in Neural Conversational Models*](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1711.08493.pdf), Liu et al. AAAI 2018.\n\n* [*DSTC7 task 1: Noetic end-to-end response selection*](https:\u002F\u002Faclweb.org\u002Fanthology\u002FW18-5708), Gunasekara et al. 2019.\n\n* [*Multi-representation Fusion Network for Multi-Turn Response Selection in Retrieval-based Chatbots*](https:\u002F\u002Fdl.acm.org\u002Fcitation.cfm?doid=3289600.3290985), Tao et al. WSDM 2019.\n\n* [*Multi-Turn Response Selection for Chatbots with Deep Attention Matching Network*](http:\u002F\u002Faclweb.org\u002Fanthology\u002FP18-1103), Zhou et al. ACL 2018.\n\nThe following papers use the 1-of-100 ranking accuracy in particular:\n\n* [*Conversational Contextual Cues: The Case of Personalization  and History  for  Response  Ranking.*](http:\u002F\u002Farxiv.org\u002Fabs\u002F1606.00372), Al-Rfou et al. arXiv pre-print 2016.\n\n* [*Efficient Natural Language Response Suggestion for Smart Reply*](http:\u002F\u002Farxiv.org\u002Fabs\u002F1705.00652), Henderson et al. arXiv pre-print 2017.\n\n* [*Question-Answer Selection in User to User Marketplace Conversations*](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1802.01766.pdf), Kumar et al. IWSDS 2018.\n\n* [*Universal Sentence Encoder*](https:\u002F\u002Farxiv.org\u002Fabs\u002F1803.11175), Cer et al. arXiv pre-print 2018.\n\n* [*Learning  Semantic  Textual  Similarity  from  Conversations.*](http:\u002F\u002Faclweb.org\u002Fanthology\u002FW18-3022). Yang et al. Workshop on Representation Learning for NLP 2018.\n\n\n\n## Citations\n\nWhen using these datasets in your work, please cite our paper, [A Repository of Conversational Datasets](https:\u002F\u002Farxiv.org\u002Fabs\u002F1904.06472):\n\n```bibtex\n@inproceedings{Henderson2019,\n    author      = {Matthew Henderson and Pawe{\\l} Budzianowski and I{\\~{n}}igo Casanueva and Sam Coope and Daniela Gerz and Girish Kumar and Nikola Mrk{\\v{s}}i\\'c and Georgios Spithourakis and Pei-Hao Su and Ivan Vulic and Tsung-Hsien Wen},\n    title       = {A Repository of Conversational Datasets},\n    year        = {2019},\n    month       = {jul},\n    note        = {Data available at github.com\u002FPolyAI-LDN\u002Fconversational-datasets},\n    url         = {https:\u002F\u002Farxiv.org\u002Fabs\u002F1904.06472},\n    booktitle   = {Proceedings of the Workshop on {NLP} for Conversational {AI}},\n}\n\n```\n\n## Contributing\n\nWe happily accept contributions in the form of pull requests.\nEach pull request is tested in CircleCI - it is first linted with `flake8`, and then the unit tests are run. In particular we would be interested in:\n\n* new datasets\n* adaptations to the scripts so that they work better in your environment (e.g. other Apache Beam runners, other cloud storage solutions, other example formats)\n* results from your methods in the benchmarks [the benchmarks page](BENCHMARKS.md).\n* code for new baselines and improvements to existing baselines\n","[![CircleCI](https:\u002F\u002Fcircleci.com\u002Fgh\u002FPolyAI-LDN\u002Fconversational-datasets.svg?style=svg&circle-token=25d37b8026cb0c81306db68d098703f81dd74da9)](https:\u002F\u002Fcircleci.com\u002Fgh\u002FPolyAI-LDN\u002Fconversational-datasets)\n\n[![PolyAI](https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FPolyAI-LDN_conversational-datasets_readme_f4095d03c28b.png)](https:\u002F\u002Fpoly-ai.com\u002F)\n\n# 对话语料库\n\n*用于对话响应选择的大型语料库集合。*\n\n本仓库提供了创建可复现对话响应模型训练与评估数据集的工具，其中包括：\n\n* [Reddit](reddit) - 37亿条评论，以线程式对话结构组织\n* [OpenSubtitles](opensubtitles) - 超过4亿行电影和电视字幕文本（提供英语及其他语言版本）\n* [Amazon QA](amazon_qa) - 超过360万条亚马逊商品相关的问答对\n\n机器学习方法在处理此类大规模数据集时效果最佳。在 PolyAI，我们首先在海量对话数据上预训练对话响应模型，随后将这些模型适配到对话式 AI 的特定领域任务中。这种先在大规模数据上预训练、再进行领域适配的方法，在图像处理领域早已流行，如今也在自然语言处理社区迅速兴起。\n\n我们并未直接提供原始处理后的数据，而是给出了用于自行生成数据的脚本和说明。这样您可以查看并可能调整预处理和过滤步骤。这些说明定义了标准的数据集，并采用确定性的训练\u002F测试集划分方式，可用于在研究论文中进行可复现的评估。\n\n## 数据集\n\n每个数据集都有自己的目录，其中包含数据流脚本、运行说明以及单元测试。\n\n|                                \t|                                     \t| 训练集规模 \t| 测试集规模 \t|\n|--------------------------------\t|-------------------------------------\t|----------------\t|---------------\t|\n| [Reddit](reddit)               \t| 2015 - 2019                         \t| 6.54亿       \t| 7,200万      \t|\n| [OpenSubtitles](opensubtitles) \t| 英语（另有其他语言版本）            \t| 2.86亿       \t| 3,300万      \t|\n| [Amazon QA](amazon_qa)         \t| -                                   \t| 300万        \t| 30万         \t|\n\n请注意，这些是经过过滤和其他处理后的数据集规模。例如，Reddit 数据集基于原始的37亿条评论数据库，但最终仅包含7.26亿个样本，因为脚本会过滤掉过长或过短的评论、无意义的评论（如“[已删除]”）以及没有回复的评论。\n\n\n## 基准测试\n\n各数据集的基准测试结果可在 [`BENCHMARKS.md`](BENCHMARKS.md) 中找到。\n\n## 对话语料库格式\n\n本仓库包含用于创建标准格式数据集的脚本——任何符合此格式的数据集在其他地方都简称为 *对话数据集*。\n\n\n数据集可以存储为：\n\n* 每行一个样本的 JSON 文本文件\n* 或者作为 [TensorFlow 记录文件](`https:\u002F\u002Fwww.tensorflow.org\u002Ftutorials\u002Fload_data\u002Ftf_records`)，其中包含序列化的 [tensorflow example](https:\u002F\u002Fwww.tensorflow.org\u002Ftutorials\u002Fload_data\u002Ftf_records#data_types_for_tfexample) 协议缓冲区。\n\n\n训练集和测试集分别存储为独立的集合。样本会在各个文件之间随机打乱顺序（不一定可复现）。然而，训练\u002F测试集的划分始终是确定性的，因此无论何时生成数据集，都会得到相同的划分。\n\n每个样本包含一段对话上下文及其对应的回复。例如：\n\n```javascript\n{\n  'context\u002F1': \"你好，最近怎么样？\",\n  'context\u002F0': \"我很好。你呢？\",\n  'context': \"太好了。你觉得今天的天气如何？\",\n  'response': \"感觉不像是二月份的天气。\"\n}\n```\n\n具体而言，每个样本包含若干字符串特征：\n\n* `context` 特征：对话上下文中最新的文本\n* `response` 特征：直接回应 `context` 的文本\n* 若干 *额外上下文特征*，如 `context\u002F0`、`context\u002F1` 等，按时间倒序排列。这样命名是为了让 `context\u002Fi` 总是指第 `i` 个最近的额外上下文，从而无需填充，也便于混合不同长度上下文的数据集。\n\n根据数据集的不同，每个样本还可能包含一些额外的特征。例如，在 Reddit 数据集中，上下文和回复的作者信息会通过附加特征来标识。\n\n### 阅读对话数据集\n\n#### JSON 格式\n\n在 TensorFlow 之外使用时，JSON 格式可能更为方便。要获取 JSON 格式的数据集，可以在数据集的 `create_data.py` 脚本中使用 `--dataset_format JSON` 参数。每行将包含一个单独的 JSON 对象。\n\n以下是读取 JSON 格式数据集的一些示例 Python 代码。\n\n```python\nimport json\nfrom glob import glob\n\n\nfor file_name in glob(\"dataset\u002Ftrain\u002F*.json\"):\n    for line in open(file_name):\n        example = json.loads(line)\n        # 现在可以访问：\n        #   example['context']\n        #   example['response']\n        #   example['context\u002F0'] 等。\n```\n\n#### TensorFlow 格式\n\n[`tools\u002Ftfrutil.py`](tools\u002Ftfrutil.py) 和 [`baselines\u002Frun_baseline.py`](baselines\u002Frun_baseline.py) 脚本展示了如何使用 TensorFlow 库中的函数，在 Python 中读取 TensorFlow 示例格式的对话数据集。\n\n您可以使用 [`tools\u002Ftfrutil.py`](tools\u002Ftfrutil.py) 来计算 TensorFlow 记录文件中的样本数量：\n\n```\n$ python tools\u002Ftfrutil.py size data\u002Freddit-test\n726158\n```\n\n它也可以用来以可读格式显示这些样本：\n\n```\n$ python tools\u002Ftfrutil.py pp data\u002Freddit-test\n\nExample 0\n--------\n[Context]:\n\t飞机？那是什么？\n[Response]:\n\t《空前绝后》！这部电影是对飞行题材电影的精彩恶搞，听起来很糟糕，但实际上满分10分！\n\nExtra Contexts:\n\t[context\u002F2]:\n\t\t不幸的是，他们晚餐都吃了鱼。\n\t[context\u002F1]:\n\t\t这是某种梗吗？我不明白。\n\t[context\u002F0]:\n\t\t《空前绝后》。放下手头的一切，现在就看吧！\n\nOther features:\n\t[context_author]:\n\t\tDoctor_Insano_MD\n\t[response_author]:\n\t\tThegreatandpowerfulR\n\t[subreddit]:\n\t\ttodayilearned\n\t[thread_id]:\n\t\t41ar0l\n--------\n...\n```\n\n以下是将对话数据集读入 TensorFlow 图形的一些示例 TensorFlow 代码：\n\n```python\n\nnum_extra_contexts = 10\nbatch_size = 100\npattern = \"gs:\u002F\u002Fyour-bucket\u002Fdataset\u002Ftrain-*.tfrecord\"\n\nif not tf.gfile.Glob(pattern):\n    raise ValueError(\"No files matched pattern \" + pattern)\n\ndataset = tf.data.Dataset.list_files(pattern)\ndataset = dataset.apply(\n    tf.contrib.data.parallel_interleave(\n        lambda file: tf.data.TFRecordDataset(file),\n        cycle_length=8))\ndataset = dataset.apply(\n    tf.data.experimental.shuffle_and_repeat(\n        buffer_size=8 * batch_size))\ndataset = dataset.batch(batch_size)\n\ndef _parse_function(serialized_examples):\n    parse_spec = {\n        \"context\": tf.FixedLenFeature([], tf.string),\n        \"response\": tf.FixedLenFeature([], tf.string)\n    }\n    parse_spec.update({\n        \"context\u002F{}\".format(i): tf.FixedLenFeature(\n            [], tf.string, default_value=\"\")\n        for i in range(num_extra_contexts)\n    })\n    return tf.parse_example(serialized_examples, parse_spec)\n\ndataset = dataset.map(_parse_function, num_parallel_calls=8)\ndataset = dataset.prefetch(8)\niterator = dataset.make_one_shot_iterator()\ntensor_dict = iterator.get_next()\n\n# 现在 TensorFlow 图形可以访问\n# tensor_dict[\"context\"]、tensor_dict[\"response\"] 等，\n# 它们是以字符串特征（Unicode 字节）形式呈现的批次数据。\n```\n\n## 入门指南\n\n对话数据集是通过 [Apache Beam 流水线](https:\u002F\u002Fbeam.apache.org\u002F) 脚本创建的，并在 [Google Dataflow](https:\u002F\u002Fcloud.google.com\u002Fdataflow\u002F) 上运行。这会将数据处理流水线并行化到许多工作机器上。Apache Beam 需要 Python 2.7，因此您需要设置一个 Python 2.7 的虚拟环境：\n\n```bash\npython2.7 -m virtualenv venv\n. venv\u002Fbin\u002Factivate\npip install -r requirements.txt\n```\n\nDataflow 脚本会将对话数据集写入 Google 云存储，因此您需要先 [创建一个存储桶](https:\u002F\u002Fcloud.google.com\u002Fstorage\u002Fdocs\u002Fcreating-buckets) 来保存数据集。\n\nDataflow 会在多个 Compute Engine 实例上运行工作节点，所以请确保您有足够的 `n1-standard-1` 机器配额（[配额信息](https:\u002F\u002Fcloud.google.com\u002Fdataflow\u002Fquotas)）。各个数据集的 README 文件会说明需要多少个工作节点，以及每个 Dataflow 作业大概需要多长时间。\n\n最后，您还需要通过创建具有 Dataflow 和 Cloud Storage 访问权限的服务账号来 [设置身份验证](https:\u002F\u002Fcloud.google.com\u002Fdocs\u002Fauthentication\u002Fgetting-started)，并设置 `GOOGLE_APPLICATION_CREDENTIALS`：\n\n```bash\nexport GOOGLE_APPLICATION_CREDENTIALS={{json 文件密钥位置}}\n```\n\n这样应该足以按照每个数据集的创建说明进行操作。\n\n\n## 评估\n\n当然，您可以以任何您喜欢的方式评估您的模型。不过，在发表结果时，我们鼓励您同时报告“1\u002F100 排名准确率”，这一指标正逐渐成为研究界的通用标准。\n\n“1\u002F100 排名准确率”是一种 *Recall@k* 指标。一般来说，*Recall@k* 是指针对给定的对话上下文，提供 *N* 个回复，其中只有一个回复是相关的。该指标用于判断相关回复是否出现在前 *k* 名候选回复中。当 *k=1* 且 *N=100* 时，就得到了“1\u002F100”指标。也就是说，对于每一个查询，我们会判断正确的回复是否位于 100 个候选回复中的第一名。最终得分则是所有查询的平均值。\n\n“1\u002F100”指标是通过随机抽取 100 个样本批次来计算的，批次中的其他回复则被用作随机的负样本。这种方法能够高效地对大量样本进行分批计算。尽管无法保证这些随机负样本一定是真正的“负样本”，但“1\u002F100”指标仍然提供了一个有用的评估信号，与下游任务有较好的相关性。\n\n以下 TensorFlow 代码展示了如何为一种点积风格的编码器模型计算该指标，其中每个上下文和回复的得分都是对应向量之间的点积：\n\n```python\n# 使用 TensorFlow 操作将上下文和回复编码为向量。\n\n# 下面两者都是 [100, encoding_size] 的矩阵。\ncontext_encodings = _encode_contexts(tensor_dict['context'])\nresponse_encodings = _encode_responses(tensor_dict['response'])\n\nscores = tf.matmul(\n  context_encodings, response_encodings,\n  transpose_b=True)  # 一个 [100, 100] 的矩阵。\n\nbatch_size = tf.shape(context_encodings)[0]\n\naccuracy_1_of_100 = tf.metrics.accuracy(\n  labels=tf.range(batch_size),\n  predictions=tf.argmax(scores, 1)\n)\n```\n\n另请参阅 [baselines](baselines)，其中包含计算 1-of-100 指标的示例代码。\n\n许多研究已在基于检索的对话系统中使用了 *Recall@k*，其中包括以下论文：\n\n* [*Ubuntu 对话语料库：用于非结构化多轮对话系统研究的大规模数据集*](https:\u002F\u002Faclweb.org\u002Fanthology\u002FW15-4640)，Lowe 等人，SIGDIAL 2015。\n\n* [*面向会话式对话系统的神经话语排序模型*](https:\u002F\u002Fwww.aclweb.org\u002Fanthology\u002FW16-3648)，Inaba 和 Takahashi，SIGDIAL 2016。\n\n* [*非任务导向型会话系统的策略与政策学习*](https:\u002F\u002Faclweb.org\u002Fanthology\u002FW16-3649)，Yu 等人，SIGDIAL 2016。\n\n* [*利用 Ubuntu 对话语料库训练端到端对话系统*](http:\u002F\u002Fdad.uni-bielefeld.de\u002Findex.php\u002Fdad\u002Farticle\u002Fview\u002F3698)，Lowe 等人，Dialogue and Discourse 2017。\n\n* [*序列匹配网络：基于检索的聊天机器人中多轮响应选择的新架构*](https:\u002F\u002Faclweb.org\u002Fanthology\u002FP17-1046)，Wu 等人，ACL 2017。\n\n* [*通过融入领域知识改进多轮对话系统中的响应选择*](http:\u002F\u002Faclweb.org\u002Fanthology\u002FK18-1048)，Chaudhuri 等人，CoNLL 2018。\n\n* [*针对神经在线聊天响应选择的数据增强*](https:\u002F\u002Faclweb.org\u002Fanthology\u002FW18-5708)，Du 和 Black，SCAI 2018。\n\n* [*用于神经会话模型在线响应选择的定制非线性赌盘算法*](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1711.08493.pdf)，Liu 等人，AAAI 2018。\n\n* [*DSTC7 任务 1：基于直觉的端到端响应选择*](https:\u002F\u002Faclweb.org\u002Fanthology\u002FW18-5708)，Gunasekara 等人，2019 年。\n\n* [*基于检索的聊天机器人中多轮响应选择的多表示融合网络*](https:\u002F\u002Fdl.acm.org\u002Fcitation.cfm?doid=3289600.3290985)，Tao 等人，WSDM 2019。\n\n* [*具有深度注意力匹配网络的聊天机器人多轮响应选择*](http:\u002F\u002Faclweb.org\u002Fanthology\u002FP18-1103)，Zhou 等人，ACL 2018。\n\n以下论文特别使用了 1-of-100 排名准确率：\n\n* [*会话上下文线索：个性化和历史记录在响应排名中的作用*](http:\u002F\u002Farxiv.org\u002Fabs\u002F1606.00372)，Al-Rfou 等人，arXiv 预印本 2016 年。\n\n* [*智能回复中高效的自然语言回复建议*](http:\u002F\u002Farxiv.org\u002Fabs\u002F1705.00652)，Henderson 等人，arXiv 预印本 2017 年。\n\n* [*用户对用户交易平台对话中的问答选择*](https:\u002F\u002Farxiv.org\u002Fpdf\u002F1802.01766.pdf)，Kumar 等人，IWSDS 2018。\n\n* [*通用句子编码器*](https:\u002F\u002Farxiv.org\u002Fabs\u002F1803.11175)，Cer 等人，arXiv 预印本 2018 年。\n\n* [*从会话中学习语义文本相似度*](http:\u002F\u002Faclweb.org\u002Fanthology\u002FW18-3022)，Yang 等人，2018 年 NLP 表征学习研讨会。\n\n\n\n## 引用\n\n在您的工作中使用这些数据集时，请引用我们的论文《会话数据集仓库》（A Repository of Conversational Datasets）：\n\n```bibtex\n@inproceedings{Henderson2019,\n    author      = {Matthew Henderson and Pawe{\\l} Budzianowski and I{\\~{n}}igo Casanueva and Sam Coope and Daniela Gerz and Girish Kumar and Nikola Mrk{\\v{s}}i\\'c and Georgios Spithourakis and Pei-Hao Su and Ivan Vulic and Tsung-Hsien Wen},\n    title       = {A Repository of Conversational Datasets},\n    year        = {2019},\n    month       = {jul},\n    note        = {数据可在 github.com\u002FPolyAI-LDN\u002Fconversational-datasets 上获取},\n    url         = {https:\u002F\u002Farxiv.org\u002Fabs\u002F1904.06472},\n    booktitle   = {会话式 AI 的 NLP 工作坊论文集},\n}\n\n```\n\n## 贡献\n\n我们非常欢迎以拉取请求形式的贡献。\n每个拉取请求都会在 CircleCI 中进行测试——首先使用 `flake8` 进行代码风格检查，然后运行单元测试。我们尤其感兴趣的是：\n\n* 新的数据集\n* 对脚本的调整，使其在您的环境中更好地运行（例如其他 Apache Beam 运行器、其他云存储解决方案、其他示例格式）\n* 您的方法在基准测试中的结果 [基准测试页面](BENCHMARKS.md)。\n* 新基线的代码以及现有基线的改进","# conversational-datasets 快速上手指南\n\n`conversational-datasets` 是一个用于构建大规模对话响应选择数据集的工具库，包含 Reddit、OpenSubtitles 和 Amazon QA 等知名数据集的生成脚本。本项目不直接提供处理后的数据文件，而是提供基于 Apache Beam 的流水线脚本，让用户在 Google Cloud Dataflow 上自行生成可复现的标准格式数据集。\n\n## 环境准备\n\n在开始之前，请确保满足以下系统要求和前置依赖：\n\n*   **操作系统**: Linux 或 macOS (推荐)\n*   **Python 版本**: **必须使用 Python 2.7** (Apache Beam 旧版本要求)\n*   **云平台**: Google Cloud Platform (GCP) 账号\n    *   已启用 **Dataflow API** 和 **Cloud Storage API**\n    *   拥有足够的 `n1-standard-1` 机器配额（用于运行并行处理任务）\n*   **命令行工具**:\n    *   `virtualenv`\n    *   `gcloud` CLI (可选，用于管理 GCP 资源)\n\n## 安装步骤\n\n### 1. 创建 Python 2.7 虚拟环境\n由于核心脚本依赖 Python 2.7，请先创建并激活独立的虚拟环境：\n\n```bash\npython2.7 -m virtualenv venv\nsource venv\u002Fbin\u002Factivate\n```\n\n### 2. 安装依赖包\n安装项目所需的 Python 库：\n\n```bash\npip install -r requirements.txt\n```\n\n### 3. 配置 Google Cloud 认证\n脚本需要将生成的数据集写入 Google Cloud Storage (GCS)，因此需要配置服务账号认证：\n\n1.  在 GCP 控制台创建一个具有 **Dataflow** 和 **Storage Admin** 权限的服务账号。\n2.  下载该账号的 JSON 密钥文件。\n3.  设置环境变量指向该密钥文件：\n\n```bash\nexport GOOGLE_APPLICATION_CREDENTIALS=\u002Fpath\u002Fto\u002Fyour-service-account-key.json\n```\n\n### 4. 准备存储桶\n在 Google Cloud Storage 中创建一个存储桶（Bucket），用于存放生成的数据集文件：\n\n```bash\n# 示例：创建一个名为 my-conversational-data 的存储桶\ngsutil mb gs:\u002F\u002Fmy-conversational-data\n```\n\n## 基本使用\n\n本工具通过运行特定的 `create_data.py` 脚本来生成数据集。以下以生成 **Reddit** 数据集为例，展示最简使用流程。其他数据集（如 `opensubtitles`, `amazon_qa`）用法类似，请参考对应目录下的 README。\n\n### 1. 进入数据集目录\n```bash\ncd reddit\n```\n\n### 2. 运行数据生成脚本\n使用 Apache Beam 直接在 Google Dataflow 上运行管道。你需要指定项目 ID、临时存储位置以及输出路径。\n\n```bash\npython create_data.py \\\n  --project YOUR_GCP_PROJECT_ID \\\n  --runner DataflowRunner \\\n  --temp_location gs:\u002F\u002Fmy-conversational-data\u002Ftemp \\\n  --output gs:\u002F\u002Fmy-conversational-data\u002Freddit-output \\\n  --dataset_format JSON\n```\n\n*   `--project`: 你的 GCP 项目 ID。\n*   `--runner DataflowRunner`: 指示在云端分布式运行（本地测试可用 `DirectRunner`，但大数据集不建议）。\n*   `--temp_location`: GCS 路径，用于存放临时文件。\n*   `--output`: GCS 路径，生成后的数据集将保存于此。\n*   `--dataset_format JSON`: 指定输出格式为 JSON（每行一个 JSON 对象），便于非 TensorFlow 环境使用；也可选 `tfrecord`。\n\n### 3. 读取生成的数据\n\n#### 方式 A：读取 JSON 格式 (通用)\n如果选择了 `JSON` 格式，可以使用标准 Python 代码读取：\n\n```python\nimport json\nfrom glob import glob\n\n# 假设数据已下载到本地或挂载\nfor file_name in glob(\"dataset\u002Ftrain\u002F*.json\"):\n    for line in open(file_name):\n        example = json.loads(line)\n        # 访问上下文和响应\n        print(example['context'])\n        print(example['response'])\n        # 访问额外的历史上下文 (context\u002F0, context\u002F1...)\n        if 'context\u002F0' in example:\n            print(example['context\u002F0'])\n```\n\n#### 方式 B：读取 TensorFlow Record 格式\n如果选择了默认的 `tfrecord` 格式，可使用 TensorFlow 数据管道读取：\n\n```python\nimport tensorflow as tf\n\nnum_extra_contexts = 10\nbatch_size = 100\npattern = \"gs:\u002F\u002Fmy-conversational-data\u002Freddit-output\u002Ftrain-*.tfrecord\"\n\ndataset = tf.data.Dataset.list_files(pattern)\ndataset = dataset.apply(\n    tf.contrib.data.parallel_interleave(\n        lambda file: tf.data.TFRecordDataset(file),\n        cycle_length=8))\ndataset = dataset.apply(\n    tf.data.experimental.shuffle_and_repeat(\n        buffer_size=8 * batch_size))\ndataset = dataset.batch(batch_size)\n\ndef _parse_function(serialized_examples):\n    parse_spec = {\n        \"context\": tf.FixedLenFeature([], tf.string),\n        \"response\": tf.FixedLenFeature([], tf.string)\n    }\n    parse_spec.update({\n        \"context\u002F{}\".format(i): tf.FixedLenFeature(\n            [], tf.string, default_value=\"\")\n        for i in range(num_extra_contexts)\n    })\n    return tf.parse_example(serialized_examples, parse_spec)\n\ndataset = dataset.map(_parse_function, num_parallel_calls=8)\niterator = dataset.make_one_shot_iterator()\ntensor_dict = iterator.get_next()\n\n# tensor_dict[\"context\"] 和 tensor_dict[\"response\"] 现在可用于模型训练\n```\n\n### 4. 验证数据\n你可以使用提供的工具脚本检查生成的 TFRecord 文件大小或预览内容：\n\n```bash\n# 查看示例数量\npython tools\u002Ftfrutil.py size gs:\u002F\u002Fmy-conversational-data\u002Freddit-output\u002Ftest\n\n# 打印可读格式的样本\npython tools\u002Ftfrutil.py pp gs:\u002F\u002Fmy-conversational-data\u002Freddit-output\u002Ftest\n```","某初创团队正在开发一款面向电商领域的智能客服机器人，急需提升模型在复杂对话语境下的回复准确率。\n\n### 没有 conversational-datasets 时\n- **数据获取困难且分散**：工程师需手动爬取并清洗 Reddit、字幕组及亚马逊问答等多源数据，耗时数周仍难以凑齐高质量语料。\n- **实验结果不可复现**：由于缺乏统一的预处理标准和确定的训练\u002F测试集划分，团队成员间模型效果对比困难，论文基准难以对齐。\n- **领域适配成本高**：直接使用原始粗数据训练，模型充斥着无关噪音（如被删除的评论或过短回复），导致迁移到电商场景时微调效果不佳。\n- **格式转换繁琐**：不同来源的数据格式各异，每次训练前都需编写大量脚本转换为 TensorFlow Record 或 JSON 标准格式，极易出错。\n\n### 使用 conversational-datasets 后\n- **一键生成海量标准数据**：直接运行脚本即可自动生成包含数亿条对话的 Reddit、OpenSubtitles 或 Amazon QA 数据集，将数据准备周期从数周缩短至数小时。\n- **确保评估严谨可复现**：工具内置确定性的训练\u002F测试集划分逻辑，团队可基于统一基准快速迭代模型，轻松复现业界 SOTA 结果。\n- **预训练效果显著提升**：利用经过严格过滤（剔除无效、过短内容）的大规模通用对话数据进行预训练，模型再微调至电商场景时，意图理解能力大幅增强。\n- **无缝对接主流框架**：生成的数据天然符合标准的“上下文 - 回复”格式（JSON 或 TF Record），可直接投入 TensorFlow 等框架进行训练，免去格式清洗烦恼。\n\nconversational-datasets 通过提供可复现的大规模对话数据构建方案，让研发团队能从繁琐的数据工程中解放出来，专注于核心模型架构的创新与落地。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002FPolyAI-LDN_conversational-datasets_07aef7bf.png","PolyAI-LDN","PolyAI","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002FPolyAI-LDN_da46802e.png","",null,"contact@poly-ai.com","https:\u002F\u002Fpoly.ai","https:\u002F\u002Fgithub.com\u002FPolyAI-LDN",[81,85,89],{"name":82,"color":83,"percentage":84},"Python","#3572A5",83.9,{"name":86,"color":87,"percentage":88},"Jupyter Notebook","#DA5B0B",15.3,{"name":90,"color":91,"percentage":92},"Shell","#89e051",0.9,1392,178,"2026-04-07T02:53:15","Apache-2.0",5,"未说明 (基于 Google Cloud Dataflow，通常支持 Linux)","未说明","未说明 (取决于 Dataflow 作业规模，需足够的 n1-standard-1 机器配额)",{"notes":102,"python":103,"dependencies":104},"该工具主要作为数据生成脚本运行在 Google Cloud Dataflow (Apache Beam) 上，而非本地直接运行模型。需要配置 Google Cloud 账号、创建存储桶 (Bucket)、设置服务账号认证 (GOOGLE_APPLICATION_CREDENTIALS)，并确保有足够的 n1-standard-1 计算实例配额。数据处理是分布式的，具体资源需求取决于所选数据集的大小和处理参数。","2.7",[105,106,107,108],"apache-beam","tensorflow","google-cloud-dataflow","google-cloud-storage",[16,14],[111,112,113],"conversational-ai","datasets","machine-learning","2026-03-27T02:49:30.150509","2026-04-08T12:11:45.570321",[117,122,127,132,137,142],{"id":118,"question_zh":119,"answer_zh":120,"source_url":121},24179,"安装时遇到 TensorFlow 和 TensorBoard 版本不兼容的错误怎么办？","该错误通常是由于环境管理工具（如 conda）默认解析依赖项的方式与 virtualenv 不同导致的。建议尝试使用 virtualenv 而不是 conda 环境来安装依赖，或者手动检查并调整 requirements.txt 中的版本约束以匹配当前环境。","https:\u002F\u002Fgithub.com\u002FPolyAI-LDN\u002Fconversational-datasets\u002Fissues\u002F50",{"id":123,"question_zh":124,"answer_zh":125,"source_url":126},24180,"运行 Reddit 数据集处理脚本时出现 'Couldn't resolve host metadata' 的 GCP 认证失败错误如何解决？","这通常是因为 Dataflow 作业使用的 worker 数量超过了配额限制。请前往 Google Cloud Console 的 Dataflow 页面检查作业正在使用的 worker 数量。如果数量受限，您需要申请增加配额以便作业可以在更多机器上并行运行。","https:\u002F\u002Fgithub.com\u002FPolyAI-LDN\u002Fconversational-datasets\u002Fissues\u002F42",{"id":128,"question_zh":129,"answer_zh":130,"source_url":131},24181,"如何在 PyTorch 中解析该项目生成的 tf.Record 文件？","项目已支持直接生成 JSON 格式数据以避免解析 tf.Record 的麻烦。在运行 `create_data.py` 脚本时，添加 `--dataset_format JSON` 参数即可生成 JSON 文件，从而方便地在 PyTorch 或其他框架中使用。","https:\u002F\u002Fgithub.com\u002FPolyAI-LDN\u002Fconversational-datasets\u002Fissues\u002F48",{"id":133,"question_zh":134,"answer_zh":135,"source_url":136},24182,"为什么 Reddit 数据集中的部分评论（extra contexts）看起来被截断了？","这是预期行为。为了控制单个样本的大小，距离当前回复较远的上下文（extra contexts）会被修剪至最多 128 个字符（且不切断单词）。主要的 context 和 response 字段通常是完整的。如果需要完整文本，可以通过调整 `max_length` 标志来修改此限制，但请注意这会使得结果无法与官方基准测试进行直接比较。","https:\u002F\u002Fgithub.com\u002FPolyAI-LDN\u002Fconversational-datasets\u002Fissues\u002F45",{"id":138,"question_zh":139,"answer_zh":140,"source_url":141},24183,"运行脚本时遇到 'No module named deprecation_wrapper' 导入错误怎么办？","该错误可能与 TensorFlow 版本兼容性有关。有用户反馈将 TensorFlow 版本降级或指定为 `Tensorflow==1.5.0` 后解决了该问题并使代码正常运行。建议检查您的 TensorFlow 版本并尝试调整。","https:\u002F\u002Fgithub.com\u002FPolyAI-LDN\u002Fconversational-datasets\u002Fissues\u002F71",{"id":143,"question_zh":144,"answer_zh":145,"source_url":146},24184,"是否有教程指导如何在本地机器（而非 GCP 云服务）上处理原始数据？","虽然该仓库主要设计用于 GCP 服务（如 Dataflow），但用户可以通过修改运行参数来尝试在本地运行。具体方法是将运行器（runner）参数设置为 `DirectRunner` 或直接移除依赖云服务的参数（如 `--temp_location`, `--staging_location` 等），以便在本地环境中执行 `create_data.py` 脚本。","https:\u002F\u002Fgithub.com\u002FPolyAI-LDN\u002Fconversational-datasets\u002Fissues\u002F57",[]]