abhishekgahlot commited on
Commit
6b45f45
·
verified ·
1 Parent(s): 244ab32

OpenJev 1.1: full card, figures, helper and licence files

Browse files
Files changed (4) hide show
  1. README.md +1 -1
  2. helper/SERVE.md +3 -3
  3. helper/compat.py +2 -2
  4. helper/shim.py +2 -1
README.md CHANGED
@@ -164,7 +164,7 @@ READOUT_TARGETED=1 READOUT_INSTR_STYLE=pyrepr SHIM_STAGGER=1 READOUT_REPEAT=1 \
164
  python OpenJev-1.1/helper/compat.py --host 127.0.0.1 --port 3000
165
  ```
166
 
167
- Then `POST /v1/systemone` as in the example at the top. Leave out `READOUT_REPEAT=1` for the faster one-read setting. `curl -s http://127.0.0.1:3000/v1/version` should show `T: 0.85`, `noul_t: 1.829074`, `repeat: true` and a helper SHA-256 beginning `0f04305c`. Keep `--served-model-name qwen` and `--max-logprobs 64`: the helper asks for the option scores under that name. The FP4 command, the 64k window and the security notes for exposing the port are in [`helper/SERVE.md`](helper/SERVE.md).
168
 
169
  ## Formats
170
 
 
164
  python OpenJev-1.1/helper/compat.py --host 127.0.0.1 --port 3000
165
  ```
166
 
167
+ Then `POST /v1/systemone` as in the example at the top. Leave out `READOUT_REPEAT=1` for the faster one-read setting. `curl -s http://127.0.0.1:3000/v1/version` should show `T: 0.85`, `noul_t: 1.829074`, `repeat: true` and a helper SHA-256 beginning `f35b7272`. Keep `--served-model-name qwen` and `--max-logprobs 64`: the helper asks for the option scores under that name. The FP4 command, the 64k window and the security notes for exposing the port are in [`helper/SERVE.md`](helper/SERVE.md).
168
 
169
  ## Formats
170
 
helper/SERVE.md CHANGED
@@ -49,8 +49,8 @@ Three of the flags are load-bearing for the helper, not tuning:
49
  ## 2. Helper
50
 
51
  `helper/` holds two files:
52
- - `shim.py` asks the model and reads the answer from the option scores. Its sha256 is `75fabafbc6a10fcee7fb2b20a131486b7db6953cab52e7650be92b08d784620e`.
53
- - `compat.py` runs in front of it and adds the request features of the hosted Jev API (table on the model card). It imports `shim.py` from its own folder and hands every request it accepts to the helper unchanged, so the answers are the helper's. Its sha256 is `0c935808c9c4dc7c764ff255e6fc8ce59aed71504585953fe2447848baad2bba`.
54
 
55
  Run one of them. With compat in front and read twice on:
56
 
@@ -190,7 +190,7 @@ Response shape (values shown as placeholders; nothing here is a measured number)
190
  }
191
  ```
192
 
193
- The helper's build string has this form: `<model folder name> T=0.85 noul=1.829074,0.0 flags={...} shim=shim.py@75fabafbc6a1`. With read twice on, an answer whose doubled prompt did not fit carries `"read_once": <number of such reads>`.
194
 
195
  `choice` is picked before rounding; probabilities are rounded to 4 decimals. `confidence` for a choice is `(max p - 1/N) / (1 - 1/N)`; for a score it is one minus the expected distance from the most likely level, relative to a uniform answer.
196
 
 
49
  ## 2. Helper
50
 
51
  `helper/` holds two files:
52
+ - `shim.py` asks the model and reads the answer from the option scores. Its sha256 is `f35b7272906e6e3b2a75e05c233b52b412f7d3c533c689b5e3ded593df99ff3f`.
53
+ - `compat.py` runs in front of it and adds the request features of the hosted Jev API (table on the model card). It imports `shim.py` from its own folder and hands every request it accepts to the helper unchanged, so the answers are the helper's. Its sha256 is `1ee46f50925f9a0c74bff014aba690d9e0879ae77ee59ede2b0caa7bb6cfaca7`.
54
 
55
  Run one of them. With compat in front and read twice on:
56
 
 
190
  }
191
  ```
192
 
193
+ The helper's build string has this form: `<model folder name> T=0.85 noul=1.829074,0.0 flags={...} shim=shim.py@f35b7272906e`. With read twice on, an answer whose doubled prompt did not fit carries `"read_once": <number of such reads>`.
194
 
195
  `choice` is picked before rounding; probabilities are rounded to 4 decimals. `confidence` for a choice is `(max p - 1/N) / (1 - 1/N)`; for a score it is one minus the expected distance from the most likely level, relative to a uniform answer.
196
 
helper/compat.py CHANGED
@@ -17,7 +17,7 @@ changes. Added here:
17
  connection on these).
18
  Run exactly like shim.py, from the same folder (or with PYTHONPATH=<the helper's folder>): VLLM=http://localhost:8000/v1 python compat.py --port 8765
19
  NOT YET CHECKED ON A GPU: the default-instruction prompt and the image mapping are shapes the model was neither trained nor measured on."""
20
- import argparse, base64, email.message, email.parser, email.policy, io, json, os, time, zlib
21
 
22
  import shim as S
23
 
@@ -124,7 +124,7 @@ def read_part(piece):
124
  end = piece.find(b"\r\n\r\n", 0, 2 + MAX_PART_HEADER + 4) # the blank line after the header block
125
  if not piece.startswith(b"\r\n") or end < 0 or not piece.endswith(b"\r\n"):
126
  raise ApiError(400, f"a multipart part is a line break, at most {MAX_PART_HEADER} bytes of headers, a blank line, its content and a line break")
127
- headers = email.parser.BytesHeaderParser(policy=email.policy.HTTP).parsebytes(piece[2:end])
128
  return headers.get_param("name", header="content-disposition"), piece[end + 4:-2]
129
 
130
 
 
17
  connection on these).
18
  Run exactly like shim.py, from the same folder (or with PYTHONPATH=<the helper's folder>): VLLM=http://localhost:8000/v1 python compat.py --port 8765
19
  NOT YET CHECKED ON A GPU: the default-instruction prompt and the image mapping are shapes the model was neither trained nor measured on."""
20
+ import argparse, base64, email.message, email.parser, io, json, os, time, zlib
21
 
22
  import shim as S
23
 
 
124
  end = piece.find(b"\r\n\r\n", 0, 2 + MAX_PART_HEADER + 4) # the blank line after the header block
125
  if not piece.startswith(b"\r\n") or end < 0 or not piece.endswith(b"\r\n"):
126
  raise ApiError(400, f"a multipart part is a line break, at most {MAX_PART_HEADER} bytes of headers, a blank line, its content and a line break")
127
+ headers = email.parser.BytesHeaderParser().parsebytes(piece[2:end]) # compat32: the HTTP policy raised on hostile headers
128
  return headers.get_param("name", header="content-disposition"), piece[end + 4:-2]
129
 
130
 
helper/shim.py CHANGED
@@ -141,7 +141,8 @@ _reads = threading.local() # per answering thread: reads of the current questio
141
  def _twice(state_text, prompt):
142
  """READOUT_REPEAT: the user turn twice when the doubled prompt fits the window, else once and counted"""
143
  twice = prompt + "\n\n" + prompt
144
- if _prompt_tokens((SYS if _sys(state_text) else []) + [{"role": "user", "content": twice}]) + 1 <= WINDOW: return twice
 
145
  _reads.once = getattr(_reads, "once", 0) + 1
146
  return prompt
147
 
 
141
  def _twice(state_text, prompt):
142
  """READOUT_REPEAT: the user turn twice when the doubled prompt fits the window, else once and counted"""
143
  twice = prompt + "\n\n" + prompt
144
+ # over 128 characters per token of the window it cannot fit (no token is that long), so it is never tokenized: a huge state costs nothing here
145
+ if len(twice) <= WINDOW * 128 and _prompt_tokens((SYS if _sys(state_text) else []) + [{"role": "user", "content": twice}]) + 1 <= WINDOW: return twice
146
  _reads.once = getattr(_reads, "once", 0) + 1
147
  return prompt
148