AlJohri commited on
Commit
d1c48ab
·
verified ·
1 Parent(s): 4a62495

Add ONNX export (onnx/model.onnx) and model-card section

Browse files

Adds a single-file ONNX export of the model under `onnx/model.onnx` (~436 MB) for inference with ONNX Runtime, plus an 'ONNX' section on the model card documenting the input/output contract and how a term's impact is recovered.

The file was produced with the export script proposed in the companion PR basnetsoyuj/DeeperImpact#17 (`src/deep_impact/scripts/export_onnx.py`) and verified to match the PyTorch model within max |diff| ~ 6e-6 over a padded batch of documents.

Files changed (2) hide show
  1. README.md +13 -0
  2. onnx/model.onnx +3 -0
README.md CHANGED
@@ -31,3 +31,16 @@ python -m src.deep_impact.index \
31
  ```
32
 
33
  It distributes the inference across multiple GPUs in the machine. To manually set the GPUs, use `CUDA_VISIBLE_DEVICES` environment variable.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  ```
32
 
33
  It distributes the inference across multiple GPUs in the machine. To manually set the GPUs, use `CUDA_VISIBLE_DEVICES` environment variable.
34
+
35
+ ## ONNX
36
+
37
+ An ONNX export is available at [`onnx/model.onnx`](onnx/model.onnx) for inference with [ONNX Runtime](https://onnxruntime.ai/) — e.g. from Rust/C++/JS, or from Python without PyTorch.
38
+
39
+ | | names | dtype | shape |
40
+ |--------|------------------------------------------------|---------|----------------|
41
+ | inputs | `input_ids`, `attention_mask`, `token_type_ids` | int64 | `[batch, seq]` |
42
+ | output | `impact_scores` | float32 | `[batch, seq]` |
43
+
44
+ `impact_scores` is a per-subword-token score. A term's impact is the score at its **first** subword token — the same indexing as `DeepImpact.compute_term_impacts` (`##` continuation subwords are skipped; punctuation and terms past the 512-token window are dropped). Batch and sequence axes are dynamic.
45
+
46
+ The file was exported with [`src/deep_impact/scripts/export_onnx.py`](https://github.com/basnetsoyuj/DeeperImpact/blob/master/src/deep_impact/scripts/export_onnx.py) and matches the PyTorch model within `max |diff| ~ 6e-6`.
onnx/model.onnx ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:38cb884a1b7bb3f2dbf969c22219cb5b4eba64b824f0291ea8249baa616fc8a5
3
+ size 435818763