Instructions to use dizyann/crivo-web with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use dizyann/crivo-web with Transformers.js:
// ⚠️ Unknown pipeline tag
Download scripts/conversion/browser.ts from dizyann/crivo-web: direct link, hf CLI and curl.
- Browser
- Download file 1.63 kB
-
https://huggingface.co/dizyann/crivo-web/resolve/main/scripts/conversion/browser.ts
- Command line
-
hf download hf://dizyann/crivo-web/scripts/conversion/browser.ts
-
curl -L -o browser.ts https://huggingface.co/dizyann/crivo-web/resolve/main/scripts/conversion/browser.ts
1.63 kB
| /** Browser parity harness. Serve /models/<size>/ from .cache/variants with CORS. */ | |
| import { env } from '@huggingface/transformers' | |
| import { Crivo, type Question } from '../../src/decisions/adapters/crivo.js' | |
| env.allowRemoteModels = false | |
| env.allowLocalModels = true | |
| env.localModelPath = `${self.location.origin}/models/` | |
| self.onmessage = async ({ data }) => { | |
| const { size, dtype, device } = data | |
| let model: Crivo | undefined | |
| try { | |
| const fixture = await (await fetch(`/models/${size}/parity.json`)).json() | |
| model = await Crivo.load({ modelId: size, dtype, device }) | |
| let maxError = 0 | |
| for (const sample of fixture.cases) { | |
| const answers = await model.answerMany( | |
| sample.state, | |
| sample.questions.map((question: Question) => ({ question })) | |
| ) | |
| for (const [i, answer] of answers.entries()) { | |
| const expected: number[] = sample[dtype === 'q8' ? 'int8' : 'fp32'][i] | |
| const actual = | |
| answer.type === 'noul' | |
| ? [1 - answer.noul, answer.noul] | |
| : Object.values(answer.probabilities) | |
| for (const [j, value] of actual.entries()) { | |
| const delta = Math.abs(value - (expected[j] ?? Number.NaN)) | |
| if (!Number.isFinite(delta)) throw new Error('Nonfinite output') | |
| maxError = Math.max(maxError, delta) | |
| } | |
| } | |
| } | |
| if (dtype === 'fp32' && maxError > 1e-4) throw new Error(`FP32 parity failed: ${maxError}`) | |
| self.postMessage({ size, dtype, device, maxError }) | |
| } catch (error) { | |
| self.postMessage({ size, dtype, device, error: String(error) }) | |
| } finally { | |
| await model?.dispose() | |
| } | |
| } | |