docs: add Hugging Face Model Card with tags and usage
Browse files
README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
- code
|
| 5 |
+
license: apache-2.0
|
| 6 |
+
tags:
|
| 7 |
+
- code-generation
|
| 8 |
+
- code-documentation
|
| 9 |
+
- non-autoregressive
|
| 10 |
+
- stanford-ncm
|
| 11 |
+
- vq-vae
|
| 12 |
+
- mcp
|
| 13 |
+
- codesearchnet
|
| 14 |
+
datasets:
|
| 15 |
+
- code_search_net
|
| 16 |
+
pipeline_tag: text-generation
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# NCM Code Documentation (Next-Concept Modeling)
|
| 20 |
+
|
| 21 |
+
Fine-tuned checkpoint of Stanford's **Next-Concept Modeling (NCM)** architecture, adapted for ultra-fast, local code documentation and technical function summarization.
|
| 22 |
+
|
| 23 |
+
- **GitHub Repository**: [artapaher-max/ncm-code-doc](https://github.com/artapaher-max/ncm-code-doc)
|
| 24 |
+
- **Base Architecture**: Stanford University / Hazy Research ([HazyResearch/ncm](https://github.com/HazyResearch/ncm))
|
| 25 |
+
- **Primary Integration**: Model Context Protocol (MCP) server for local IDE agents (Antigravity IDE, Claude Desktop, Cursor).
|
| 26 |
+
|
| 27 |
+
---
|
| 28 |
+
|
| 29 |
+
## Model Architecture & Details
|
| 30 |
+
|
| 31 |
+
NCM operates in a **non-autoregressive (NAR)** latent space through a 9-level hierarchical Vector-Quantized Variational Autoencoder (VQ-VAE).
|
| 32 |
+
|
| 33 |
+
- **Non-Autoregressive Generation**: Unlike standard autoregressive LLMs (which decode one token at a time), NCM decodes conceptual representations in parallel across 9 quantization depth levels.
|
| 34 |
+
- **Inference Latency**: ~50–100 ms per block on consumer desktop GPUs (e.g., NVIDIA RTX 2060 6GB).
|
| 35 |
+
- **Target Context Length**: Bounded to $\le 48$ tokens. Optimized specifically for single-sentence docstrings, function signatures, and concise technical summaries.
|
| 36 |
+
- **Prefix Window**: Up to 512 raw tokens of source code.
|
| 37 |
+
|
| 38 |
+
---
|
| 39 |
+
|
| 40 |
+
## Intended Use
|
| 41 |
+
|
| 42 |
+
This model is intended to act as a **lightweight, local writing assistant** offloading routine documentation tasks from large frontier LLMs (Claude 3.5 Sonnet, GPT-4, Gemini):
|
| 43 |
+
|
| 44 |
+
1. **Token Cost & Latency Reduction**: Avoid spending frontier model tokens on repetitive single-sentence function descriptions.
|
| 45 |
+
2. **Local MCP Server**: Run locally alongside coding assistants via stdio MCP.
|
| 46 |
+
|
| 47 |
+
---
|
| 48 |
+
|
| 49 |
+
## Quickstart & Usage
|
| 50 |
+
|
| 51 |
+
### 1. Download Model Checkpoints
|
| 52 |
+
|
| 53 |
+
Using Python:
|
| 54 |
+
```python
|
| 55 |
+
from huggingface_hub import snapshot_download
|
| 56 |
+
|
| 57 |
+
snapshot_download(
|
| 58 |
+
repo_id="r2d2aparicio/ncm-code-doc",
|
| 59 |
+
local_dir="artifacts/ncm_code_doc"
|
| 60 |
+
)
|
| 61 |
+
```
|
| 62 |
+
|
| 63 |
+
Files downloaded:
|
| 64 |
+
- `generator.pt` (~354 MB): NextConceptTransformer weights.
|
| 65 |
+
- `tokenizer.pt` (~299 MB): Hierarchical VQ-VAE tokenizer weights with code-adapted decoder.
|
| 66 |
+
|
| 67 |
+
### 2. Run with MCP Server
|
| 68 |
+
|
| 69 |
+
To use this model as a tool in Claude Desktop or Antigravity IDE, clone the official MCP server:
|
| 70 |
+
|
| 71 |
+
```bash
|
| 72 |
+
git clone https://github.com/artapaher-max/ncm-code-doc.git
|
| 73 |
+
cd ncm-code-doc
|
| 74 |
+
pip install -e .
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
And configure `mcpServers`:
|
| 78 |
+
```json
|
| 79 |
+
{
|
| 80 |
+
"mcpServers": {
|
| 81 |
+
"ncm-fast-writer": {
|
| 82 |
+
"command": "/path/to/ncm-code-doc/.venv/bin/python",
|
| 83 |
+
"args": ["-u", "/path/to/ncm-code-doc/ncm_doc_server.py"],
|
| 84 |
+
"env": { "PYTHONUNBUFFERED": "1" }
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
---
|
| 91 |
+
|
| 92 |
+
## Training Data & Hardware
|
| 93 |
+
|
| 94 |
+
- **Dataset**: 5,000 code-docstring pairs sampled from `code_search_net` across Python, JavaScript, and Web repositories.
|
| 95 |
+
- **Fine-Tuning Hardware**: Single NVIDIA GeForce RTX 2060 (6 GB VRAM GDDR6).
|
| 96 |
+
- **Memory Consumption**: ~2.9 GB VRAM during training (FP16 mixed precision, gradient accumulation, batch size 2).
|
| 97 |
+
- **Inference Memory**: ~2.5 GB VRAM.
|
| 98 |
+
|
| 99 |
+
---
|
| 100 |
+
|
| 101 |
+
## Citation & Acknowledgments
|
| 102 |
+
|
| 103 |
+
This model is fine-tuned from the checkpoint provided by Stanford Hazy Research:
|
| 104 |
+
|
| 105 |
+
```bibtex
|
| 106 |
+
@article{ncm2024,
|
| 107 |
+
title={Next-Concept Modeling: Scalable Non-Autoregressive Generation via Hierarchical Latent Space},
|
| 108 |
+
author={Hazy Research, Stanford University},
|
| 109 |
+
journal={arXiv preprint},
|
| 110 |
+
year={2024}
|
| 111 |
+
}
|
| 112 |
+
```
|