Spaces:
Running
Running
0.2.1: give reasoning models (gpt-oss) token headroom + low reasoning effort, so grading, preference ranking and ping aren't cut off; wheel rebuilt
Browse files- .gitattributes +1 -0
- README.md +1 -1
- app/curate_api.py +1 -1
- datainventor/llm.py +10 -2
- dist/datainventor-0.2.1-py3-none-any.whl +3 -0
- pyproject.toml +1 -1
.gitattributes
CHANGED
|
@@ -34,3 +34,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
dist/datainventor-0.2.0-py3-none-any.whl filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
dist/datainventor-0.2.0-py3-none-any.whl filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
dist/datainventor-0.2.1-py3-none-any.whl filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -41,7 +41,7 @@ You register Hugging Face datasets as **sources** to curate, and optionally desc
|
|
| 41 |
The hosted run works on about 200 documents per source and returns the kept and created documents with a report. The runner does the same on every document:
|
| 42 |
|
| 43 |
```bash
|
| 44 |
-
pip install 'datainventor[full] @ https://huggingface.co/spaces/codelion/data-inventor/resolve/main/dist/datainventor-0.2.
|
| 45 |
export DI_API_KEY=... # key for the endpoint named in the recipe
|
| 46 |
datainventor init recipe.yaml # or download one from the app
|
| 47 |
datainventor preview recipe.yaml # every step on a sample
|
|
|
|
| 41 |
The hosted run works on about 200 documents per source and returns the kept and created documents with a report. The runner does the same on every document:
|
| 42 |
|
| 43 |
```bash
|
| 44 |
+
pip install 'datainventor[full] @ https://huggingface.co/spaces/codelion/data-inventor/resolve/main/dist/datainventor-0.2.1-py3-none-any.whl'
|
| 45 |
export DI_API_KEY=... # key for the endpoint named in the recipe
|
| 46 |
datainventor init recipe.yaml # or download one from the app
|
| 47 |
datainventor preview recipe.yaml # every step on a sample
|
app/curate_api.py
CHANGED
|
@@ -23,7 +23,7 @@ PER_SOURCE = int(os.environ.get("CURATE_PER_SOURCE", "200"))
|
|
| 23 |
GRADE_N = int(os.environ.get("CURATE_GRADE", "48"))
|
| 24 |
REPHRASE_N = int(os.environ.get("CURATE_REPHRASE", "8"))
|
| 25 |
MAX_SOURCES, MAX_TARGETS = 4, 2
|
| 26 |
-
INSTALL = "pip install 'datainventor[full] @ https://huggingface.co/spaces/codelion/data-inventor/resolve/main/dist/datainventor-0.2.
|
| 27 |
PREVIEWS: dict[str, Preview] = {}
|
| 28 |
TRIES: dict[str, list] = {}
|
| 29 |
GUARD = threading.Lock()
|
|
|
|
| 23 |
GRADE_N = int(os.environ.get("CURATE_GRADE", "48"))
|
| 24 |
REPHRASE_N = int(os.environ.get("CURATE_REPHRASE", "8"))
|
| 25 |
MAX_SOURCES, MAX_TARGETS = 4, 2
|
| 26 |
+
INSTALL = "pip install 'datainventor[full] @ https://huggingface.co/spaces/codelion/data-inventor/resolve/main/dist/datainventor-0.2.1-py3-none-any.whl'"
|
| 27 |
PREVIEWS: dict[str, Preview] = {}
|
| 28 |
TRIES: dict[str, list] = {}
|
| 29 |
GUARD = threading.Lock()
|
datainventor/llm.py
CHANGED
|
@@ -12,6 +12,11 @@ from typing import Callable, Optional
|
|
| 12 |
HF_BASE = "https://router.huggingface.co/v1"
|
| 13 |
HF_MODEL = "openai/gpt-oss-20b:deepinfra"
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
@dataclass
|
| 17 |
class Endpoint:
|
|
@@ -23,8 +28,11 @@ class Endpoint:
|
|
| 23 |
|
| 24 |
def chat(self, prompt: str, max_tokens: int = 1500, temperature: float = 0.8, retries: int = 5,
|
| 25 |
validate: Optional[Callable[[str], bool]] = None) -> str:
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
| 28 |
if self.disable_thinking:
|
| 29 |
body["chat_template_kwargs"] = {"enable_thinking": False}
|
| 30 |
data = json.dumps(body).encode()
|
|
|
|
| 12 |
HF_BASE = "https://router.huggingface.co/v1"
|
| 13 |
HF_MODEL = "openai/gpt-oss-20b:deepinfra"
|
| 14 |
|
| 15 |
+
# Reasoning models spend completion tokens thinking before the answer, so a call that asks for
|
| 16 |
+
# an 8-token label would be cut off. They get this many extra tokens on top of the answer budget.
|
| 17 |
+
REASONING_HEADROOM = 1536
|
| 18 |
+
_REASONING = re.compile(r"gpt-oss|deepseek-r1|qwq|:think\b", re.I)
|
| 19 |
+
|
| 20 |
|
| 21 |
@dataclass
|
| 22 |
class Endpoint:
|
|
|
|
| 28 |
|
| 29 |
def chat(self, prompt: str, max_tokens: int = 1500, temperature: float = 0.8, retries: int = 5,
|
| 30 |
validate: Optional[Callable[[str], bool]] = None) -> str:
|
| 31 |
+
reasoning = bool(_REASONING.search(self.model)) and not self.disable_thinking
|
| 32 |
+
body = {"model": self.model, "max_tokens": max_tokens + (REASONING_HEADROOM if reasoning else 0),
|
| 33 |
+
"temperature": temperature, "messages": [{"role": "user", "content": prompt}]}
|
| 34 |
+
if reasoning and "gpt-oss" in self.model.lower():
|
| 35 |
+
body["reasoning_effort"] = "low"
|
| 36 |
if self.disable_thinking:
|
| 37 |
body["chat_template_kwargs"] = {"enable_thinking": False}
|
| 38 |
data = json.dumps(body).encode()
|
dist/datainventor-0.2.1-py3-none-any.whl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:826c02e165c190f971307c3c4c8e4328e4d49e94d8cfab20f8ca76c99e0fa020
|
| 3 |
+
size 2413973
|
pyproject.toml
CHANGED
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
| 4 |
|
| 5 |
[project]
|
| 6 |
name = "datainventor"
|
| 7 |
-
version = "0.2.
|
| 8 |
description = "Curate a pretraining corpus on your own machines: clean, calibrate, create, compose."
|
| 9 |
readme = "README.md"
|
| 10 |
requires-python = ">=3.10"
|
|
|
|
| 4 |
|
| 5 |
[project]
|
| 6 |
name = "datainventor"
|
| 7 |
+
version = "0.2.1"
|
| 8 |
description = "Curate a pretraining corpus on your own machines: clean, calibrate, create, compose."
|
| 9 |
readme = "README.md"
|
| 10 |
requires-python = ">=3.10"
|