|
| 1 | +# Benchmarking and model comparison |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +`BitNetSharp.App` can now host more than one local model shape through the same Microsoft Agent Framework wrapper: |
| 6 | + |
| 7 | +- `bitnet-b1.58-sharp` for the paper-aligned seeded transformer |
| 8 | +- `traditional-local` for a local tensor-based comparison model trained on the default training corpus |
| 9 | +- an absolute path to a local command model JSON file for other locally available models |
| 10 | + |
| 11 | +The benchmark command uses BenchmarkDotNet to measure the same hosted-model operations that the SpecFlow scenarios exercise: |
| 12 | + |
| 13 | +- training a selected trainable model on the default dataset |
| 14 | +- generating a response for a prompt |
| 15 | +- streaming a response for a prompt |
| 16 | +- building the agent host |
| 17 | + |
| 18 | +## Run the built-in comparison benchmark |
| 19 | + |
| 20 | +```bash |
| 21 | +dotnet run --configuration Release --project /home/runner/work/BitNet-b1.58-Sharp/BitNet-b1.58-Sharp/src/BitNetSharp.App/BitNetSharp.App.csproj -- benchmark --model=bitnet-b1.58-sharp --compare-model=traditional-local --prompt="how are you hosted" |
| 22 | +``` |
| 23 | + |
| 24 | +This runs the BenchmarkDotNet suite over both local models so their hosted response and host-construction costs can be compared directly. |
| 25 | + |
| 26 | +## Train the traditional local model |
| 27 | + |
| 28 | +```bash |
| 29 | +dotnet run --project /home/runner/work/BitNet-b1.58-Sharp/BitNet-b1.58-Sharp/src/BitNetSharp.App/BitNetSharp.App.csproj -- train --model=traditional-local |
| 30 | +``` |
| 31 | + |
| 32 | +The traditional local model trains over `BitNetTrainingCorpus.CreateDefaultExamples()` for 24 epochs using `System.Numerics.Tensors` softmax and dot-product primitives so it can be benchmarked and queried against the same dataset every time. |
| 33 | + |
| 34 | +## Compare another local model |
| 35 | + |
| 36 | +Pass the absolute path to a JSON file that describes how to execute a locally available model runner: |
| 37 | + |
| 38 | +```bash |
| 39 | +dotnet run --configuration Release --project /home/runner/work/BitNet-b1.58-Sharp/BitNet-b1.58-Sharp/src/BitNetSharp.App/BitNetSharp.App.csproj -- benchmark --model=/absolute/path/to/local-model.json --compare-model=traditional-local |
| 40 | +``` |
| 41 | + |
| 42 | +Example configuration: |
| 43 | + |
| 44 | +```json |
| 45 | +{ |
| 46 | + "modelId": "my-local-model", |
| 47 | + "displayName": "My local model", |
| 48 | + "executablePath": "/absolute/path/to/model-runner", |
| 49 | + "arguments": [ |
| 50 | + "--model", |
| 51 | + "/absolute/path/to/model.bin" |
| 52 | + ], |
| 53 | + "promptTransport": "StandardInput", |
| 54 | + "primaryLanguage": "en-US" |
| 55 | +} |
| 56 | +``` |
| 57 | + |
| 58 | +### Prompt transport options |
| 59 | + |
| 60 | +- `StandardInput`: the prompt is written to the process standard input |
| 61 | +- `FinalArgument`: the prompt is appended as the final command-line argument |
| 62 | + |
| 63 | +This keeps model comparison local-only and avoids endpoint or API-key based integrations. |
0 commit comments