vera-s1 0.1.2__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.
- vera_s1-0.1.2/PKG-INFO +57 -0
- vera_s1-0.1.2/README.md +42 -0
- vera_s1-0.1.2/pyproject.toml +25 -0
- vera_s1-0.1.2/setup.cfg +4 -0
- vera_s1-0.1.2/vera/__init__.py +47 -0
- vera_s1-0.1.2/vera/model.py +831 -0
- vera_s1-0.1.2/vera/schema.py +117 -0
- vera_s1-0.1.2/vera/serve.py +300 -0
- vera_s1-0.1.2/vera_s1.egg-info/PKG-INFO +57 -0
- vera_s1-0.1.2/vera_s1.egg-info/SOURCES.txt +12 -0
- vera_s1-0.1.2/vera_s1.egg-info/dependency_links.txt +1 -0
- vera_s1-0.1.2/vera_s1.egg-info/entry_points.txt +2 -0
- vera_s1-0.1.2/vera_s1.egg-info/requires.txt +6 -0
- vera_s1-0.1.2/vera_s1.egg-info/top_level.txt +1 -0
vera_s1-0.1.2/PKG-INFO
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vera-s1
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: vera-spark and vera-core: calibrated System One decision models
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Project-URL: vera-spark, https://huggingface.co/scar-ai/vera-spark
|
|
7
|
+
Project-URL: vera-core, https://huggingface.co/scar-ai/vera-core
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Requires-Dist: torch>=2.4
|
|
11
|
+
Requires-Dist: transformers>=5.0
|
|
12
|
+
Requires-Dist: huggingface_hub>=0.25
|
|
13
|
+
Provides-Extra: fast
|
|
14
|
+
Requires-Dist: flash-linear-attention; extra == "fast"
|
|
15
|
+
|
|
16
|
+
# vera-s1
|
|
17
|
+
|
|
18
|
+
Python package and Jev-compatible HTTP server for the **vera** System One decision models:
|
|
19
|
+
[vera-spark](https://huggingface.co/scar-ai/vera-spark) (~630M, compact) and
|
|
20
|
+
[vera-core](https://huggingface.co/scar-ai/vera-core) (~2B, most accurate).
|
|
21
|
+
|
|
22
|
+
Give a vera model a state (text or JSON) and typed questions; it returns typed answers with calibrated probabilities
|
|
23
|
+
in one forward pass. It never generates text.
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install vera-s1 # add [fast] for flash-linear-attention (faster vera-core on GPU)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
import vera
|
|
31
|
+
|
|
32
|
+
agent = vera.load("scar-ai/vera-spark") # or "scar-ai/vera-core"
|
|
33
|
+
result = agent.predict(
|
|
34
|
+
"Hi, we were billed twice for March. Please refund the duplicate today or we will cancel our plan.",
|
|
35
|
+
{"department": {"type": "choice", "instructions": "Which department should handle this?",
|
|
36
|
+
"criteria": {"billing": "invoices, payments, refunds", "technical": "bugs, outages",
|
|
37
|
+
"other": "everything else"}},
|
|
38
|
+
"churn_risk": {"type": "noul", "instructions": "Does the user threaten to cancel or leave?"}})
|
|
39
|
+
print(result["answers"])
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Question types: `choice` (2 to 255 options), `score` (2 to 10 ordered levels) and `noul` (yes/no probability).
|
|
43
|
+
|
|
44
|
+
## HTTP server
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
vera-serve --model scar-ai/vera-core --port 8200
|
|
48
|
+
curl -s localhost:8200/v1/systemone -H 'Content-Type: application/json' -d '{
|
|
49
|
+
"state": "I was charged twice. Please fix this ASAP.",
|
|
50
|
+
"questions": {"billing": {"type": "noul", "instructions": "Is this ticket about billing?"}}}'
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Same request and response shape as Jev's `POST /v1/systemone`. Binds `127.0.0.1` by default and has no
|
|
54
|
+
authentication: put it behind your own gateway before exposing it.
|
|
55
|
+
|
|
56
|
+
Requires Python 3.10+ and transformers 5+. A GPU (CUDA or ROCm) is recommended; Apple MPS is not supported (CPU is
|
|
57
|
+
used on Macs).
|
vera_s1-0.1.2/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# vera-s1
|
|
2
|
+
|
|
3
|
+
Python package and Jev-compatible HTTP server for the **vera** System One decision models:
|
|
4
|
+
[vera-spark](https://huggingface.co/scar-ai/vera-spark) (~630M, compact) and
|
|
5
|
+
[vera-core](https://huggingface.co/scar-ai/vera-core) (~2B, most accurate).
|
|
6
|
+
|
|
7
|
+
Give a vera model a state (text or JSON) and typed questions; it returns typed answers with calibrated probabilities
|
|
8
|
+
in one forward pass. It never generates text.
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
pip install vera-s1 # add [fast] for flash-linear-attention (faster vera-core on GPU)
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```python
|
|
15
|
+
import vera
|
|
16
|
+
|
|
17
|
+
agent = vera.load("scar-ai/vera-spark") # or "scar-ai/vera-core"
|
|
18
|
+
result = agent.predict(
|
|
19
|
+
"Hi, we were billed twice for March. Please refund the duplicate today or we will cancel our plan.",
|
|
20
|
+
{"department": {"type": "choice", "instructions": "Which department should handle this?",
|
|
21
|
+
"criteria": {"billing": "invoices, payments, refunds", "technical": "bugs, outages",
|
|
22
|
+
"other": "everything else"}},
|
|
23
|
+
"churn_risk": {"type": "noul", "instructions": "Does the user threaten to cancel or leave?"}})
|
|
24
|
+
print(result["answers"])
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Question types: `choice` (2 to 255 options), `score` (2 to 10 ordered levels) and `noul` (yes/no probability).
|
|
28
|
+
|
|
29
|
+
## HTTP server
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
vera-serve --model scar-ai/vera-core --port 8200
|
|
33
|
+
curl -s localhost:8200/v1/systemone -H 'Content-Type: application/json' -d '{
|
|
34
|
+
"state": "I was charged twice. Please fix this ASAP.",
|
|
35
|
+
"questions": {"billing": {"type": "noul", "instructions": "Is this ticket about billing?"}}}'
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Same request and response shape as Jev's `POST /v1/systemone`. Binds `127.0.0.1` by default and has no
|
|
39
|
+
authentication: put it behind your own gateway before exposing it.
|
|
40
|
+
|
|
41
|
+
Requires Python 3.10+ and transformers 5+. A GPU (CUDA or ROCm) is recommended; Apple MPS is not supported (CPU is
|
|
42
|
+
used on Macs).
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "vera-s1"
|
|
7
|
+
version = "0.1.2"
|
|
8
|
+
description = "vera-spark and vera-core: calibrated System One decision models"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "Apache-2.0"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
dependencies = ["torch>=2.4", "transformers>=5.0", "huggingface_hub>=0.25"]
|
|
13
|
+
|
|
14
|
+
[project.optional-dependencies]
|
|
15
|
+
fast = ["flash-linear-attention"]
|
|
16
|
+
|
|
17
|
+
[project.urls]
|
|
18
|
+
"vera-spark" = "https://huggingface.co/scar-ai/vera-spark"
|
|
19
|
+
"vera-core" = "https://huggingface.co/scar-ai/vera-core"
|
|
20
|
+
|
|
21
|
+
[project.scripts]
|
|
22
|
+
vera-serve = "vera.serve:main"
|
|
23
|
+
|
|
24
|
+
[tool.setuptools]
|
|
25
|
+
packages = ["vera"]
|
vera_s1-0.1.2/setup.cfg
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""vera: calibrated System One decision models (vera-spark, vera-core).
|
|
2
|
+
|
|
3
|
+
import vera
|
|
4
|
+
agent = vera.load("scar-ai/vera-spark")
|
|
5
|
+
result = agent.predict(state, questions)
|
|
6
|
+
"""
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
|
|
11
|
+
__version__ = "0.1.2"
|
|
12
|
+
__all__ = ["load", "Agent"]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class Agent:
|
|
16
|
+
"""A loaded model. `predict` answers every question in one forward pass."""
|
|
17
|
+
|
|
18
|
+
def __init__(self, pred):
|
|
19
|
+
self.pred = pred
|
|
20
|
+
|
|
21
|
+
@property
|
|
22
|
+
def name(self) -> str:
|
|
23
|
+
return self.pred.name
|
|
24
|
+
|
|
25
|
+
@property
|
|
26
|
+
def device(self) -> str:
|
|
27
|
+
return self.pred.device
|
|
28
|
+
|
|
29
|
+
def predict(self, state, questions: dict) -> dict:
|
|
30
|
+
"""state: text or any JSON-serialisable object. questions: {id: {"type": "choice"|"score"|"noul", ...}}.
|
|
31
|
+
Returns {"model", "answers": {id: {...}}, "usage"} (the same shape as POST /v1/systemone)."""
|
|
32
|
+
return self.pred.answer({"state": state, "questions": questions})
|
|
33
|
+
|
|
34
|
+
__call__ = predict
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def load(model: str = "scar-ai/vera-spark", device: str | None = None, max_len: int | None = None,
|
|
38
|
+
token: str | None = None, revision: str | None = None) -> Agent:
|
|
39
|
+
"""Load a vera model from a Hub repo id (downloaded once and cached) or a local directory.
|
|
40
|
+
device: "cuda" or "cpu"; default is CUDA when available, else CPU."""
|
|
41
|
+
os.environ.setdefault("USE_TF", "0") # transformers' TensorFlow probe can hang model construction
|
|
42
|
+
if not os.path.isdir(model):
|
|
43
|
+
from huggingface_hub import snapshot_download
|
|
44
|
+
model = snapshot_download(model, token=token, revision=revision,
|
|
45
|
+
allow_patterns=["model.pt", "arch.json", "tokenizer*", "chat_template.jinja"])
|
|
46
|
+
from .serve import Predictor
|
|
47
|
+
return Agent(Predictor(model, device=device, max_len=max_len))
|