bestofn 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
bestofn-1.0.0/LICENSE ADDED
@@ -0,0 +1,216 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
203
+
204
+ Copyright 2026 Alejandro Areces Rivera - Interlace AI
205
+
206
+ Licensed under the Apache License, Version 2.0 (the "License");
207
+ you may not use this file except in compliance with the License.
208
+ You may obtain a copy of the License at
209
+
210
+ http://www.apache.org/licenses/LICENSE-2.0
211
+
212
+ Unless required by applicable law or agreed to in writing, software
213
+ distributed under the License is distributed on an "AS IS" BASIS,
214
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
215
+ See the License for the specific language governing permissions and
216
+ limitations under the License.
bestofn-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,351 @@
1
+ Metadata-Version: 2.4
2
+ Name: bestofn
3
+ Version: 1.0.0
4
+ Summary: Inference-time compute for language models: sample N reasoning trajectories and select the best.
5
+ Author-email: Alejandro Areces Rivera <interlaceIA@gmail.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://huggingface.co/InterlaceAI/best-of-n
8
+ Project-URL: Source, https://github.com/voidlinestudios12-jpg/Interlace-AI/tree/main/best-of-n
9
+ Project-URL: Documentation, https://github.com/voidlinestudios12-jpg/Interlace-AI/blob/main/best-of-n/USAGE.md
10
+ Project-URL: Paper, https://doi.org/10.5281/zenodo.21936833
11
+ Project-URL: Issues, https://github.com/voidlinestudios12-jpg/Interlace-AI/issues
12
+ Keywords: llm,best-of-n,inference-time-compute,test-time-compute,reasoning,verifier,self-consistency,majority-voting
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.8
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Provides-Extra: transformers
30
+ Requires-Dist: torch; extra == "transformers"
31
+ Requires-Dist: transformers; extra == "transformers"
32
+ Provides-Extra: vllm
33
+ Requires-Dist: vllm; extra == "vllm"
34
+ Dynamic: license-file
35
+
36
+ <div align="center">
37
+
38
+ <img src="https://huggingface.co/InterlaceAI/best-of-n/resolve/main/figures/interlace-logo.png" width="96" alt="Interlace AI">
39
+
40
+ **INTERLACE&nbsp;AI**
41
+
42
+ # Best-of-N
43
+
44
+ ### Inference-time compute for any language model
45
+
46
+ **Sample N reasoning trajectories from a frozen model and select the best one.**
47
+ No weights are modified. All gains come from *how* the model is used.
48
+
49
+ Works with **any causal LM** and **any N** — you configure both.
50
+
51
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.21936833.svg)](https://doi.org/10.5281/zenodo.21936833)
52
+ [![License](https://img.shields.io/badge/license-Apache%202.0-green)](https://github.com/voidlinestudios12-jpg/Interlace-AI/blob/main/best-of-n/../LICENSE)
53
+ [![Tests](https://img.shields.io/badge/tests-45%20passing-brightgreen)](https://github.com/voidlinestudios12-jpg/Interlace-AI/blob/main/best-of-n/tests/test_selectors.py)
54
+
55
+ </div>
56
+
57
+ ---
58
+
59
+ ## What it does
60
+
61
+ A language model does not produce *an* answer. It produces a **distribution over
62
+ answers**, and generating text draws one sample from it. Ask the same question
63
+ twice at non-zero temperature and you can get two different results.
64
+
65
+ That variability is usually treated as a nuisance. Best-of-N treats it as a
66
+ resource.
67
+
68
+ Suppose a model solves a given problem correctly 30% of the time. Ask once and
69
+ you are right 30% of the time. Ask 32 times and the probability that **at least
70
+ one** attempt is correct is `1 − 0.7³² ≈ 99.99%`. The knowledge is there; a
71
+ single sample just fails to retrieve it reliably.
72
+
73
+ So the problem splits in two:
74
+
75
+ | | |
76
+ |---|---|
77
+ | **Coverage** | Did any of the N attempts get it right? `1 − (1−p)^N` |
78
+ | **Selection** | Did we manage to pick that one out of the N? |
79
+
80
+ This library implements both halves: sampling N trajectories, and four different
81
+ ways of choosing between them.
82
+
83
+ ![A 1.5B model against the field](https://huggingface.co/InterlaceAI/best-of-n/resolve/main/figures/04_vs_other_models.png)
84
+
85
+ Against published results from other laboratories. Ours is majority vote at
86
+ N=128 — the figure a system can actually return; the others are their published
87
+ pass@1. Coverage is shown separately and labelled as a ceiling.
88
+
89
+ ![AIME results](https://huggingface.co/InterlaceAI/best-of-n/resolve/main/figures/01_aime_base_vs_bestofn.png)
90
+
91
+ Measured on `DeepSeek-R1-Distill-Qwen-1.5B`, **AIME 2024**, weights untouched:
92
+
93
+ | N | Majority vote | Coverage (pass@N) |
94
+ |---:|---:|---:|
95
+ | 1 | 23.3% | 23.3% |
96
+ | 8 | 40.0% | 60.0% |
97
+ | 32 | 50.0% | 73.3% |
98
+ | **128** | **53.3%** | **83.3%** |
99
+
100
+ ![Across benchmarks](https://huggingface.co/InterlaceAI/best-of-n/resolve/main/figures/02_three_benchmarks.png)
101
+
102
+ And across domains:
103
+
104
+ | Benchmark | N | Single sample | Majority vote | Δ |
105
+ |---|---:|---:|---:|---:|
106
+ | AIME 2024 | 128 | 23.3% | **53.3%** | +30.0 |
107
+ | GPQA-Diamond | 32 | 33.8% | **43.4%** | +9.6 |
108
+ | GSM8K | 4 | 87.2% | **92.8%** | +5.6 |
109
+
110
+ All three are majority vote — the selector you would actually deploy. AIME
111
+ coverage at N=128 is higher (83.3%) but is a ceiling, not a returnable result.
112
+
113
+ ### How a call works
114
+
115
+ 1. **Generate.** N reasoning trajectories are sampled in parallel from the frozen
116
+ model at `temperature > 0`, so each explores a different path.
117
+ 2. **Extract.** The final answer is pulled out of each trajectory (by default the
118
+ last `oxed{...}`) and normalised, so `"204"`, `"204.0"` and `" 204 "` count
119
+ as the same answer.
120
+ 3. **Select.** A selector decides which answer to return — by frequency, by the
121
+ model's own confidence, or by an external verifier's score.
122
+ 4. **Return.** You get the answer plus every sample, so you can inspect them or
123
+ apply a different selector for free.
124
+
125
+ ---
126
+
127
+ ## Quickstart
128
+
129
+ ```python
130
+ from bestofn import BestOfN
131
+
132
+ engine = BestOfN("deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B", n=32)
133
+
134
+ result = engine.solve("What is the remainder when 7^100 is divided by 13?")
135
+ print(result.answer)
136
+ print(result.agreement) # how much the 32 samples agreed
137
+ ```
138
+
139
+ Any model, any N:
140
+
141
+ ```python
142
+ BestOfN("Qwen/Qwen2.5-Math-7B-Instruct", n=64)
143
+ BestOfN("meta-llama/Llama-3.1-8B-Instruct", n=16)
144
+ BestOfN("/path/to/your/local/model", n=128)
145
+ ```
146
+
147
+ Install:
148
+
149
+ ```bash
150
+ pip install torch transformers
151
+ pip install vllm # recommended; required for large N
152
+ ```
153
+
154
+ ---
155
+
156
+ ## The selection gap
157
+
158
+ Look at the table above again. At N=128 the model **reaches** the right answer
159
+ 83.3% of the time, but majority voting only **returns** it 53.3% of the time.
160
+
161
+ ![The selection gap](https://huggingface.co/InterlaceAI/best-of-n/resolve/main/figures/03_selection_gap.png)
162
+
163
+ That 30-point difference is the **selection gap** — the correct answer was
164
+ generated and then discarded, because it was in the minority.
165
+
166
+ Majority voting cannot fix this: it is structurally incapable of choosing an
167
+ answer most trajectories disagree with. A learned verifier can.
168
+
169
+ | Selector (N=32, 90 AIME problems) | Accuracy |
170
+ |---|---:|
171
+ | Self-certainty | 18.9% |
172
+ | Majority vote | 35.6% |
173
+ | Verifier — argmax trajectory | 43.3% |
174
+ | **Verifier — confidence-weighted vote** | **52.2%** |
175
+
176
+ ```python
177
+ def my_verifier(problem: str, trajectory: str) -> float:
178
+ return probability_it_is_correct # 0.0 – 1.0
179
+
180
+ engine = BestOfN(model, n=32, verifier=my_verifier)
181
+ engine.solve(problem, method="verifier") # +16.6 points over majority
182
+ ```
183
+
184
+ ---
185
+
186
+ ## Selectors
187
+
188
+ | Method | Needs | Recovers a minority-correct answer? |
189
+ |---|---|:---:|
190
+ | `majority` | nothing | No |
191
+ | `self_certainty` | log-probs (automatic) | Rarely |
192
+ | `verifier` | a verifier callable | **Yes** |
193
+ | `verifier_argmax` | a verifier callable | Yes, but noisier |
194
+ | `oracle` | the gold answer | Diagnostic ceiling only |
195
+
196
+ Generation is the expensive part — reusing the samples with another selector is free:
197
+
198
+ ```python
199
+ r = engine.solve(problem, n=32)
200
+ r.answer # majority
201
+ r.select_with("self_certainty")
202
+ r.covered(gold) # was the answer reachable at all? (pass@N)
203
+ ```
204
+
205
+ ---
206
+
207
+ ## Configuration
208
+
209
+ ```python
210
+ BestOfN(
211
+ model="deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B",
212
+ n=32, # your compute budget
213
+ temperature=0.6, # must be > 0
214
+ top_p=0.95,
215
+ max_tokens=8192,
216
+ extractor="boxed", # boxed | number | letter | regex | your callable
217
+ backend="auto", # auto | vllm | transformers
218
+ verifier=None,
219
+ )
220
+ ```
221
+
222
+ **Full documentation: [USAGE.md](https://github.com/voidlinestudios12-jpg/Interlace-AI/blob/main/best-of-n/USAGE.md)** — how to choose N, how to plug in a
223
+ verifier, how to measure the selection gap on your own task, and the failure
224
+ modes worth knowing about.
225
+
226
+ ---
227
+
228
+ ## Verification
229
+
230
+ The published numbers are not asserted, they are replayed. This repository ships
231
+ the trajectories that produced them and a script that feeds them back through
232
+ the library:
233
+
234
+ ```bash
235
+ python tests/verify_against_measured.py
236
+ ```
237
+
238
+ ```
239
+ Samples per problem (N) : 32
240
+ majority selection reproduced : 30/30 (100.0%)
241
+ majority vote, this library : 63.3% [recorded run: 63.3%]
242
+ coverage pass@32 : 76.7%
243
+ gain from Best-of-N : +31.7 points
244
+ PASS - reproduces the published measurements exactly
245
+ ```
246
+
247
+ > **Why 63.3% here and 53.3% in the tables above?** They are two independent runs
248
+ > of the same benchmark. AIME has only 30 problems, so a single run carries a
249
+ > standard error of roughly 9 points; our two runs differ by 13 points at N=32
250
+ > (63.3% vs 50.0%). The tables quote the **more conservative** run. This script
251
+ > replays the other one, which is the set of trajectories shipped in `tests/`.
252
+ > Both are real measurements — the spread is what a 30-problem benchmark looks
253
+ > like, and it is worth knowing before comparing any single AIME figure against
254
+ > another lab'"'"'s.
255
+
256
+ Plus 45 unit tests covering extraction, normalisation, every selector, the
257
+ minority-rescue mechanism and error handling — no GPU required:
258
+
259
+ ```bash
260
+ python tests/test_selectors.py # 45 passed, 0 failed
261
+ ```
262
+
263
+ ---
264
+
265
+ ## When this helps, and when it does not
266
+
267
+ **Good fit**
268
+
269
+ - Problems with a single comparable final answer: maths, multiple choice, short
270
+ factual questions, unit-testable code.
271
+ - A model that is *sometimes* right. The gain is largest when per-sample accuracy
272
+ sits in the middle — around 20–60%.
273
+ - Accuracy matters more than latency, and you can afford N generations.
274
+
275
+ **Poor fit**
276
+
277
+ - Open-ended generation — essays, summaries, chat. There is no well-defined vote
278
+ over free text.
279
+ - Problems the model never solves. If `p = 0`, then `1 − (1−p)^N = 0` for every
280
+ N: sampling more changes nothing.
281
+ - Problems the model always solves. Nothing to recover; you are paying N times
282
+ for the same answer.
283
+ - Hard latency budgets. Cost scales linearly with N.
284
+
285
+ Not sure which case you are in? Measure it:
286
+
287
+ ```python
288
+ results = engine.solve_batch(problems, n=32)
289
+ selected = sum(r.answer == g for r, g in zip(results, golds)) / len(golds)
290
+ reachable = sum(r.covered(g) for r, g in zip(results, golds)) / len(golds)
291
+ print(f"selected {selected:.1%} · reachable {reachable:.1%} · gap {reachable-selected:.1%}")
292
+ ```
293
+
294
+ A large gap means invest in a verifier. Low coverage means you need a better
295
+ base model, not more samples.
296
+
297
+ ---
298
+
299
+ ## Limitations
300
+
301
+ - **Coverage is a hard ceiling.** If the model never generates the correct
302
+ answer, no selector recovers it: `1 − (1−p)^N` is 0 for every N when p = 0.
303
+ - **Cost is linear in N.** N=128 means 128 generations. Use `vllm`.
304
+ - **Needs an extractable answer.** Built for tasks with a comparable final
305
+ answer. Open-ended generation has no well-defined vote.
306
+ - **Verifier errors amplify.** The selector is bounded by its verifier.
307
+
308
+ ---
309
+
310
+ ## Prior work
311
+
312
+ Best-of-N sampling and verifier-based reranking are established techniques. This is an open
313
+ implementation with published measurements, not a new method:
314
+
315
+ - Cobbe et al., *Training Verifiers to Solve Math Word Problems*, 2021 — verifier reranking of N samples
316
+ - Wang et al., *Self-Consistency Improves Chain of Thought Reasoning*, 2022 — majority voting over samples
317
+ - Lightman et al., *Let'''s Verify Step by Step*, 2023 — process vs outcome supervision
318
+ - Snell et al., *Scaling LLM Test-Time Compute Optimally*, 2024 — compute vs parameters
319
+ - Brown et al., *Large Language Monkeys*, 2024 — coverage scaling with repeated sampling
320
+
321
+ Full discussion and references in [the technical report](https://doi.org/10.5281/zenodo.21936833).
322
+
323
+ ---
324
+
325
+ ## Citation
326
+
327
+ ```bibtex
328
+ @techreport{arecesrivera2026interlace,
329
+ title = {Modern Architecture On Advanced LLM: Best-of-N Sampling,
330
+ Learned Verification and Tree Search as a Substitute for Parameter Scale},
331
+ author = {Areces Rivera, Alejandro},
332
+ year = {2026},
333
+ number = {TR-2026-01},
334
+ institution = {Interlace AI},
335
+ doi = {10.5281/zenodo.21936833}
336
+ }
337
+ ```
338
+
339
+ Technical report: [doi.org/10.5281/zenodo.21936833](https://doi.org/10.5281/zenodo.21936833)
340
+ Code and raw outputs: [github.com/.../Interlace-AI/best-of-n](https://github.com/voidlinestudios12-jpg/Interlace-AI/tree/main/best-of-n)
341
+
342
+ ---
343
+
344
+ ## License
345
+
346
+ **Apache License 2.0** — free to use, modify and redistribute, including
347
+ commercially. Use it with any model, at any N, in any project.
348
+
349
+ Copyright 2026 Alejandro Areces Rivera — Interlace AI
350
+
351
+ Questions and collaboration: `interlaceIA@gmail.com`