Card: quick start with the idealens package (classify, extract, score)
Browse files
README.md
CHANGED
|
@@ -34,16 +34,25 @@ idealens run docs.jsonl -o scores.jsonl --model IdeaLens-LogisticClassifier-PerI
|
|
| 34 |
|
| 35 |
Input is JSONL with a `text` field per document. To score outlines you already have, use `idealens score outlines.jsonl -o scores.jsonl --model IdeaLens-LogisticClassifier-PerItem`. Score outlines as extracted; the paraphrasing step is only for training data.
|
| 36 |
|
| 37 |
-
In Python:
|
| 38 |
|
| 39 |
```python
|
| 40 |
import idealens as il
|
| 41 |
|
|
|
|
|
|
|
|
|
|
| 42 |
with il.Detector("IdeaLens-LogisticClassifier-PerItem") as det:
|
| 43 |
-
records =
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
```
|
| 46 |
|
|
|
|
|
|
|
| 47 |
## Thresholds
|
| 48 |
|
| 49 |
`thresholds.json` holds this model's cuts at 0.1%, 0.5%, 1%, 2% and 5% false-positive rates, fitted on the 80,000 human
|
|
|
|
| 34 |
|
| 35 |
Input is JSONL with a `text` field per document. To score outlines you already have, use `idealens score outlines.jsonl -o scores.jsonl --model IdeaLens-LogisticClassifier-PerItem`. Score outlines as extracted; the paraphrasing step is only for training data.
|
| 36 |
|
| 37 |
+
In Python, step by step:
|
| 38 |
|
| 39 |
```python
|
| 40 |
import idealens as il
|
| 41 |
|
| 42 |
+
texts = [open("document.txt").read()]
|
| 43 |
+
formats = il.classify(texts) # one of the eight formats per document
|
| 44 |
+
outlines = il.extract(texts, formats) # role-labelled outlines
|
| 45 |
with il.Detector("IdeaLens-LogisticClassifier-PerItem") as det:
|
| 46 |
+
records = det.score_outlines(outlines, format=formats)
|
| 47 |
+
|
| 48 |
+
r = records[0]
|
| 49 |
+
print(r["p_human"], r["verdict"]["ai"]) # P(human); flagged at the 1% global cut?
|
| 50 |
+
print(r["item_p_human"]) # each item's own P(human)
|
| 51 |
+
print(outlines[0].render()) # the outline that was scored
|
| 52 |
```
|
| 53 |
|
| 54 |
+
Or in one call: `records = il.run(texts, det)`. `classify` and `extract` use Gemini 3.7 Flash, the extractor the thresholds were fitted with (`GEMINI_API_KEY`); pass `provider=idealens.providers.make(...)` to use Vertex, OpenAI, Anthropic, OpenRouter or a local server. The [package README](https://github.com/RishanthRajendhran/IdeaLens#ways-to-use-idealens) covers the other ways to run it.
|
| 55 |
+
|
| 56 |
## Thresholds
|
| 57 |
|
| 58 |
`thresholds.json` holds this model's cuts at 0.1%, 0.5%, 1%, 2% and 5% false-positive rates, fitted on the 80,000 human
|