kv-bisect 1.2.0__py3-none-any.whl

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.
kv_bisect/__init__.py ADDED
@@ -0,0 +1,62 @@
1
+ """kv-bisect: Prefix-cache-preserving `git bisect` for RAG passages, tool logs, and long LLM prompts."""
2
+
3
+ from .algorithms import (
4
+ bisect,
5
+ ddmin,
6
+ enumerate_witnesses,
7
+ fifo_jointcore,
8
+ full_loo,
9
+ iterative_loo,
10
+ linear_prefix,
11
+ polish_right_to_left,
12
+ right_dfs_jointcore,
13
+ seal_standalone,
14
+ )
15
+ from .hf import HuggingFaceKVOracle
16
+ from .oracle import (
17
+ BaseOracle,
18
+ FunctionOracle,
19
+ OpenAICompatibleOracle,
20
+ StepCallback,
21
+ TruthTableOracle,
22
+ longest_common_prefix,
23
+ longest_contiguous_prefix,
24
+ )
25
+ from .types import (
26
+ BisectResult,
27
+ ProbeStep,
28
+ SearchMode,
29
+ StandaloneMode,
30
+ TokenStats,
31
+ format_indexed_chunks,
32
+ )
33
+
34
+ __version__ = "1.2.0"
35
+
36
+ __all__ = [
37
+ "__version__",
38
+ "BisectResult",
39
+ "ProbeStep",
40
+ "SearchMode",
41
+ "StandaloneMode",
42
+ "StepCallback",
43
+ "TokenStats",
44
+ "format_indexed_chunks",
45
+ "BaseOracle",
46
+ "FunctionOracle",
47
+ "TruthTableOracle",
48
+ "OpenAICompatibleOracle",
49
+ "HuggingFaceKVOracle",
50
+ "bisect",
51
+ "enumerate_witnesses",
52
+ "polish_right_to_left",
53
+ "seal_standalone",
54
+ "full_loo",
55
+ "iterative_loo",
56
+ "linear_prefix",
57
+ "ddmin",
58
+ "fifo_jointcore",
59
+ "right_dfs_jointcore",
60
+ "longest_common_prefix",
61
+ "longest_contiguous_prefix",
62
+ ]
kv_bisect/__main__.py ADDED
@@ -0,0 +1,5 @@
1
+ import sys
2
+ from .cli import main
3
+
4
+ if __name__ == "__main__":
5
+ sys.exit(main())
@@ -0,0 +1,85 @@
1
+ {
2
+ "format": "kv-bisect/rag-chat-v1",
3
+ "request": {
4
+ "model": "Qwen/Qwen2.5-0.5B-Instruct",
5
+ "messages": [
6
+ {
7
+ "role": "system",
8
+ "content": "Use the supplied passages. Answer with a short exact answer only. If there is no supporting passage, answer UNKNOWN."
9
+ },
10
+ {
11
+ "role": "user",
12
+ "content": "[Document 1]\nIn 1870, Tesla moved to Karlovac, to attend school at the Higher Real Gymnasium, where he was profoundly influenced by a math teacher Martin Sekuli\u0107.:32 The classes were held in German, as it was a school within the Austro-Hungarian Military Frontier. Tesla was able to perform integral calculus in his head, which prompted his teachers to believe that he was cheating. He finished a four-year term in three years, graduating in 1873.:33\n\n[Document 2]\nIn 1873, Tesla returned to his birthtown, Smiljan. Shortly after he arrived, Tesla contracted cholera; he was bedridden for nine months and was near death multiple times. Tesla's father, in a moment of despair, promised to send him to the best engineering school if he recovered from the illness (his father had originally wanted him to enter the priesthood).\n\n[Document 3]\nIn 1874, Tesla evaded being drafted into the Austro-Hungarian Army in Smiljan by running away to Tomingaj, near Gra\u010dac. There, he explored the mountains in hunter's garb. Tesla said that this contact with nature made him stronger, both physically and mentally. He read many books while in Tomingaj, and later said that Mark Twain's works had helped him to miraculously recover from his earlier illness.\n\n[Document 4]\nIn 1875, Tesla enrolled at Austrian Polytechnic in Graz, Austria, on a Military Frontier scholarship. During his first year, Tesla never missed a lecture, earned the highest grades possible, passed nine exams (nearly twice as many required), started a Serbian culture club, and even received a letter of commendation from the dean of the technical faculty to his father, which stated, \"Your son is a star of first rank.\" Tesla claimed that he worked from 3 a.m. to 11 p.m., no Sundays or holidays excepted. He was \"mortified when [his] father made light of [those] hard won honors.\" After his father's death in 1879, Tesla found a package of letters from his professors to his father, warning that unless he were removed from the school, Tesla would be killed through overwork. During his second year, Tesla came into conflict with Professor Poeschl over the Gramme dynamo, when Tesla suggested that commutators weren't necessary. At the end of his second year, Tesla lost his scholarship and became addicted to gambling. During his third year, Tesla gambled away his allowance and his tuition money, later gambling back his initial losses and returning the balance to his family. Tesla said that he \"conquered [his] passion then and there,\" but later he was known to play billiards in the US. When exam time came, Tesla was unprepared and asked for an extension to study, but was denied. He never graduated from the university and did not receive grades for the last semester.\n\nQuestion: What year did Tesla avade the draft? "
13
+ }
14
+ ],
15
+ "temperature": 0,
16
+ "max_tokens": 24
17
+ },
18
+ "passages": [
19
+ "[Document 1]\nIn 1870, Tesla moved to Karlovac, to attend school at the Higher Real Gymnasium, where he was profoundly influenced by a math teacher Martin Sekuli\u0107.:32 The classes were held in German, as it was a school within the Austro-Hungarian Military Frontier. Tesla was able to perform integral calculus in his head, which prompted his teachers to believe that he was cheating. He finished a four-year term in three years, graduating in 1873.:33\n\n",
20
+ "[Document 2]\nIn 1873, Tesla returned to his birthtown, Smiljan. Shortly after he arrived, Tesla contracted cholera; he was bedridden for nine months and was near death multiple times. Tesla's father, in a moment of despair, promised to send him to the best engineering school if he recovered from the illness (his father had originally wanted him to enter the priesthood).\n\n",
21
+ "[Document 3]\nIn 1874, Tesla evaded being drafted into the Austro-Hungarian Army in Smiljan by running away to Tomingaj, near Gra\u010dac. There, he explored the mountains in hunter's garb. Tesla said that this contact with nature made him stronger, both physically and mentally. He read many books while in Tomingaj, and later said that Mark Twain's works had helped him to miraculously recover from his earlier illness.\n\n",
22
+ "[Document 4]\nIn 1875, Tesla enrolled at Austrian Polytechnic in Graz, Austria, on a Military Frontier scholarship. During his first year, Tesla never missed a lecture, earned the highest grades possible, passed nine exams (nearly twice as many required), started a Serbian culture club, and even received a letter of commendation from the dean of the technical faculty to his father, which stated, \"Your son is a star of first rank.\" Tesla claimed that he worked from 3 a.m. to 11 p.m., no Sundays or holidays excepted. He was \"mortified when [his] father made light of [those] hard won honors.\" After his father's death in 1879, Tesla found a package of letters from his professors to his father, warning that unless he were removed from the school, Tesla would be killed through overwork. During his second year, Tesla came into conflict with Professor Poeschl over the Gramme dynamo, when Tesla suggested that commutators weren't necessary. At the end of his second year, Tesla lost his scholarship and became addicted to gambling. During his third year, Tesla gambled away his allowance and his tuition money, later gambling back his initial losses and returning the balance to his family. Tesla said that he \"conquered [his] passion then and there,\" but later he was known to play billiards in the US. When exam time came, Tesla was unprepared and asked for an extension to study, but was denied. He never graduated from the university and did not receive grades for the last semester.\n\n"
23
+ ],
24
+ "message_index": 1,
25
+ "wrong_answer": "1879",
26
+ "indices": [
27
+ 3
28
+ ],
29
+ "diagnosis": {
30
+ "status": "diagnosed",
31
+ "original_count": 4,
32
+ "full_reproduces": true,
33
+ "empty_reproduces": false,
34
+ "witnesses": [
35
+ [
36
+ 3
37
+ ]
38
+ ],
39
+ "witnesses_complete": true,
40
+ "witness_guarantee": "inclusion_minimal",
41
+ "full_deletions": [
42
+ {
43
+ "index": 0,
44
+ "reproduces": false,
45
+ "answer": "1874"
46
+ },
47
+ {
48
+ "index": 1,
49
+ "reproduces": false,
50
+ "answer": "1874"
51
+ },
52
+ {
53
+ "index": 2,
54
+ "reproduces": true,
55
+ "answer": "1879"
56
+ },
57
+ {
58
+ "index": 3,
59
+ "reproduces": false,
60
+ "answer": "1874"
61
+ }
62
+ ],
63
+ "clearing_indices": [
64
+ 0,
65
+ 1,
66
+ 3
67
+ ],
68
+ "full_deletions_complete": true,
69
+ "exhaustive": true,
70
+ "calls": 16,
71
+ "max_calls": 126,
72
+ "budget_exhausted": false,
73
+ "full_answer": "1879"
74
+ },
75
+ "verification": {
76
+ "full": [
77
+ "1879"
78
+ ],
79
+ "reduced": [
80
+ "1879"
81
+ ]
82
+ },
83
+ "calls": 18,
84
+ "max_calls": 128
85
+ }
@@ -0,0 +1 @@
1
+ Answer only if all parts of the question are supported by the same piece of evidence. Check the actor and the action. If the evidence is insufficient, answer UNKNOWN. Never infer an unstated answer. Give just the answer.
@@ -0,0 +1,24 @@
1
+ {
2
+ "article": "Nikola_Tesla",
3
+ "paragraphs": [
4
+ 6,
5
+ 7,
6
+ 8,
7
+ 9
8
+ ],
9
+ "dataset": "SQuAD 1.1 dev, CC BY-SA 4.0, Rajpurkar et al.",
10
+ "data_url": "https://rajpurkar.github.io/SQuAD-explorer/dataset/dev-v1.1.json",
11
+ "license_url": "https://creativecommons.org/licenses/by-sa/4.0/",
12
+ "changes": "Four original passages were wrapped in numbered document labels. The question retains its original spelling.",
13
+ "model_revision": "7ae557604adf67be50417f59c2c2f167def9a775",
14
+ "hardware": "NVIDIA GeForce RTX 4060 Laptop GPU",
15
+ "transformers": "4.44.0",
16
+ "prompt_selection": "Five proposed system prompts were tried on this question before selecting fix.txt. This is a regression fixture for one case.",
17
+ "question": "What year did Tesla avade the draft? ",
18
+ "id": "56dfa3394a1a83140091ebff",
19
+ "gold": [
20
+ "1874",
21
+ "1874",
22
+ "1874"
23
+ ]
24
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "format": "kv-bisect/suite-v1",
3
+ "cases": [
4
+ {"name": "Tesla / original prompt reproduces the reported year", "bundle": "case.json", "expect_answer": "1879"},
5
+ {"name": "Tesla / revised prompt answers or abstains", "bundle": "case.json", "system_prompt_file": "fix.txt", "expect_answer": "1874", "reduced_answer": "UNKNOWN"}
6
+ ]
7
+ }