{"id":41954818,"url":"https://github.com/neurlang/classifier","last_synced_at":"2026-01-25T22:14:24.936Z","repository":{"id":236574644,"uuid":"792885611","full_name":"neurlang/classifier","owner":"neurlang","description":"Neurlang binary classifier (Hashtron)","archived":false,"fork":false,"pushed_at":"2026-01-14T23:00:03.000Z","size":3585,"stargazers_count":7,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-15T05:36:04.150Z","etag":null,"topics":["binary","classifier","go","golang","hashtron"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neurlang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-04-27T20:34:41.000Z","updated_at":"2026-01-14T23:00:07.000Z","dependencies_parsed_at":"2026-01-15T01:01:11.083Z","dependency_job_id":null,"html_url":"https://github.com/neurlang/classifier","commit_stats":null,"previous_names":["neurlang/classifier"],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/neurlang/classifier","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neurlang%2Fclassifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neurlang%2Fclassifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neurlang%2Fclassifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neurlang%2Fclassifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neurlang","download_url":"https://codeload.github.com/neurlang/classifier/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neurlang%2Fclassifier/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28760643,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T20:56:06.009Z","status":"ssl_error","status_checked_at":"2026-01-25T20:54:48.203Z","response_time":113,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binary","classifier","go","golang","hashtron"],"created_at":"2026-01-25T22:14:24.195Z","updated_at":"2026-01-25T22:14:24.928Z","avatar_url":"https://github.com/neurlang.png","language":"Go","readme":"# Neurlang Classifier\n\n![Neurlang Binary Classifier](./classifier.svg)\n\nNeurlang Classifier is a lightweight ML library for binary and quaternary neural networks that train quickly on CPUs. It models neurons with simple integer-to-boolean filters, enabling networks to be trained purely with integer arithmetic—no backpropagation, no floating-point math, and no GPU required. This makes training fast on multi-core CPUs while keeping dependencies minimal.\n\nThe framework has been proven in production, including training large-scale transformers for the [goruut phonemizer](https://github.com/neurlang/goruut). Use cases include virus detection, handwritten digit recognition, phoneme modeling, speech command classification, and more.\n\n## Features\n\n- **No backpropagation or perceptrons**: Uses simple integer-based logic instead of weight gradients, enabling an alternative ML paradigm\n- **CPU-optimized, hardware-light**: Requires no GPU—training is fast on multi-core CPUs using bitwise and integer operations\n- **Quaternary neurons**: Implements custom layers (convolution, attention, pooling, parity, etc.) that operate on boolean/integer data\n- **Tiny dependencies**: Written in pure Go with minimal external libraries, simplifying installation and portability\n- **Hash-based models**: Resulting models are extremely fast for inference using hash-based feature extraction\n- **Proven at scale**: Already used in production projects to train large-scale transformers\n\n## Getting Started\n\n### Prerequisites\n\n- Go 1.18 or higher\n\n### Installation\n\n```bash\ngo get github.com/neurlang/classifier\n```\n\n## Usage Examples\n\n### Training MNIST Digit Classifier\n\n```bash\ncd cmd/train_mnist\ngo run .\n```\n\n### Running Inference on MNIST\n\n```bash\ncd cmd/infer_mnist\ngo run .\n```\n\n### Training Virus Detection Classifier\n\n```bash\ncd cmd/train_is_virus\ngo run .\n```\n\n### Other Examples\n\nThe `cmd/` directory contains additional demo programs:\n- `train_is_alnum` / `infer_is_alnum` - Alphanumeric character classification\n- `train_speak` - Speech command recognition\n- `train_squareroot` / `infer_squareroot` - Mathematical function learning\n- `train_phonemizer_multi` / `train_phonemizer_ulevel` - Grapheme-to-phoneme conversion\n\nRun `./cmd/trainall.sh` to train all examples or `./cmd/runall.sh` to run all inference demos.\n\n## Package Overview\n\n- **cmd** - Demo programs with `train_*` and `infer_*` commands for various tasks\n- **datasets** - Core dataset interface and implementations:\n  - `isalnum` - Alphanumeric character dataset\n  - `isvirus` - TLSH file hash signatures for virus detection\n  - `mnist` - Standard MNIST handwritten digits (60k train / 10k test)\n  - `phonemizer_multi` / `phonemizer_ulevel` - Grapheme-to-phoneme datasets\n  - `speak` - Speech commands dataset\n  - `squareroot` - Synthetic dataset for numeric relations\n  - `stringhash` - String hashing and classification\n- **hash** - Fast modular hash function implementation used by Neurlang layers\n- **hashtron** - Core \"hashtron\" classifier model implementing the neuron logic\n- **layer** - Abstract interfaces and implementations:\n  - `conv2d` - 2D binary convolutional layer\n  - `crossattention` - Cross-attention layer for transformer-like models\n  - `full` - Fully connected (dense) layer\n  - `majpool2d` - 2D majority pooling layer\n  - `parity` - Parity (XOR-like) layer\n  - `sochastic` - Stochastic/randomly connected layer\n  - `sum` - Element-wise sum layer\n- **net** - Network architecture definitions:\n  - `feedforward` - Feedforward network architecture\n- **parallel** - Concurrency utilities (`ForEach`, `LoopUntil`) to speed up training\n- **trainer** - High-level training orchestration managing training loops over datasets\n\n## Implementing a Dataset\n\nTo implement a dataset, define a slice of samples where each sample has these methods:\n\n```go\ntype Sample interface {\n    Feature(int) uint32  // Returns the feature at the specified index\n    Parity() uint16      // Returns parity for dataset balancing (0 if balanced)\n    Output() uint16      // Returns the output label/prediction\n}\n```\n\n## Implementing a Network\n\nExample network with majority pooling layers:\n\n```go\nconst fanout1 = 3\nconst fanout2 = 5\nconst fanout3 = 3\nconst fanout4 = 5\n\nvar net feedforward.FeedforwardNetwork\nnet.NewLayerP(fanout1*fanout2*fanout3*fanout4, 0, 1\u003c\u003cfanout4)\nnet.NewCombiner(majpool2d.MustNew(fanout1*fanout2*fanout4, 1, fanout3, 1, fanout4, 1, 1))\nnet.NewLayerP(fanout1*fanout2, 0, 1\u003c\u003cfanout2)\nnet.NewCombiner(majpool2d.MustNew(fanout2, 1, fanout1, 1, fanout2, 1, 1))\nnet.NewLayer(1, 0)\n```\n\n- `fanout1` and `fanout3` define majority pooling dimensions\n- `fanout2` and `fanout4` define the number of hashtrons\n- The final layer contains one hashtron for predictions (0 or 1 means 1 bit predicted, up to 16 bits supported)\n\n### Training and Inference\n\nTraining uses the `trainer` package with custom evaluation and training functions:\n\n```go\nimport \"github.com/neurlang/classifier/trainer\"\nimport \"github.com/neurlang/classifier/parallel\"\n\n// Define training function\ntrainWorst := trainer.NewTrainWorstFunc(net, nil, nil, nil,\n    func(worst []int, tally datasets.AnyTally) {\n        parallel.ForEach(len(dataslice), 1000, func(i int) {\n            var sample = dataslice[i]\n            net.AnyTally(\u0026sample, worst, tally, customErrorFunc)\n        })\n    })\n\n// Define evaluation function\nevaluate := trainer.NewEvaluateFunc(net, len(dataslice), 99, \u0026improved_success_rate, dstmodel,\n    func(length int, h trainer.EvaluateFuncHasher) int {\n        // Evaluate accuracy on dataset\n        return successRate\n    })\n\n// Run training loop\ntrainer.NewLoopFunc(net, \u0026improved_success_rate, 100, evaluate, trainWorst)()\n```\n\nInference is straightforward:\n\n```go\npredicted := net.Infer2(\u0026sample)  // Returns predicted output\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit issues, feature requests, or pull requests.\n\n## License\n\nNeurlang Classifier is licensed under Apache 2.0 or Public Domain, at your option.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneurlang%2Fclassifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneurlang%2Fclassifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneurlang%2Fclassifier/lists"}