@swapai/core 0.1.0 → 0.2.1
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.
- package/README.md +29 -0
- package/dist/effect.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1126 -193
- package/dist/index.js.map +1 -1
- package/dist/{types-DTbU1MEi.d.ts → types-DkvGbscw.d.ts} +1 -0
- package/package.json +1 -1
- package/python/swapai_worker.py +105 -43
package/README.md
CHANGED
|
@@ -56,6 +56,27 @@ return score;
|
|
|
56
56
|
result immediately and queues storage work. Use `await relevance.flush()` when
|
|
57
57
|
you need to know all accepted examples are durable, such as during shutdown.
|
|
58
58
|
|
|
59
|
+
## Delete one classifier's training data
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
relevance.clearTrainingData();
|
|
63
|
+
await relevance.flush();
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
`clearTrainingData()` is synchronous and makes `isTrained()` return `false`
|
|
67
|
+
immediately. It queues deletion of every retained example and saved model for
|
|
68
|
+
this classifier name. `flush()` resolves after deletion is durable. Other
|
|
69
|
+
classifiers and SwapAI's shared Needle runtime are left intact.
|
|
70
|
+
|
|
71
|
+
A local classification already in progress cannot return an old-epoch result
|
|
72
|
+
after the clear. It falls back to the supplied reference classifier, or rejects
|
|
73
|
+
with `not_trained` when no reference was supplied. Its old-epoch result is not
|
|
74
|
+
retained. Calls made after deletion finishes can build a new training set.
|
|
75
|
+
|
|
76
|
+
If deletion cannot finish, `flush()` rejects and keeps the clear pending. A
|
|
77
|
+
later `flush()` retries it. If the process exits, the next `init()` for that
|
|
78
|
+
classifier finishes the pending deletion before any saved model can be used.
|
|
79
|
+
|
|
59
80
|
## Result types
|
|
60
81
|
|
|
61
82
|
SwapAI supports bounded numbers, booleans, and a closed list of strings:
|
|
@@ -74,6 +95,14 @@ init({
|
|
|
74
95
|
|
|
75
96
|
The string result is inferred as `"rabbit" | "fish" | "pig"`.
|
|
76
97
|
|
|
98
|
+
Needle is a classifier, not a regression engine. For bounded numbers, SwapAI
|
|
99
|
+
converts reference scores into a small, closed set of internal labels, then
|
|
100
|
+
converts the selected label back to a number. When the training set contains
|
|
101
|
+
only a few scores, those scores stay exact. Larger score sets are quantized to
|
|
102
|
+
a bounded set based on `acceptableError`. The held-out test still compares the
|
|
103
|
+
decoded number with the original reference score, so quantization consumes the
|
|
104
|
+
same error budget and cannot bypass the accuracy gate.
|
|
105
|
+
|
|
77
106
|
## Effect
|
|
78
107
|
|
|
79
108
|
Effect is optional and lives in a separate import:
|
package/dist/effect.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect } from 'effect';
|
|
2
|
-
import { R as ResultValue, C as Classifier, S as SwapAIError } from './types-
|
|
2
|
+
import { R as ResultValue, C as Classifier, S as SwapAIError } from './types-DkvGbscw.js';
|
|
3
3
|
|
|
4
4
|
declare function classify<Result extends ResultValue>(classifier: Classifier<Result>, input: string): Effect.Effect<Result, SwapAIError>;
|
|
5
5
|
declare function classifyWithReference<Result extends ResultValue, ReferenceError, Requirements>(classifier: Classifier<Result>, input: string, reference: (input: string) => Effect.Effect<Result, ReferenceError, Requirements>): Effect.Effect<Result, SwapAIError | ReferenceError, Requirements>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as ResultConfig, I as InitConfig, C as Classifier, b as ResultFor } from './types-
|
|
2
|
-
export { B as BooleanResultConfig, N as NormalizedInitConfig, c as NumberResultConfig, d as ReferenceClassifier, e as ResultComparison, R as ResultValue, f as StringResultConfig, S as SwapAIError } from './types-
|
|
1
|
+
import { a as ResultConfig, I as InitConfig, C as Classifier, b as ResultFor } from './types-DkvGbscw.js';
|
|
2
|
+
export { B as BooleanResultConfig, N as NormalizedInitConfig, c as NumberResultConfig, d as ReferenceClassifier, e as ResultComparison, R as ResultValue, f as StringResultConfig, S as SwapAIError } from './types-DkvGbscw.js';
|
|
3
3
|
|
|
4
4
|
declare function init<const Config extends ResultConfig>(inputConfig: InitConfig<Config>): Classifier<ResultFor<Config>>;
|
|
5
5
|
|