elephant-1-onnx / csharp /README.md
electroglyph's picture
Upload folder using huggingface_hub
fb62ba4 verified
|
Raw History Blame Contribute Delete
1.59 kB

elephant-1 ONNX — C# runner (.NET 10)

Raw onnxruntime runner + demos, a C# port of onnx_raw.py / generate.py. Needs the .NET 10 SDK (gigatoken_cs is net10-only) and a CUDA GPU for --cuda (CPU works without one).

dotnet run -- --model ../model-cuda-int4 --cuda --prompt "What is the capital of France?"
dotnet run -- --model ../model-cuda-int8 --cuda --score-demo
dotnet run -- --model ../model-cuda-int4 --cuda --score-demo
dotnet run -- --model ../model-cpu --score-demo   # CPU build, no GPU needed
dotnet run -- --model ../model-cpu-int8 --score-demo   # most faithful on CPU

Tokenizer: ../orig_tokenizer/tokenizer.json (pristine original; the build dirs carry the GenAI-fixed variant, which gigatoken_cs 0.12.0 cannot load — both tokenize byte-identically, verified 19/19). Override with --tokenizer.

  • OnnxLm.cs — session, metadata-driven fp16/fp32 state handling, prefill / decode-step / greedy generate. onnxruntime's C# API has no half type, so fp16 states and logits travel as raw bytes (exact, no conversion loss).
  • Program.cs — chat generation demo + one end-to-end scored decision (the self-test refund question). Prompt bytes, prefix split, and slot ids mirror score_elephant.py; general multi-question scoring stays in Python.

Verified on model-cuda-int4 (CUDA): prompt sha256 9b352e9d… byte-identical to the Python renderer, prefix split 58 = 58, refund noul 0.8791 = Python 0.8791, chat generation Paris. Also verified on the other builds (Python == C#): cuda-int4 0.9342, cpu 0.9069, cpu-int8 0.8921.