ReScraper: Unified Scraping and Cleaning of Web Data for Effective LLM Pretraining
Organizations: Language Technologies Institute, Carnegie Mellon University
Abstract
LLM pretraining corpora are normally cleaned by a stack of hand-written heuristics. A heuristic scraper extracts the main content from HTML, and dozens of rule-based filters then clean it, so corpus quality is capped by the coarseness and accuracy of the rules. In this work, we propose ReScraper, a unified language model of only 0.6B parameters that replaces this entire stack. To train ReScraper, we carefully curate supervised data from the outputs of three teacher models, so it learns to first extract the main content from raw data and then choose among four operations: keeping the page as extracted, editing out noisy lines and spans, deleting it entirely, or rewriting it when it is poorly written but informative. Based on the same crawled data pool, pretraining 400M, 1.4B, and 2.8B models on our curated data improves the DCLM Core score by a relative 3.8--4.7% over the strongest baseline at each scale, including the costly multi-agent curation. Our analyses show that each operation plays a distinct and complementary role, and that extracting and cleaning in one model outperforms a cascade of separate models. ReScraper also concentrates its operations on the pages that need them, raising the quality of poor pages the most while keeping the corpus diverse. These results demonstrate the feasibility and effectiveness of AI4AI for pretraining data curation, where a small learned model takes over an entire stage of the pipeline from hand-written heuristics. We open-source our code at https://github.com/cxcscmu/ReScraper
Figures & tables
| Operation | Payload | Explanation | Teacher |
|---|---|---|---|
| <extract> | rm - , rm | Always performed first. Drops lines through (or line ) that are not main content. | Dripper |
| <keep> | none | Return the extracted text unchanged. | Qwen3.8-27B |
| <delete> | none | Discard the page from the pretraining corpus. | Qwen3.8-27B |
| <edit> | rm - , rm sub : " " | Drop further noise lines through (or line ). Delete the string from line . | Qwen3.8-27B |
| <rewrite> | rewritten document | Replace the whole page with newly written text. | RePro |
| #Unique | Commonsense Reasoning | Language Understanding | Reading Comprehension | Symbolic Problem | World Knowledge | Core | |
|---|---|---|---|---|---|---|---|
| Cleaning Method | Tokens | (3 tasks) | (6 tasks) | (3 tasks) | (5 tasks) | (5 tasks) | (22 tasks) |
| 400M Setting: 400M model, 8.2B pretraining tokens | |||||||
| Raw text | 17.69B | 0.19822 | 0.14621 | 0.03926 | 0.15624 | 0.11101 | 0.13300 |
| C4-rule | 5.06B | 0.21326 | 0.19160 | -0.01954 | 0.13270 | 0.12398 | 0.13701 |
| RefinedWeb-rule | 7.04B | 0.18711 | 0.18266 | -0.07126 | 0.13612 | 0.12833 | 0.12572 |
| FineWeb-rule | 5.16B | 0.20774 | 0.19588 | 0.06072 | 0.11123 | 0.13741 | 0.14654 |
| #Unique | Commonsense Reasoning | Language Understanding | Reading Comprehension | Symbolic Problem | World Knowledge | Core | |
|---|---|---|---|---|---|---|---|
| Cleaning Method | Tokens | (3 tasks) | (6 tasks) | (3 tasks) | (5 tasks) | (5 tasks) | (22 tasks) |
| ReScraper | 7.44B | 0.33139 | 0.35533 | 0.20410 | 0.20563 | 0.24997 | 0.27348 |
| w/o <edit> | 7.77B | 0.30759 | 0.35021 | 0.20224 | 0.20027 | 0.24820 | 0.26696 |
| w/o <rewrite> | 6.62B | 0.28903 | 0.34319 | 0.19418 | 0.16804 | 0.23994 | 0.25221 |
| w/o <delete> | 9.08B | 0.31067 | 0.33114 | 0.13187 | 0.18944 | 0.24550 | 0.24951 |
| w/o <extract> | 14.10B | 0.27084 | 0.29191 | 0.13419 | 0.20447 | 0.20569 | 0.22806 |
Appendix figures & tables10 assets
Supplementary material from the paper’s appendix.
Appendix
| Component | Setting |
|---|---|
| Model and input | |
| Refiner backbone | Qwen3-0.6B ( Yang et al., 2025 ) |
| Input rendering | HTML-to-text rendering, BeautifulSoup markup strip, <lid: > ids |
| Context window | 32,768 tokens (prompt 29,696, answer 3,072) |
| Omitted pages | prompt over 29,696 tokens, rendering empty or under 20 characters, |
| or rendering over 60 s | |
| Stage 1 | Stage 2 | |||
|---|---|---|---|---|
| Operation | Targets | Share | Targets | Share |
| <keep> | 522,312 | 37.8% | 35,189 | 26.8% |
| <delete> | 499,924 | 36.1% | 32,239 | 24.5% |
| <edit> | 359,292 | 26.0% | 24,611 | 18.7% |
| <rewrite> | 1,587 | 0.1% | 39,445 | 30.0% |
| Total | 1,383,115 | 100% | 131,484 | 100% |
| Paid | Stage | H200 GPU h |
| Once | Dripper labels | 150 |
| Once | Qwen3.8-27B labels | 204 |
| Once | RePro-1B rewrites ( ) | 7 |
| Once | SFT, stage 1 | 244 |
| Once | SFT, stage 2 | 37 |
| Per pool | ProX-C | 147 |
| Case | Line-numbered input | Model prediction (SFT target) | Executed corpus record |
|---|---|---|---|
| Dripper only | lid:1 Oswald passes out Fair Play for Cuba flyers on the streets of New Orleans, August 1963 | <keep> <extract> <keep> | e2e_tag=extract ; keep the Dripper-extracted line unchanged. |
| Delete span | lid:1 IMG_3785 lid:2 Northrop Grumman’s Vice President and Deputy General Counsel, Litigation and Investigations, Valerie Caproni (J.D.’79) shares her experiences with Georgia Law students / IMG_3785 10/5/2012 | <edit> <extract> rm 1 <edit> sub 2: " / IMG_3785 10/5/2012" | e2e_tag=refine ; remove the image line and the exact trailing image identifier. |
| Delete lines + span | lid:158 Supreme Court Scenarios ... lid:162 Supreme Court Scenarios ... lid:175 This short brief summarizes ... Also available: Detailed brief | <edit> <extract> rm 1--157; rm 159--161; rm 163; rm 166--173; rm 176--196 <edit> rm 158; rm 162 sub 175: " Also available: Detailed brief" | e2e_tag=refine ; first apply Dripper’s removals, then Qwen’s two line removals and one exact-substring removal. |
| Delete page | lid:1 The page has moved to: this page | <delete> <extract> <delete> | e2e_tag=delete ; emit no document. |
| Rewrite | lid:19 Web Design & Devlopment lid:22 Website designing is an expansive term covering various aptitudes and controls that are utilized lid:23 as a part of the generation and upkeep of sites. | <rewrite> <extract> rm 1--18; rm 20--21; rm 42--63 <rewrite> Web Design & Development Website designing encompasses a wide range of skills and tools used to create and maintain websites. ... | e2e_tag=rewrite ; emit the newly generated replacement text. |
| ReScraper | Teacher | |
| <extract> removals, all pages | ||
| Pages | 4,989 | 4,989 |
| Pages with a removal (%) | 99.7 | 99.7 |
| rm ops per page | 3 [2–4] (4.6) | 3 [2–4] (4.4) |
| Lines removed per page | 85 [46–147] | 85 [46–146] |
| Span length, lines | 6 [2–25] | 6 [2–27] |
| Group before cleaning | Pages | RefinedWeb-rule | ProX-C | UltraX | ReScraper | |
|---|---|---|---|---|---|---|
| DataMan | 1–2 | 375 | 0.59 | 0.56 | 0.71 | 1.09 |
| 3 | 852 | 0.88 | 0.91 | 1.02 | 1.32 | |
| 4–5 | 3,772 | 1.69 | 1.66 | 1.73 | 1.90 | |
| FineWeb-Edu | 0.5 | 1,015 | 0.67 | 0.76 | 0.81 | 1.26 |
| 0.5–1 | 1,926 | 1.37 | 1.31 | 1.44 | 1.61 | |
| 1 | 2,059 | 1.92 | 1.87 | 1.93 | 1.98 | |
| Case | Resiliparse text | ProX-C | UltraX | ReScraper |
|---|---|---|---|---|
| (a) Over-deletion and missed navigation | Presidio County, Texas From Ballotpedia Jump to: navigation, search […] Presidio County, Texas is one of 254 counties in Texas. Website evaluation […] Local ballot measures in Texas A-B AndersonAndrewsAngelinaAransas […] […] | (empty) remove_lines(start=0, end=74) remove_lines(start=75, end=77) | Presidio County, Texas Presidio County, Texas is one of 254 counties in Texas. Website evaluation […] Local ballot measures in Texas A-B AndersonAndrewsAngelinaAransas […] […] | <keep> <extract> rm 1; rm 3-11; rm 22-94 <keep> Presidio County, Texas Presidio County, Texas is one of 254 counties in Texas. Website evaluation The good - The names of all county commissioners are provided. [1] […] The bad - Individual contact information is not provided for the county commissioners. […] |
| (b) Valueless page kept | MySQL Error! MySQL error in file: /engine/classes/mysql.php at line 52 Error Number: 1 The Error returned was: Too many connections SQL query: | (unchanged) untouch_doc() | (unchanged) | <delete> <extract> rm 1 <delete> (no document) |
| (c) Sidebar scraped in place of the article | Trending Trending Stories Coconut oil may be worse than palm oil for the environment […] (four more headlines) Follow Us […] | Coconut oil may be worse than palm oil for the environment […] (five headlines) remove_lines(start=0, end=3) […] | Coconut oil may be worse than palm oil for the environment […] (five headlines) Audra McDonald turns 40: a look back | <keep> <extract> rm 1-30; rm 34; rm 38-56 <keep> Climate change threatens Africa water TSHWANE, South Africa, Nov. 14 (UPI) – Climate change in Africa’s river basins could hamper the continent’s farm transformation efforts […] (the full article) |
| Case | Resiliparse text | ReScraper input (selected lines) | ReScraper |
|---|---|---|---|
| (a) Table cells fused | Summary data for Cessna Citation Sovereign - Country of originFirst flightNo. builtNo. in serviceCrewPassengers USA200222522528 - 12 […] Dimensions for Cessna Citation Sovereign - Length63 ft. 6 in. Wing Span63 ft. 1 in. Height20 ft. 1 in. […] Performance of Cessna Citation Sovereign - Max Speed458 kts Cruise Speed437 kts […] | lid:43 Country of origin First flight No. built No. in service Crew Passengers lid:44 USA 2002 225 225 2 8 - 12 […] lid:49 Length 63 ft. 6 in. lid:50 Wing Span 63 ft. 1 in. lid:51 Height 20 ft. 1 in. […] lid:55 Max Speed 458 kts lid:56 Cruise Speed 437 kts […] | <keep> <extract> rm 1-40; rm 60-95; rm 113-128 <keep> Aircraft Data The Cessna Citation Model 680 Sovereign is a high performance, twin engined medium range business jet. […] Country of origin First flight No. built No. in service Crew Passengers USA 2002 225 225 2 8 - 12 […] Length 63 ft. 6 in. Wing Span 63 ft. 1 in. Height 20 ft. 1 in. […] |
| (b) List dropped | 2.18 Postinstallation Setup and Testing Prev Chapter 2 Installing and Upgrading MySQL Next […] After installing MySQL, there are some items that you should address. For example: Prev Up Next 2.17.5 Compiling and Linking an Optimized mysqld Server Home 2.18.1 Unix Postinstallation Procedures | lid:7 After installing MySQL, there are some items that you should address. For example: lid:8 - You should initialize the data directory and create the MySQL grant tables, as describe in Section 2.18.1, “Unix Postinstallation Procedures” . lid:9 - An important security concern is that the initial accounts in the grant tables have no passwords. […] lid:10 – lid:12 (three more items) lid:13 Prev Up Next | <keep> <extract> rm 1-2; rm 13-14 <keep> 2.18 Postinstallation Setup and Testing […] After installing MySQL, there are some items that you should address. For example: - You should initialize the data directory and create the MySQL grant tables, […] - An important security concern is that the initial accounts in the grant tables have no passwords. […] (three more items) |
| Case | Line-numbered input | ReScraper program | Executed text |
|---|---|---|---|
| (a) <edit> | lid:1 Moncton Home Price Index for October 2015 lid:2 Moncton, Dieppe, Riverview, Shediac: Real Estate market news, stats, updates, 1st time homebuyer tips and more …. lid:3 – lid:8 (site menu) lid:9 Moncton Home Price Index for October 2015 lid:10 11/18/15 // Home Price Index/#moncton, Home Price Index lid:11 Moncton Home Price Index rose less in October. lid:12 […] lid:13 (click the chart for a larger image or here for the Home Price Index web site) lid:14 – lid:16 […] lid:17 I’ve chosen to focus on the single family home category. […] I hope you find this information interesting. Feel free to email me with your comments or questions. That includes any other local real estate topics. lid:18 Share this: lid:19 – lid:27 (sharing, archive, subscription and copyright lines) | <edit> <extract> rm 2-10 rm 18-27 <edit> rm 13 sub 17: " Feel free to email me with your comments or questions. That includes any other local real estate topics." | Moncton Home Price Index for October 2015 Moncton Home Price Index rose less in October. […] I’ve chosen to focus on the single family home category. […] I hope you find this information interesting. |
| (b) <rewrite> | lid:1 – lid:171 (cookie notice, menus, delivery offers, breadcrumb, share buttons) lid:172 Music since 1939 lid:173 £9.99 lid:174 Product description lid:175 Slim paperback in VGC apart from torn top of spine. lid:176 A well-illustrated (B&W photos) review of British composers and instrumentalists. lid:177 Item details lid:178 Author(s): lid:179 Myers, Rollo H. […] lid:183 14 xs 20.3 cm […] lid:194 – lid:202 (delivery and returns) lid:203 – lid:221 (the product description and item details, repeated) lid:222 – lid:294 (delivery text, footer) | <rewrite> <extract> rm 1-171 rm 194-202 rm 222-294 <rewrite> Music since 1939 £9.99 Product description A slim paperback in VGC, excluding the torn top of the spine, featuring a well-illustrated (B&W photos) review of British composers and instrumentalists. Item details Author(s): Rollo H. Myers […] Dimensions: 14 x 20.3 cm […] | (the text after the second <rewrite> , which replaces the page) |
| Prompt | Section | Model | Input | Decoding |
|---|---|---|---|---|
| Refinement | § D.1 | Qwen3.8-27B | Dripper’s extracted text, without line ids | greedy, thinking disabled, at most input length + 256 tokens |
| Rewriting | § D.2 | RePro-1B | a 7,000-character chunk of the extracted text | temperature 1.0, top- 0.9, at most 2,048 tokens |
| ReScraper | § D.3 | Qwen3-0.6B | line-numbered rendering (§ 3.1 ) | temperature 1.0, top- 1.0, at most 3,072 tokens, thinking disabled |
| Keep-or-drop judge | § D.4 | gpt-oss-120b | the rendered page | temperature 0, low reasoning effort |
| Extraction judge | § D.5 | gpt-oss-120b | the rendered page and one extraction | temperature 0, low reasoning effort |
| Output judge | § D.6 | gpt-oss-120b | the text one pipeline keeps from a page | temperature 0, low reasoning effort |