Publish verified ToolElite model/data asset
Browse files- .gitattributes +26 -0
- NOTICE.md +4 -0
- README.md +54 -0
- asset-summary.json +10 -0
- build_search_r1_corpus.py +484 -0
- demo_generate_30.py +110 -0
- publication-manifest.json +175 -0
- raw_data/1.json +3 -0
- raw_data/10.json +3 -0
- raw_data/11.json +3 -0
- raw_data/12.json +3 -0
- raw_data/13.json +3 -0
- raw_data/14.json +3 -0
- raw_data/15.json +3 -0
- raw_data/16.json +3 -0
- raw_data/17.json +3 -0
- raw_data/18.json +3 -0
- raw_data/19.json +3 -0
- raw_data/2.json +3 -0
- raw_data/20.json +3 -0
- raw_data/21.json +3 -0
- raw_data/22.json +3 -0
- raw_data/23.json +3 -0
- raw_data/24.json +3 -0
- raw_data/25.json +3 -0
- raw_data/3.json +3 -0
- raw_data/4.json +3 -0
- raw_data/5.json +3 -0
- raw_data/6.json +3 -0
- raw_data/7.json +3 -0
- raw_data/8.json +3 -0
- raw_data/9.json +3 -0
- search_r1_corpus.jsonl +3 -0
.gitattributes
CHANGED
|
@@ -58,3 +58,29 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 58 |
# Video files - compressed
|
| 59 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 60 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
# Video files - compressed
|
| 59 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 60 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
| 61 |
+
raw_data/1.json filter=lfs diff=lfs merge=lfs -text
|
| 62 |
+
raw_data/10.json filter=lfs diff=lfs merge=lfs -text
|
| 63 |
+
raw_data/11.json filter=lfs diff=lfs merge=lfs -text
|
| 64 |
+
raw_data/12.json filter=lfs diff=lfs merge=lfs -text
|
| 65 |
+
raw_data/13.json filter=lfs diff=lfs merge=lfs -text
|
| 66 |
+
raw_data/14.json filter=lfs diff=lfs merge=lfs -text
|
| 67 |
+
raw_data/15.json filter=lfs diff=lfs merge=lfs -text
|
| 68 |
+
raw_data/16.json filter=lfs diff=lfs merge=lfs -text
|
| 69 |
+
raw_data/17.json filter=lfs diff=lfs merge=lfs -text
|
| 70 |
+
raw_data/18.json filter=lfs diff=lfs merge=lfs -text
|
| 71 |
+
raw_data/19.json filter=lfs diff=lfs merge=lfs -text
|
| 72 |
+
raw_data/2.json filter=lfs diff=lfs merge=lfs -text
|
| 73 |
+
raw_data/20.json filter=lfs diff=lfs merge=lfs -text
|
| 74 |
+
raw_data/21.json filter=lfs diff=lfs merge=lfs -text
|
| 75 |
+
raw_data/22.json filter=lfs diff=lfs merge=lfs -text
|
| 76 |
+
raw_data/23.json filter=lfs diff=lfs merge=lfs -text
|
| 77 |
+
raw_data/24.json filter=lfs diff=lfs merge=lfs -text
|
| 78 |
+
raw_data/25.json filter=lfs diff=lfs merge=lfs -text
|
| 79 |
+
raw_data/3.json filter=lfs diff=lfs merge=lfs -text
|
| 80 |
+
raw_data/4.json filter=lfs diff=lfs merge=lfs -text
|
| 81 |
+
raw_data/5.json filter=lfs diff=lfs merge=lfs -text
|
| 82 |
+
raw_data/6.json filter=lfs diff=lfs merge=lfs -text
|
| 83 |
+
raw_data/7.json filter=lfs diff=lfs merge=lfs -text
|
| 84 |
+
raw_data/8.json filter=lfs diff=lfs merge=lfs -text
|
| 85 |
+
raw_data/9.json filter=lfs diff=lfs merge=lfs -text
|
| 86 |
+
search_r1_corpus.jsonl filter=lfs diff=lfs merge=lfs -text
|
NOTICE.md
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Wikipedia contributors. Article URLs and author histories: see link fields in raw_data/*.json.
|
| 2 |
+
Modified by ToolElite: markup removal and passage segmentation.
|
| 3 |
+
Text: CC BY-SA 4.0, https://creativecommons.org/licenses/by-sa/4.0/
|
| 4 |
+
Original scripts retained as supplied; no separate code license asserted.
|
README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-sa-4.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
tags:
|
| 6 |
+
- math
|
| 7 |
+
- retrieval
|
| 8 |
+
- search-r1
|
| 9 |
+
- toolelite
|
| 10 |
+
configs:
|
| 11 |
+
- config_name: corpus
|
| 12 |
+
default: true
|
| 13 |
+
data_files:
|
| 14 |
+
- split: train
|
| 15 |
+
path: search_r1_corpus.jsonl
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# 数学百科常识向量检索数据库 — ToolElite / wiki_math
|
| 19 |
+
|
| 20 |
+
本仓库用于服务 ToolElite 的 search 工具,为多轮数学推理提供外部知识检索。
|
| 21 |
+
内容为数学百科知识、概念、背景与相关常识。
|
| 22 |
+
|
| 23 |
+
发布内容是向量检索数据库的 **corpus、原始数据与构建脚本**;本地文件夹未包含 embedding、FAISS 索引或检索编码器权重,使用前需构建索引。
|
| 24 |
+
|
| 25 |
+
## Corpus 格式
|
| 26 |
+
|
| 27 |
+
`search_r1_corpus.jsonl` 共 **573,011** 个片段,字段为 `id` (string), `contents` (string)。
|
| 28 |
+
采用 Search-R1 本地数据库的 JSONL corpus 结构:每行一条记录,`id` 为按行递增的字符串,
|
| 29 |
+
`contents` 为 `"文章标题"\n正文片段`。
|
| 30 |
+
字段与 ToolElite 本地 corpus 加载器匹配;应保持 corpus 行顺序与向量索引对应。
|
| 31 |
+
[Search-R1](https://github.com/PeterGriffinJin/Search-R1) 为格式/流程参考,不是本语料的作者。
|
| 32 |
+
|
| 33 |
+
原始文件保存在 `raw_data/`,不与主 corpus 混作训练行;原始处理脚本按原样保存,可能含原机器绝对路径,运行前需指定本机输入/输出路径。
|
| 34 |
+
`asset-summary.json` 与 `publication-manifest.json` 提供结构摘要、大小和 SHA256 校验。
|
| 35 |
+
|
| 36 |
+
## 下载与接入
|
| 37 |
+
|
| 38 |
+
```bash
|
| 39 |
+
hf download BitZone910/wiki_math --repo-type dataset --local-dir data/wiki_math
|
| 40 |
+
|
| 41 |
+
# 在 ToolElite 项目环境中,将 corpus 编码为 FAISS 索引
|
| 42 |
+
python -m toolelite.retrieval.general.build_index \
|
| 43 |
+
--corpus_path data/wiki_math/search_r1_corpus.jsonl \
|
| 44 |
+
--save_dir data/wiki_math/index --faiss_type Flat \
|
| 45 |
+
--device cpu --no-faiss_gpu --batch_size 128
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
检索服务的 `general_corpus_path` 指向上述 corpus,`general_index_path` 指向生成的 `e5_Flat.index`,
|
| 49 |
+
并加载与建索引相同的 E5 编码器。两个仓库可以各自建索引;若合并 corpus,需重新编号并重新建索引。
|
| 50 |
+
|
| 51 |
+
## 来源、许可与处理
|
| 52 |
+
|
| 53 |
+
来自本地数学 Wikipedia 抓取快照;25 个原始 JSON 的 `link` 保留文章 URL,页面历史可用于作者归属。原始下载地址和抓取时间未记录。处理后文本遵循 Wikipedia 的 CC BY-SA 4.0 归属与相同方式共享要求;本文与原始链接一并保留归属。[Wikimedia 条款](https://foundation.wikimedia.org/wiki/Policy:Terms_of_Use)。
|
| 54 |
+
清洗、移除标记及按片段切分会改变原文本;详见仓库处理脚本。此数据库不保证所有陈述无误,检索结果需结合推理核实。
|
asset-summary.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"rows": 573011,
|
| 3 |
+
"fields": [
|
| 4 |
+
"contents",
|
| 5 |
+
"id"
|
| 6 |
+
],
|
| 7 |
+
"positional_ids": true,
|
| 8 |
+
"embeddings_included": false,
|
| 9 |
+
"faiss_index_included": false
|
| 10 |
+
}
|
build_search_r1_corpus.py
ADDED
|
@@ -0,0 +1,484 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Build a Search-R1-compatible passage corpus from the local Math Wikipedia dump.
|
| 2 |
+
|
| 3 |
+
This script intentionally uses only the Python standard library. It reads the
|
| 4 |
+
25 source JSON files in numeric order and writes one JSON object per passage.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
import html
|
| 10 |
+
import json
|
| 11 |
+
import os
|
| 12 |
+
import re
|
| 13 |
+
from collections import Counter
|
| 14 |
+
from html.parser import HTMLParser
|
| 15 |
+
from pathlib import Path
|
| 16 |
+
from typing import Any, Iterable, Optional
|
| 17 |
+
from urllib.parse import unquote, urlsplit
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
BASE_DIR = Path(r"C:\Users\lenovo\Desktop\wiki_math")
|
| 21 |
+
INPUT_DIR = BASE_DIR / "raw_data"
|
| 22 |
+
OUTPUT_PATH = BASE_DIR / "search_r1_corpus.jsonl"
|
| 23 |
+
TEMP_OUTPUT_PATH = BASE_DIR / "search_r1_corpus.jsonl.tmp"
|
| 24 |
+
INPUT_FILES = tuple(INPUT_DIR / f"{number}.json" for number in range(1, 26))
|
| 25 |
+
|
| 26 |
+
TARGET_PASSAGE_WORDS = 100
|
| 27 |
+
MIN_PASSAGE_WORDS = 50
|
| 28 |
+
PROGRESS_INTERVAL = 1_000
|
| 29 |
+
|
| 30 |
+
TITLE_NAMESPACE_PREFIXES = (
|
| 31 |
+
"file:",
|
| 32 |
+
"image:",
|
| 33 |
+
"category:",
|
| 34 |
+
"template:",
|
| 35 |
+
"wikipedia:",
|
| 36 |
+
"portal:",
|
| 37 |
+
"help:",
|
| 38 |
+
"mediawiki:",
|
| 39 |
+
"user:",
|
| 40 |
+
"talk:",
|
| 41 |
+
"draft:",
|
| 42 |
+
)
|
| 43 |
+
PROTECTION_KEYWORDS = (
|
| 44 |
+
"semi-protected",
|
| 45 |
+
"protected",
|
| 46 |
+
"extended confirmed protected",
|
| 47 |
+
)
|
| 48 |
+
REMOVED_WIKILINK_NAMESPACES = ("file:", "image:", "category:")
|
| 49 |
+
|
| 50 |
+
BLOCK_TAGS = {
|
| 51 |
+
"address",
|
| 52 |
+
"article",
|
| 53 |
+
"aside",
|
| 54 |
+
"blockquote",
|
| 55 |
+
"br",
|
| 56 |
+
"caption",
|
| 57 |
+
"dd",
|
| 58 |
+
"div",
|
| 59 |
+
"dl",
|
| 60 |
+
"dt",
|
| 61 |
+
"figcaption",
|
| 62 |
+
"figure",
|
| 63 |
+
"footer",
|
| 64 |
+
"form",
|
| 65 |
+
"h1",
|
| 66 |
+
"h2",
|
| 67 |
+
"h3",
|
| 68 |
+
"h4",
|
| 69 |
+
"h5",
|
| 70 |
+
"h6",
|
| 71 |
+
"header",
|
| 72 |
+
"hr",
|
| 73 |
+
"li",
|
| 74 |
+
"main",
|
| 75 |
+
"nav",
|
| 76 |
+
"ol",
|
| 77 |
+
"p",
|
| 78 |
+
"pre",
|
| 79 |
+
"section",
|
| 80 |
+
"table",
|
| 81 |
+
"td",
|
| 82 |
+
"th",
|
| 83 |
+
"tr",
|
| 84 |
+
"ul",
|
| 85 |
+
}
|
| 86 |
+
INVISIBLE_FORMAT_CHARS = str.maketrans(
|
| 87 |
+
{
|
| 88 |
+
"\u200b": None, # zero-width space
|
| 89 |
+
"\u200c": None, # zero-width non-joiner
|
| 90 |
+
"\u200d": None, # zero-width joiner
|
| 91 |
+
"\u200e": None, # left-to-right mark (for example, ‎)
|
| 92 |
+
"\u200f": None, # right-to-left mark
|
| 93 |
+
"\ufeff": None, # byte-order mark / zero-width no-break space
|
| 94 |
+
}
|
| 95 |
+
)
|
| 96 |
+
|
| 97 |
+
WIKILINK_RE = re.compile(r"\[\[([^\[\]]*)\]\]")
|
| 98 |
+
EXTERNAL_LINK_RE = re.compile(
|
| 99 |
+
r"\[https?://[^\s\]]+(?:\s+([^\]]*?))?\]", re.IGNORECASE
|
| 100 |
+
)
|
| 101 |
+
BARE_URL_RE = re.compile(r"https?://[^\s<>\[\]\"']+", re.IGNORECASE)
|
| 102 |
+
WHITESPACE_RE = re.compile(r"\s+")
|
| 103 |
+
SPACE_BEFORE_PUNCTUATION_RE = re.compile(r"\s+([,.;:!?])")
|
| 104 |
+
CLOSING_SENTENCE_CHARS = frozenset("\"'\u2019\u201d)]}")
|
| 105 |
+
TRAILING_URL_PUNCTUATION = frozenset(".,;:!?)]}")
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
class _HTMLTextExtractor(HTMLParser):
|
| 109 |
+
"""Drop markup while retaining visible text and sensible word boundaries."""
|
| 110 |
+
|
| 111 |
+
def __init__(self) -> None:
|
| 112 |
+
super().__init__(convert_charrefs=True)
|
| 113 |
+
self.parts: list[str] = []
|
| 114 |
+
|
| 115 |
+
def handle_starttag(
|
| 116 |
+
self, tag: str, attrs: list[tuple[str, Optional[str]]]
|
| 117 |
+
) -> None:
|
| 118 |
+
del attrs
|
| 119 |
+
if tag.lower() in BLOCK_TAGS:
|
| 120 |
+
self.parts.append(" ")
|
| 121 |
+
|
| 122 |
+
def handle_startendtag(
|
| 123 |
+
self, tag: str, attrs: list[tuple[str, Optional[str]]]
|
| 124 |
+
) -> None:
|
| 125 |
+
self.handle_starttag(tag, attrs)
|
| 126 |
+
|
| 127 |
+
def handle_endtag(self, tag: str) -> None:
|
| 128 |
+
if tag.lower() in BLOCK_TAGS:
|
| 129 |
+
self.parts.append(" ")
|
| 130 |
+
|
| 131 |
+
def handle_data(self, data: str) -> None:
|
| 132 |
+
self.parts.append(data)
|
| 133 |
+
|
| 134 |
+
def get_text(self) -> str:
|
| 135 |
+
return "".join(self.parts)
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
def normalize_whitespace(text: str) -> str:
|
| 139 |
+
"""Collapse spaces, tabs, and newlines into a single ASCII space."""
|
| 140 |
+
|
| 141 |
+
normalized = WHITESPACE_RE.sub(" ", text).strip()
|
| 142 |
+
return SPACE_BEFORE_PUNCTUATION_RE.sub(r"\1", normalized)
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
def strip_html_and_decode_entities(text: str) -> str:
|
| 146 |
+
"""Decode entities, remove HTML tags, and remove invisible format marks."""
|
| 147 |
+
|
| 148 |
+
decoded = html.unescape(text).translate(INVISIBLE_FORMAT_CHARS)
|
| 149 |
+
parser = _HTMLTextExtractor()
|
| 150 |
+
parser.feed(decoded)
|
| 151 |
+
parser.close()
|
| 152 |
+
return parser.get_text().translate(INVISIBLE_FORMAT_CHARS)
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
def remove_balanced_templates(text: str) -> str:
|
| 156 |
+
"""Remove balanced, possibly nested, ``{{...}}`` template spans.
|
| 157 |
+
|
| 158 |
+
An unmatched opening marker is preserved instead of discarding the rest of
|
| 159 |
+
an article. This protects useful text when malformed source markup appears.
|
| 160 |
+
"""
|
| 161 |
+
|
| 162 |
+
spans: list[tuple[int, int]] = []
|
| 163 |
+
stack: list[int] = []
|
| 164 |
+
outer_start = -1
|
| 165 |
+
index = 0
|
| 166 |
+
|
| 167 |
+
while index < len(text) - 1:
|
| 168 |
+
pair = text[index : index + 2]
|
| 169 |
+
if pair == "{{":
|
| 170 |
+
if not stack:
|
| 171 |
+
outer_start = index
|
| 172 |
+
stack.append(index)
|
| 173 |
+
index += 2
|
| 174 |
+
continue
|
| 175 |
+
if pair == "}}" and stack:
|
| 176 |
+
stack.pop()
|
| 177 |
+
index += 2
|
| 178 |
+
if not stack:
|
| 179 |
+
spans.append((outer_start, index))
|
| 180 |
+
outer_start = -1
|
| 181 |
+
continue
|
| 182 |
+
index += 1
|
| 183 |
+
|
| 184 |
+
if not spans:
|
| 185 |
+
return text
|
| 186 |
+
|
| 187 |
+
parts: list[str] = []
|
| 188 |
+
cursor = 0
|
| 189 |
+
for start, end in spans:
|
| 190 |
+
parts.append(text[cursor:start])
|
| 191 |
+
parts.append(" ")
|
| 192 |
+
cursor = end
|
| 193 |
+
parts.append(text[cursor:])
|
| 194 |
+
return "".join(parts)
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
def _replace_wikilink(match: re.Match[str]) -> str:
|
| 198 |
+
inner = match.group(1).strip()
|
| 199 |
+
if not inner:
|
| 200 |
+
return ""
|
| 201 |
+
|
| 202 |
+
target = inner.split("|", 1)[0].strip()
|
| 203 |
+
if target.casefold().startswith(REMOVED_WIKILINK_NAMESPACES):
|
| 204 |
+
return ""
|
| 205 |
+
|
| 206 |
+
if "|" in inner:
|
| 207 |
+
return inner.rsplit("|", 1)[1].strip()
|
| 208 |
+
return inner
|
| 209 |
+
|
| 210 |
+
|
| 211 |
+
def clean_wikilinks(text: str) -> str:
|
| 212 |
+
"""Resolve normal wikilinks and remove media/category wikilink blocks."""
|
| 213 |
+
|
| 214 |
+
while True:
|
| 215 |
+
updated, replacements = WIKILINK_RE.subn(_replace_wikilink, text)
|
| 216 |
+
text = updated
|
| 217 |
+
if replacements == 0:
|
| 218 |
+
return text
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
def clean_external_links(text: str) -> str:
|
| 222 |
+
"""Keep bracketed external-link labels and remove unlabeled links."""
|
| 223 |
+
|
| 224 |
+
def replace(match: re.Match[str]) -> str:
|
| 225 |
+
label = match.group(1)
|
| 226 |
+
return label.strip() if label else ""
|
| 227 |
+
|
| 228 |
+
return EXTERNAL_LINK_RE.sub(replace, text)
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
def remove_bare_urls(text: str) -> str:
|
| 232 |
+
"""Remove bare HTTP(S) URLs without swallowing adjacent sentence marks."""
|
| 233 |
+
|
| 234 |
+
def replace(match: re.Match[str]) -> str:
|
| 235 |
+
url = match.group(0)
|
| 236 |
+
trailing: list[str] = []
|
| 237 |
+
while url and url[-1] in TRAILING_URL_PUNCTUATION:
|
| 238 |
+
trailing.append(url[-1])
|
| 239 |
+
url = url[:-1]
|
| 240 |
+
return "".join(reversed(trailing))
|
| 241 |
+
|
| 242 |
+
return BARE_URL_RE.sub(replace, text)
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
def clean_content(content: str) -> str:
|
| 246 |
+
"""Apply all requested article-body cleaning steps."""
|
| 247 |
+
|
| 248 |
+
text = strip_html_and_decode_entities(content)
|
| 249 |
+
text = remove_balanced_templates(text)
|
| 250 |
+
text = clean_wikilinks(text)
|
| 251 |
+
text = clean_external_links(text)
|
| 252 |
+
text = remove_bare_urls(text)
|
| 253 |
+
return normalize_whitespace(text)
|
| 254 |
+
|
| 255 |
+
|
| 256 |
+
def title_from_link(link: str) -> str:
|
| 257 |
+
"""Extract and decode the page name following ``/wiki/`` in a URL."""
|
| 258 |
+
|
| 259 |
+
path = unquote(urlsplit(link).path)
|
| 260 |
+
marker = "/wiki/"
|
| 261 |
+
marker_index = path.casefold().find(marker)
|
| 262 |
+
if marker_index < 0:
|
| 263 |
+
return ""
|
| 264 |
+
page_name = path[marker_index + len(marker) :]
|
| 265 |
+
return normalize_whitespace(page_name.replace("_", " "))
|
| 266 |
+
|
| 267 |
+
|
| 268 |
+
def clean_title(title: str, link: str) -> str:
|
| 269 |
+
"""Clean a title and use its URL page name when the result is empty."""
|
| 270 |
+
|
| 271 |
+
cleaned = normalize_whitespace(strip_html_and_decode_entities(title))
|
| 272 |
+
return cleaned or title_from_link(link)
|
| 273 |
+
|
| 274 |
+
|
| 275 |
+
def initial_filter_reason(article: Any) -> Optional[str]:
|
| 276 |
+
"""Return the first matching raw-record filter reason, if any."""
|
| 277 |
+
|
| 278 |
+
if not isinstance(article, dict):
|
| 279 |
+
return "invalid_record"
|
| 280 |
+
|
| 281 |
+
raw_title = article.get("title")
|
| 282 |
+
raw_link = article.get("link")
|
| 283 |
+
raw_content = article.get("content")
|
| 284 |
+
|
| 285 |
+
title = "" if raw_title is None else str(raw_title)
|
| 286 |
+
link = "" if raw_link is None else str(raw_link)
|
| 287 |
+
folded_title = title.strip().casefold()
|
| 288 |
+
folded_link = link.casefold()
|
| 289 |
+
|
| 290 |
+
if folded_title.startswith(TITLE_NAMESPACE_PREFIXES):
|
| 291 |
+
return "title_namespace_prefix"
|
| 292 |
+
if any(keyword in folded_title for keyword in PROTECTION_KEYWORDS):
|
| 293 |
+
return "title_protection_keyword"
|
| 294 |
+
if raw_content is None or len(str(raw_content).strip()) < 50:
|
| 295 |
+
return "content_empty_or_under_50_chars"
|
| 296 |
+
if "/wiki/file:" in folded_link or "/wiki/image:" in folded_link:
|
| 297 |
+
return "file_or_image_link"
|
| 298 |
+
return None
|
| 299 |
+
|
| 300 |
+
|
| 301 |
+
def split_sentences(text: str) -> list[str]:
|
| 302 |
+
"""Split after .?! plus optional closing quotes/brackets and whitespace."""
|
| 303 |
+
|
| 304 |
+
sentences: list[str] = []
|
| 305 |
+
sentence_start = 0
|
| 306 |
+
index = 0
|
| 307 |
+
|
| 308 |
+
while index < len(text):
|
| 309 |
+
if not text[index].isspace():
|
| 310 |
+
index += 1
|
| 311 |
+
continue
|
| 312 |
+
|
| 313 |
+
previous = index - 1
|
| 314 |
+
while (
|
| 315 |
+
previous >= sentence_start
|
| 316 |
+
and text[previous] in CLOSING_SENTENCE_CHARS
|
| 317 |
+
):
|
| 318 |
+
previous -= 1
|
| 319 |
+
|
| 320 |
+
if previous >= sentence_start and text[previous] in ".?!":
|
| 321 |
+
sentence = text[sentence_start:index].strip()
|
| 322 |
+
if sentence:
|
| 323 |
+
sentences.append(sentence)
|
| 324 |
+
while index < len(text) and text[index].isspace():
|
| 325 |
+
index += 1
|
| 326 |
+
sentence_start = index
|
| 327 |
+
continue
|
| 328 |
+
|
| 329 |
+
index += 1
|
| 330 |
+
|
| 331 |
+
remainder = text[sentence_start:].strip()
|
| 332 |
+
if remainder:
|
| 333 |
+
sentences.append(remainder)
|
| 334 |
+
return sentences
|
| 335 |
+
|
| 336 |
+
|
| 337 |
+
def word_count(text: str) -> int:
|
| 338 |
+
return len(text.split())
|
| 339 |
+
|
| 340 |
+
|
| 341 |
+
def make_passages(text: str) -> list[str]:
|
| 342 |
+
"""Greedily accumulate sentences into Search-R1 retrieval passages."""
|
| 343 |
+
|
| 344 |
+
if word_count(text) < MIN_PASSAGE_WORDS:
|
| 345 |
+
return []
|
| 346 |
+
|
| 347 |
+
passages: list[str] = []
|
| 348 |
+
current_sentences: list[str] = []
|
| 349 |
+
current_words = 0
|
| 350 |
+
|
| 351 |
+
for sentence in split_sentences(text):
|
| 352 |
+
current_sentences.append(sentence)
|
| 353 |
+
current_words += word_count(sentence)
|
| 354 |
+
if current_words >= TARGET_PASSAGE_WORDS:
|
| 355 |
+
passages.append(" ".join(current_sentences))
|
| 356 |
+
current_sentences = []
|
| 357 |
+
current_words = 0
|
| 358 |
+
|
| 359 |
+
if current_sentences:
|
| 360 |
+
remainder = " ".join(current_sentences)
|
| 361 |
+
if current_words < MIN_PASSAGE_WORDS and passages:
|
| 362 |
+
passages[-1] = f"{passages[-1]} {remainder}"
|
| 363 |
+
else:
|
| 364 |
+
passages.append(remainder)
|
| 365 |
+
|
| 366 |
+
return passages
|
| 367 |
+
|
| 368 |
+
|
| 369 |
+
def load_documents(path: Path) -> list[Any]:
|
| 370 |
+
"""Load either the observed {documents: [...]} root or a top-level array."""
|
| 371 |
+
|
| 372 |
+
with path.open("r", encoding="utf-8") as source:
|
| 373 |
+
data = json.load(source)
|
| 374 |
+
|
| 375 |
+
if isinstance(data, list):
|
| 376 |
+
return data
|
| 377 |
+
if isinstance(data, dict) and isinstance(data.get("documents"), list):
|
| 378 |
+
return data["documents"]
|
| 379 |
+
raise ValueError(
|
| 380 |
+
f"{path} must contain a JSON array or an object with a 'documents' array"
|
| 381 |
+
)
|
| 382 |
+
|
| 383 |
+
|
| 384 |
+
def verify_input_files(paths: Iterable[Path]) -> None:
|
| 385 |
+
missing = [str(path) for path in paths if not path.is_file()]
|
| 386 |
+
if missing:
|
| 387 |
+
formatted = "\n ".join(missing)
|
| 388 |
+
raise FileNotFoundError(f"Missing input files:\n {formatted}")
|
| 389 |
+
|
| 390 |
+
|
| 391 |
+
def print_statistics(
|
| 392 |
+
original_articles: int,
|
| 393 |
+
retained_articles: int,
|
| 394 |
+
filter_counts: Counter[str],
|
| 395 |
+
passage_count: int,
|
| 396 |
+
) -> None:
|
| 397 |
+
filtered_articles = sum(filter_counts.values())
|
| 398 |
+
average = passage_count / retained_articles if retained_articles else 0.0
|
| 399 |
+
|
| 400 |
+
print("\nCompleted corpus generation.")
|
| 401 |
+
print(f"Original articles: {original_articles}")
|
| 402 |
+
print(f"Retained articles: {retained_articles}")
|
| 403 |
+
print(f"Filtered articles: {filtered_articles}")
|
| 404 |
+
print("Filtered by reason (mutually exclusive):")
|
| 405 |
+
for reason in (
|
| 406 |
+
"invalid_record",
|
| 407 |
+
"title_namespace_prefix",
|
| 408 |
+
"title_protection_keyword",
|
| 409 |
+
"content_empty_or_under_50_chars",
|
| 410 |
+
"file_or_image_link",
|
| 411 |
+
"cleaned_content_under_50_words",
|
| 412 |
+
):
|
| 413 |
+
print(f" {reason}: {filter_counts[reason]}")
|
| 414 |
+
print(f"Generated passages: {passage_count}")
|
| 415 |
+
print(f"Average passages per retained article: {average:.4f}")
|
| 416 |
+
print(f"Output file: {OUTPUT_PATH}")
|
| 417 |
+
|
| 418 |
+
|
| 419 |
+
def build_corpus() -> None:
|
| 420 |
+
"""Read, clean, split, and atomically write the complete passage corpus."""
|
| 421 |
+
|
| 422 |
+
verify_input_files(INPUT_FILES)
|
| 423 |
+
|
| 424 |
+
processed_articles = 0
|
| 425 |
+
retained_articles = 0
|
| 426 |
+
passage_count = 0
|
| 427 |
+
filter_counts: Counter[str] = Counter()
|
| 428 |
+
|
| 429 |
+
try:
|
| 430 |
+
with TEMP_OUTPUT_PATH.open("w", encoding="utf-8", newline="\n") as output:
|
| 431 |
+
for input_path in INPUT_FILES:
|
| 432 |
+
documents = load_documents(input_path)
|
| 433 |
+
for article in documents:
|
| 434 |
+
processed_articles += 1
|
| 435 |
+
reason = initial_filter_reason(article)
|
| 436 |
+
|
| 437 |
+
if reason is not None:
|
| 438 |
+
filter_counts[reason] += 1
|
| 439 |
+
else:
|
| 440 |
+
assert isinstance(article, dict)
|
| 441 |
+
raw_content = str(article["content"])
|
| 442 |
+
raw_title = "" if article.get("title") is None else str(article["title"])
|
| 443 |
+
raw_link = "" if article.get("link") is None else str(article["link"])
|
| 444 |
+
|
| 445 |
+
cleaned_content = clean_content(raw_content)
|
| 446 |
+
passages = make_passages(cleaned_content)
|
| 447 |
+
if not passages:
|
| 448 |
+
filter_counts["cleaned_content_under_50_words"] += 1
|
| 449 |
+
else:
|
| 450 |
+
title = clean_title(raw_title, raw_link)
|
| 451 |
+
retained_articles += 1
|
| 452 |
+
for passage in passages:
|
| 453 |
+
record = {
|
| 454 |
+
"id": str(passage_count),
|
| 455 |
+
"contents": f'"{title}"\n{passage}',
|
| 456 |
+
}
|
| 457 |
+
output.write(json.dumps(record, ensure_ascii=False))
|
| 458 |
+
output.write("\n")
|
| 459 |
+
passage_count += 1
|
| 460 |
+
|
| 461 |
+
if processed_articles % PROGRESS_INTERVAL == 0:
|
| 462 |
+
print(
|
| 463 |
+
f"Processed {processed_articles} articles, "
|
| 464 |
+
f"generated {passage_count} passages..."
|
| 465 |
+
)
|
| 466 |
+
|
| 467 |
+
os.replace(TEMP_OUTPUT_PATH, OUTPUT_PATH)
|
| 468 |
+
except BaseException:
|
| 469 |
+
try:
|
| 470 |
+
TEMP_OUTPUT_PATH.unlink(missing_ok=True)
|
| 471 |
+
except OSError:
|
| 472 |
+
pass
|
| 473 |
+
raise
|
| 474 |
+
|
| 475 |
+
print_statistics(
|
| 476 |
+
original_articles=processed_articles,
|
| 477 |
+
retained_articles=retained_articles,
|
| 478 |
+
filter_counts=filter_counts,
|
| 479 |
+
passage_count=passage_count,
|
| 480 |
+
)
|
| 481 |
+
|
| 482 |
+
|
| 483 |
+
if __name__ == "__main__":
|
| 484 |
+
build_corpus()
|
demo_generate_30.py
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Generate and print a 30-passage Search-R1 corpus demo."""
|
| 2 |
+
|
| 3 |
+
import json
|
| 4 |
+
import os
|
| 5 |
+
import sys
|
| 6 |
+
from collections import Counter
|
| 7 |
+
|
| 8 |
+
import build_search_r1_corpus as corpus_builder
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
DEMO_PASSAGE_LIMIT = 30
|
| 12 |
+
DEMO_OUTPUT_PATH = corpus_builder.BASE_DIR / "search_r1_corpus_demo.jsonl"
|
| 13 |
+
DEMO_TEMP_PATH = corpus_builder.BASE_DIR / "search_r1_corpus_demo.jsonl.tmp"
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def main() -> None:
|
| 17 |
+
if hasattr(sys.stdout, "reconfigure"):
|
| 18 |
+
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
| 19 |
+
|
| 20 |
+
corpus_builder.verify_input_files(corpus_builder.INPUT_FILES)
|
| 21 |
+
|
| 22 |
+
jsonl_lines = []
|
| 23 |
+
scanned_articles = 0
|
| 24 |
+
retained_articles = 0
|
| 25 |
+
filter_counts = Counter()
|
| 26 |
+
|
| 27 |
+
try:
|
| 28 |
+
with DEMO_TEMP_PATH.open(
|
| 29 |
+
"w", encoding="utf-8", newline="\n"
|
| 30 |
+
) as output:
|
| 31 |
+
for input_path in corpus_builder.INPUT_FILES:
|
| 32 |
+
documents = corpus_builder.load_documents(input_path)
|
| 33 |
+
|
| 34 |
+
for article in documents:
|
| 35 |
+
scanned_articles += 1
|
| 36 |
+
reason = corpus_builder.initial_filter_reason(article)
|
| 37 |
+
|
| 38 |
+
if reason is not None:
|
| 39 |
+
filter_counts[reason] += 1
|
| 40 |
+
continue
|
| 41 |
+
|
| 42 |
+
raw_content = str(article["content"])
|
| 43 |
+
raw_title = (
|
| 44 |
+
""
|
| 45 |
+
if article.get("title") is None
|
| 46 |
+
else str(article["title"])
|
| 47 |
+
)
|
| 48 |
+
raw_link = (
|
| 49 |
+
""
|
| 50 |
+
if article.get("link") is None
|
| 51 |
+
else str(article["link"])
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
cleaned_content = corpus_builder.clean_content(raw_content)
|
| 55 |
+
passages = corpus_builder.make_passages(cleaned_content)
|
| 56 |
+
if not passages:
|
| 57 |
+
filter_counts["cleaned_content_under_50_words"] += 1
|
| 58 |
+
continue
|
| 59 |
+
|
| 60 |
+
retained_articles += 1
|
| 61 |
+
title = corpus_builder.clean_title(raw_title, raw_link)
|
| 62 |
+
|
| 63 |
+
for passage in passages:
|
| 64 |
+
passage_id = str(len(jsonl_lines))
|
| 65 |
+
record = {
|
| 66 |
+
"id": passage_id,
|
| 67 |
+
"contents": f'"{title}"\n{passage}',
|
| 68 |
+
}
|
| 69 |
+
line = json.dumps(record, ensure_ascii=False)
|
| 70 |
+
output.write(line)
|
| 71 |
+
output.write("\n")
|
| 72 |
+
jsonl_lines.append(line)
|
| 73 |
+
|
| 74 |
+
if len(jsonl_lines) == DEMO_PASSAGE_LIMIT:
|
| 75 |
+
break
|
| 76 |
+
|
| 77 |
+
if len(jsonl_lines) == DEMO_PASSAGE_LIMIT:
|
| 78 |
+
break
|
| 79 |
+
|
| 80 |
+
if len(jsonl_lines) == DEMO_PASSAGE_LIMIT:
|
| 81 |
+
break
|
| 82 |
+
|
| 83 |
+
os.replace(DEMO_TEMP_PATH, DEMO_OUTPUT_PATH)
|
| 84 |
+
except BaseException:
|
| 85 |
+
try:
|
| 86 |
+
DEMO_TEMP_PATH.unlink(missing_ok=True)
|
| 87 |
+
except OSError:
|
| 88 |
+
pass
|
| 89 |
+
raise
|
| 90 |
+
|
| 91 |
+
print("=" * 80)
|
| 92 |
+
print(f"Search-R1 corpus demo: {len(jsonl_lines)} JSONL records")
|
| 93 |
+
print("=" * 80)
|
| 94 |
+
for line in jsonl_lines:
|
| 95 |
+
print(line)
|
| 96 |
+
|
| 97 |
+
print("=" * 80)
|
| 98 |
+
print("Demo summary")
|
| 99 |
+
print("=" * 80)
|
| 100 |
+
print(f"Scanned source articles: {scanned_articles}")
|
| 101 |
+
print(f"Articles contributing passages: {retained_articles}")
|
| 102 |
+
print(f"Filtered while scanning: {sum(filter_counts.values())}")
|
| 103 |
+
for reason, count in sorted(filter_counts.items()):
|
| 104 |
+
print(f" {reason}: {count}")
|
| 105 |
+
print(f"Generated passages: {len(jsonl_lines)}")
|
| 106 |
+
print(f"Output file: {DEMO_OUTPUT_PATH}")
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
if __name__ == "__main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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"schema_version": "toolelite.hf-publication.v1",
|
| 3 |
+
"repo_id": "BitZone910/wiki_math",
|
| 4 |
+
"repo_type": "dataset",
|
| 5 |
+
"visibility": "public",
|
| 6 |
+
"asset_id": "62d45b3423afbc1b88afbad41ce8bbd24872798d12c3a734b1006b9326dd329d",
|
| 7 |
+
"files": [
|
| 8 |
+
{
|
| 9 |
+
"path": "asset-summary.json",
|
| 10 |
+
"bytes": 166,
|
| 11 |
+
"sha256": "82482aeb6918ddd66df38282bc9af0fb2e013f090f438bd357d957f16352ec96"
|
| 12 |
+
},
|
| 13 |
+
{
|
| 14 |
+
"path": "build_search_r1_corpus.py",
|
| 15 |
+
"bytes": 14447,
|
| 16 |
+
"sha256": "7267bb5004d7536ba7e2c5ec91d587fb5b3c7cec07ca5a0ab0b18b8cabaf9a58"
|
| 17 |
+
},
|
| 18 |
+
{
|
| 19 |
+
"path": "demo_generate_30.py",
|
| 20 |
+
"bytes": 3662,
|
| 21 |
+
"sha256": "4c1030c4b578da78b758a1bf4274c7a6fd22fed553281d6f7e45f5028c55a35d"
|
| 22 |
+
},
|
| 23 |
+
{
|
| 24 |
+
"path": "NOTICE.md",
|
| 25 |
+
"bytes": 305,
|
| 26 |
+
"sha256": "8940071130fc94b88573476a90a5161093744b1d1d2f42514344ba30e9b1a892"
|
| 27 |
+
},
|
| 28 |
+
{
|
| 29 |
+
"path": "raw_data/1.json",
|
| 30 |
+
"bytes": 48240711,
|
| 31 |
+
"sha256": "d93207a924c221271c18ce74d3a8eac375edbe3b5de0828f3a1801bdb04b6607"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"path": "raw_data/10.json",
|
| 35 |
+
"bytes": 14459930,
|
| 36 |
+
"sha256": "89899b15fee5c1f4777edcdbbdaa1f707cca0b0609c89c7f7e1713ccbf3b507c"
|
| 37 |
+
},
|
| 38 |
+
{
|
| 39 |
+
"path": "raw_data/11.json",
|
| 40 |
+
"bytes": 13821228,
|
| 41 |
+
"sha256": "ff36acced0fcd104e98f95e9759bf481f417d10a5d5c14bb0822a1e4511c19d1"
|
| 42 |
+
},
|
| 43 |
+
{
|
| 44 |
+
"path": "raw_data/12.json",
|
| 45 |
+
"bytes": 21750967,
|
| 46 |
+
"sha256": "aa35601110ea2976b87f5f8e8460b65d16e88efbefff61eaf2792b23131f051d"
|
| 47 |
+
},
|
| 48 |
+
{
|
| 49 |
+
"path": "raw_data/13.json",
|
| 50 |
+
"bytes": 23249464,
|
| 51 |
+
"sha256": "7a7b0409ae480f242e4ce62ca0c6694710459c8df1169dad5f1105adc20050a2"
|
| 52 |
+
},
|
| 53 |
+
{
|
| 54 |
+
"path": "raw_data/14.json",
|
| 55 |
+
"bytes": 15485912,
|
| 56 |
+
"sha256": "5a25e5ef2c908adeb88692e7d306cdb84f6b31b84cf722a66b8a06664e11606b"
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"path": "raw_data/15.json",
|
| 60 |
+
"bytes": 16017542,
|
| 61 |
+
"sha256": "74cbae286bcd8e9a6209fff2b6ce7d75fe18e478d0731957fdc47d32ad550f34"
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"path": "raw_data/16.json",
|
| 65 |
+
"bytes": 17147104,
|
| 66 |
+
"sha256": "7a0b34fd181c86d6ff4a829f9ccf0a7fcf9f3e901ce07acadfabaf8fe9768617"
|
| 67 |
+
},
|
| 68 |
+
{
|
| 69 |
+
"path": "raw_data/17.json",
|
| 70 |
+
"bytes": 14880769,
|
| 71 |
+
"sha256": "d9caad660878bf5d198abb9020dc770ff26b2134e95a168d08f99018912c8dd3"
|
| 72 |
+
},
|
| 73 |
+
{
|
| 74 |
+
"path": "raw_data/18.json",
|
| 75 |
+
"bytes": 17188925,
|
| 76 |
+
"sha256": "f1f38fc7b9805972f3b67d47781088dea15d20c5b7a9fd39919c2a05248c9258"
|
| 77 |
+
},
|
| 78 |
+
{
|
| 79 |
+
"path": "raw_data/19.json",
|
| 80 |
+
"bytes": 15952857,
|
| 81 |
+
"sha256": "c3e236289285308934ba9800e846dbfc40c8c1e542bfe5329d76a3c2c42c3af2"
|
| 82 |
+
},
|
| 83 |
+
{
|
| 84 |
+
"path": "raw_data/2.json",
|
| 85 |
+
"bytes": 40525855,
|
| 86 |
+
"sha256": "e043d2600ec6d1d918184d3de6f9c848976bd3844418239acd3aac8b760fe958"
|
| 87 |
+
},
|
| 88 |
+
{
|
| 89 |
+
"path": "raw_data/20.json",
|
| 90 |
+
"bytes": 17354868,
|
| 91 |
+
"sha256": "bfab6793d569677ffa3c144bb79edf0592d92fcb5340432d31b4070123d150de"
|
| 92 |
+
},
|
| 93 |
+
{
|
| 94 |
+
"path": "raw_data/21.json",
|
| 95 |
+
"bytes": 15281958,
|
| 96 |
+
"sha256": "08284c3f5f9ee54132f297be27b1beecf5d7075c20b7ed1547014693236b85c4"
|
| 97 |
+
},
|
| 98 |
+
{
|
| 99 |
+
"path": "raw_data/22.json",
|
| 100 |
+
"bytes": 22178602,
|
| 101 |
+
"sha256": "e1a93e09ff5dc9522df1e1cbf82a79d8a8aefbdd9a7ba164cb83a8511c9508f6"
|
| 102 |
+
},
|
| 103 |
+
{
|
| 104 |
+
"path": "raw_data/23.json",
|
| 105 |
+
"bytes": 31585222,
|
| 106 |
+
"sha256": "9479a067a829872638999816d15d648f0a6e8117583697a18f18c93bfc4295b9"
|
| 107 |
+
},
|
| 108 |
+
{
|
| 109 |
+
"path": "raw_data/24.json",
|
| 110 |
+
"bytes": 17337513,
|
| 111 |
+
"sha256": "ed963df4a07a99781523da4f36ab8280da5fec51e7d24711f9782e77e1b29d0f"
|
| 112 |
+
},
|
| 113 |
+
{
|
| 114 |
+
"path": "raw_data/25.json",
|
| 115 |
+
"bytes": 31150026,
|
| 116 |
+
"sha256": "f11e79d3389a1bd71e8a17a87ccd069374bfcf568a01b0bfe2a3f53342a505b9"
|
| 117 |
+
},
|
| 118 |
+
{
|
| 119 |
+
"path": "raw_data/3.json",
|
| 120 |
+
"bytes": 34635903,
|
| 121 |
+
"sha256": "e70a3d6fc974a5037e6c260244dd121a1f4967b369b3779c4d2cd0790abf523e"
|
| 122 |
+
},
|
| 123 |
+
{
|
| 124 |
+
"path": "raw_data/4.json",
|
| 125 |
+
"bytes": 33715353,
|
| 126 |
+
"sha256": "2c00d592ff597a2f9b130a6dd577641e6219591cc92adc76d505d831d814ed30"
|
| 127 |
+
},
|
| 128 |
+
{
|
| 129 |
+
"path": "raw_data/5.json",
|
| 130 |
+
"bytes": 38107300,
|
| 131 |
+
"sha256": "bdf2661189b8454277cab44e73eadd318dfa32a37b80eaac6ed29dce68aee4a9"
|
| 132 |
+
},
|
| 133 |
+
{
|
| 134 |
+
"path": "raw_data/6.json",
|
| 135 |
+
"bytes": 25177537,
|
| 136 |
+
"sha256": "41c3faaf5e35e5f2c03ded20b82aa8d19dc4d3bec7114a86bac80906169d98e0"
|
| 137 |
+
},
|
| 138 |
+
{
|
| 139 |
+
"path": "raw_data/7.json",
|
| 140 |
+
"bytes": 21966253,
|
| 141 |
+
"sha256": "db4eb0237f24d77811eeca3d49469fd6a82f08513a9a525f1d8effc6b9a9241e"
|
| 142 |
+
},
|
| 143 |
+
{
|
| 144 |
+
"path": "raw_data/8.json",
|
| 145 |
+
"bytes": 21020296,
|
| 146 |
+
"sha256": "449d59e64c9d82957d39296c4a74b3c675f705f746c20fb971be36cdde79f43a"
|
| 147 |
+
},
|
| 148 |
+
{
|
| 149 |
+
"path": "raw_data/9.json",
|
| 150 |
+
"bytes": 27945214,
|
| 151 |
+
"sha256": "66dc8ca47e6accddcce08f4ba30515f9b6d46c995e27f4f59210facfad3a5706"
|
| 152 |
+
},
|
| 153 |
+
{
|
| 154 |
+
"path": "README.md",
|
| 155 |
+
"bytes": 2692,
|
| 156 |
+
"sha256": "3a50f327a432d14e87c6440eb74b8aa7262139da967a601c2da4439c030e8040"
|
| 157 |
+
},
|
| 158 |
+
{
|
| 159 |
+
"path": "search_r1_corpus.jsonl",
|
| 160 |
+
"bytes": 443937190,
|
| 161 |
+
"sha256": "741affc0363d4bad7e8871559dd6f849d5b19fd73a99e0124c100974c64255a7"
|
| 162 |
+
}
|
| 163 |
+
],
|
| 164 |
+
"source_folder": "C:\\Users\\lenovo\\Desktop\\ToolElite_data_processing\\wiki_math",
|
| 165 |
+
"summary": {
|
| 166 |
+
"rows": 573011,
|
| 167 |
+
"fields": [
|
| 168 |
+
"contents",
|
| 169 |
+
"id"
|
| 170 |
+
],
|
| 171 |
+
"positional_ids": true,
|
| 172 |
+
"embeddings_included": false,
|
| 173 |
+
"faiss_index_included": false
|
| 174 |
+
}
|
| 175 |
+
}
|
raw_data/1.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d93207a924c221271c18ce74d3a8eac375edbe3b5de0828f3a1801bdb04b6607
|
| 3 |
+
size 48240711
|
raw_data/10.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:89899b15fee5c1f4777edcdbbdaa1f707cca0b0609c89c7f7e1713ccbf3b507c
|
| 3 |
+
size 14459930
|
raw_data/11.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ff36acced0fcd104e98f95e9759bf481f417d10a5d5c14bb0822a1e4511c19d1
|
| 3 |
+
size 13821228
|
raw_data/12.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:aa35601110ea2976b87f5f8e8460b65d16e88efbefff61eaf2792b23131f051d
|
| 3 |
+
size 21750967
|
raw_data/13.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7a7b0409ae480f242e4ce62ca0c6694710459c8df1169dad5f1105adc20050a2
|
| 3 |
+
size 23249464
|
raw_data/14.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5a25e5ef2c908adeb88692e7d306cdb84f6b31b84cf722a66b8a06664e11606b
|
| 3 |
+
size 15485912
|
raw_data/15.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:74cbae286bcd8e9a6209fff2b6ce7d75fe18e478d0731957fdc47d32ad550f34
|
| 3 |
+
size 16017542
|
raw_data/16.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7a0b34fd181c86d6ff4a829f9ccf0a7fcf9f3e901ce07acadfabaf8fe9768617
|
| 3 |
+
size 17147104
|
raw_data/17.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d9caad660878bf5d198abb9020dc770ff26b2134e95a168d08f99018912c8dd3
|
| 3 |
+
size 14880769
|
raw_data/18.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f1f38fc7b9805972f3b67d47781088dea15d20c5b7a9fd39919c2a05248c9258
|
| 3 |
+
size 17188925
|
raw_data/19.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c3e236289285308934ba9800e846dbfc40c8c1e542bfe5329d76a3c2c42c3af2
|
| 3 |
+
size 15952857
|
raw_data/2.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e043d2600ec6d1d918184d3de6f9c848976bd3844418239acd3aac8b760fe958
|
| 3 |
+
size 40525855
|
raw_data/20.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bfab6793d569677ffa3c144bb79edf0592d92fcb5340432d31b4070123d150de
|
| 3 |
+
size 17354868
|
raw_data/21.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:08284c3f5f9ee54132f297be27b1beecf5d7075c20b7ed1547014693236b85c4
|
| 3 |
+
size 15281958
|
raw_data/22.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e1a93e09ff5dc9522df1e1cbf82a79d8a8aefbdd9a7ba164cb83a8511c9508f6
|
| 3 |
+
size 22178602
|
raw_data/23.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9479a067a829872638999816d15d648f0a6e8117583697a18f18c93bfc4295b9
|
| 3 |
+
size 31585222
|
raw_data/24.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ed963df4a07a99781523da4f36ab8280da5fec51e7d24711f9782e77e1b29d0f
|
| 3 |
+
size 17337513
|
raw_data/25.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f11e79d3389a1bd71e8a17a87ccd069374bfcf568a01b0bfe2a3f53342a505b9
|
| 3 |
+
size 31150026
|
raw_data/3.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e70a3d6fc974a5037e6c260244dd121a1f4967b369b3779c4d2cd0790abf523e
|
| 3 |
+
size 34635903
|
raw_data/4.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2c00d592ff597a2f9b130a6dd577641e6219591cc92adc76d505d831d814ed30
|
| 3 |
+
size 33715353
|
raw_data/5.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bdf2661189b8454277cab44e73eadd318dfa32a37b80eaac6ed29dce68aee4a9
|
| 3 |
+
size 38107300
|
raw_data/6.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:41c3faaf5e35e5f2c03ded20b82aa8d19dc4d3bec7114a86bac80906169d98e0
|
| 3 |
+
size 25177537
|
raw_data/7.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:db4eb0237f24d77811eeca3d49469fd6a82f08513a9a525f1d8effc6b9a9241e
|
| 3 |
+
size 21966253
|
raw_data/8.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:449d59e64c9d82957d39296c4a74b3c675f705f746c20fb971be36cdde79f43a
|
| 3 |
+
size 21020296
|
raw_data/9.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:66dc8ca47e6accddcce08f4ba30515f9b6d46c995e27f4f59210facfad3a5706
|
| 3 |
+
size 27945214
|
search_r1_corpus.jsonl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:741affc0363d4bad7e8871559dd6f849d5b19fd73a99e0124c100974c64255a7
|
| 3 |
+
size 443937190
|