Views
No views yet
1# Install dependencies
2pip install mlx huggingface_hub numpy
3
4# Download model
5huggingface-cli download codelion/malm-165m --local-dir ./malm-165m
6
7# Run semantic search
8python malm-165m/inference.py --query "function that sorts a list"1Query: function that sorts a list
2------------------------------------------------------------
3
41. array_sort (score: 0.9526)
5 Signature: array_sort(col)
6 Docstring: Collection function: sorts the input array in ascending order...
7
82. sort_array (score: 0.7707)
9 Signature: sort_array(col, asc)
10 Docstring: Collection function: sorts the input array in ascending or descending order...1from huggingface_hub import snapshot_download
2from pathlib import Path
3import sys
4
5# Download and import
6model_path = snapshot_download("codelion/malm-165m")
7sys.path.insert(0, model_path)
8
9from inference import load_model, search_functions
10
11# Load model
12model, tokenizer, functions, config = load_model(Path(model_path))
13print(f"Loaded {len(functions)} functions")
14
15# Search
16results = search_functions(
17 model, tokenizer, functions,
18 query="connect to database",
19 top_k=5
20)
21
22for name, signature, docstring, score in results:
23 print(f"{name}: {score:.4f}")mlx-lm generate, so we provide a custom inference script.| Component | Parameters |
|---|---|
| Embedding | 11.1M |
| Position Embedding | 0.1M |
| Query Encoder (4 layers) | 28.4M |
| Value Encoder (4 layers) | 28.4M |
| Decoder (12 layers) | 85.1M |
| Output Projection | 11.1M |
| Total | ~165M |
1{
2 "vocab_size": 14407,
3 "d_model": 768,
4 "n_heads": 12,
5 "n_layers": 12,
6 "n_query_layers": 4,
7 "max_seq_len": 128,
8 "num_parameters": 165123656,
9 "num_functions": 2000
10}| File | Description |
|---|---|
model.npz | Model weights (MLX-compatible NumPy format) |
config.json | Model configuration |
tokenizer.json | Tokenizer vocabulary |
functions.json | Memory bank of 2000 Python functions |
inference.py | Standalone inference script |
1@article{sharma2026malm,
2 title={Reverse Engineering a $500M Mystery: From HashHop to Memory-Augmented Language Models},
3 author={Sharma, Asankhaya},
4 year={2026},
5 url={https://huggingface.co/blog/codelion/reverse-engineering-magic-hashhop}
6}