Instructions to use Neo-3007/OptiCore_slm with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use Neo-3007/OptiCore_slm with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf Neo-3007/OptiCore_slm # Run inference directly in the terminal: llama cli -hf Neo-3007/OptiCore_slm
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf Neo-3007/OptiCore_slm # Run inference directly in the terminal: llama cli -hf Neo-3007/OptiCore_slm
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf Neo-3007/OptiCore_slm # Run inference directly in the terminal: ./build/bin/llama cli -hf Neo-3007/OptiCore_slm
Use Docker
docker model run hf.co/Neo-3007/OptiCore_slm
- Llama new
- LM Studio
- Jan
- Ollama
How to use Neo-3007/OptiCore_slm with Ollama:
ollama run hf.co/Neo-3007/OptiCore_slm
- Unsloth Desktop
- Docker Model Runner
How to use Neo-3007/OptiCore_slm with Docker Model Runner:
docker model run hf.co/Neo-3007/OptiCore_slm
- Lemonade
How to use Neo-3007/OptiCore_slm with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Neo-3007/OptiCore_slm
Run and chat with the model
lemonade run user.OptiCore_slm-{{QUANT_TAG}}List all available models
lemonade list
- Atomic Chat
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
OptiCoreSLM
A small language model fine-tuned to find and fix performance bottlenecks in C++ code β runs locally, no internet required.
OptiCoreSLM is built around one idea: C++ performance work often happens on codebases that can't leave the machine. Cloud-based tools are out. General-purpose local models are either too slow or too generic to be useful for hardware-level rewrites. OptiCoreSLM is fine-tuned specifically on C++ optimization patterns β bit manipulation, branchless arithmetic, cache-friendly data structures, algorithmic complexity β and ships as a VS Code extension backed by a local Python server.
Table of Contents
- How It Works
- Project Structure
- Prerequisites
- First-Time Setup
- Everyday Startup
- Using the Extension
- All Commands Reference
- Troubleshooting
- Usage Examples
- Benchmarks
- Links
- Acknowledgements
How It Works
OptiCoreSLM has three components that must all be running together:
VS Code Extension (you select C++ code, right-click β OptiCore: Optimize Selection)
β
β POST http://127.0.0.1:8080/optimize
βΌ
Python Server (server.py β Flask, runs locally)
β
βββ Rule-based engine (always available, instant, no model needed)
βββ GGUF model via llama-cpp-python (optional, loaded with --model flag)
The server has two modes:
| Mode | How to start | When to use |
|---|---|---|
| Rule-based fallback | python server.py |
Demo, testing, no model file available |
| Full AI model | python server.py --model path/to/model.gguf |
Production use with the fine-tuned weights |
The rule-based mode is not a stub β it covers real patterns: std::list β std::vector, std::map β std::unordered_map, nested O(NΒ²) loops, missing reserve(), raw new usage, Dutch National Flag sorting, bubble sort, and linear search on sorted arrays. It is accurate and instant. The GGUF model handles free-form cases outside those patterns.
Project Structure
opticore-slm/ # repo root
βββ opticore-slm/ # project folder
βββ server/
β βββ server.py # Flask inference server (port 8080)
β βββ requirements.txt # flask, flask-cors, llama-cpp-python
βββ training/ # fine-tuning scripts and JSONL datasets
β βββ train_sft.py
β βββ train_unsloth.py
β βββ all_training_data.jsonl
β βββ ...
βββ vscode-extension/ # VS Code extension source
βββ src/
β βββ extension.ts # extension entry point
βββ out/
β βββ extension.js # compiled output
βββ package.json # extension manifest (engines: vscode ^1.85.0)
βββ tsconfig.json
βββ opticore-slm-0.1.0.vsix # pre-built installable package
Prerequisites
| Requirement | Version | Notes |
|---|---|---|
| Python | 3.9+ | Check with python --version |
| pip | any recent | Comes with Python |
| Node.js | 18 LTS+ | Only needed if you modify the extension source |
| VS Code | 1.85+ | The extension's engines field requires this |
@vscode/vsce |
latest | Only needed to repackage the extension after code changes |
You do not need Ollama. The server runs the model directly via llama-cpp-python.
First-Time Setup
Do these steps once. After that, use Everyday Startup only.
Step 1 β Install Python dependencies
cd C:\Users\opticore-slm\opticore-slm\server
python -m pip install -r requirements.txt
requirements.txt installs:
| Package | Purpose |
|---|---|
flask>=3.0.0 |
Runs the local web server that the extension talks to |
flask-cors>=4.0.0 |
Allows the extension's webview to make requests to localhost |
llama-cpp-python>=0.2.0 |
Loads and runs the GGUF model file on CPU |
If
llama-cpp-pythonfails to install: It needs C++ build tools. On Windows, install Visual Studio Build Tools with the "Desktop development with C++" workload, then retry. If you only want the rule-based mode (no model), you can skip it β the server runs fine without it and will print a warning on startup.
Verify the installs:
python -m pip show flask
python -m pip show flask-cors
python -m pip show llama-cpp-python
Step 2 β Install the VS Code extension
The .vsix file is already built and committed. Install it once:
cd C:\Users\opticore-slm\opticore-slm\vscode-extension
code --install-extension opticore-slm-0.1.0.vsix
After installation, reload VS Code: Ctrl+Shift+P β Developer: Reload Window.
You do not need to run npm install or vsce package unless you are changing the extension source code.
Everyday Startup
Every time you restart your laptop or want to use OptiCore, do only these two steps.
Terminal 1 β Start the Python server
cd C:\Users\opticore-slm\opticore-slm\server
python server.py
Wait until you see:
[OptiCore] No --model provided. Running in rule-based fallback mode.
[OptiCore] Server starting on http://127.0.0.1:8080
* Running on http://127.0.0.1:8080
Keep this terminal open. The extension stops working the moment you close it.
To use the AI model instead of the rule-based fallback:
python server.py --model path\to\your-model.gguf
Terminal 2 β Open VS Code
cd C:\Users\opticore-slm\opticore-slm
code .
If VS Code is already open with the right folder, skip this.
Using the Extension
- Open any
.cppor.cfile in VS Code. - Select the code you want to optimize (a function, a block, or the whole file).
- Right-click the selection.
- Click OptiCore: Optimize Selection.
- A side panel opens showing original vs optimized code and an explanation.
The right-click menu item only appears when:
- A
.cppor.cfile is open (VS Code language ID:cpporc)- Some text is selected
If the item doesn't appear, check those two conditions first. You can also run it from the Command Palette: Ctrl+Shift+P β type OptiCore: Optimize Selection.
All Commands Reference
A. Running the backend
| Task | Command |
|---|---|
| Navigate to server folder | cd C:\Users\opticore-slm\opticore-slm\server |
| Start server (rule-based mode) | python server.py |
| Start server (with AI model) | python server.py --model path\to\model.gguf |
| Start on a different port | python server.py --port 9090 |
| Stop the server | Ctrl+C in the server terminal |
| Check Python version | python --version |
| Verify Flask is installed | python -m pip show flask |
| Verify flask-cors is installed | python -m pip show flask-cors |
| Verify llama-cpp-python | python -m pip show llama-cpp-python |
| List all installed packages | python -m pip list |
| Install all dependencies | python -m pip install -r requirements.txt |
B. Working with the VS Code extension
Navigate to the extension folder first:
cd C:\Users\opticore-slm\opticore-slm\vscode-extension
| Task | Command | When to use |
|---|---|---|
| Install the pre-built extension | code --install-extension opticore-slm-0.1.0.vsix |
First-time setup or reinstall |
| Force reinstall same version | code --install-extension opticore-slm-0.1.0.vsix --force |
Extension got corrupted or deactivated |
| Install JS dependencies | npm install |
Only after cloning fresh or changing package.json |
| Compile TypeScript | npm run compile |
After editing src/extension.ts |
| Watch mode (auto-recompile) | npm run watch |
During active development |
Package into .vsix |
vsce package |
After compiling, to build a new installable file |
List .vsix files |
dir *.vsix |
To see the filename before installing |
| Reload VS Code after install | Ctrl+Shift+P β Developer: Reload Window |
Always run after installing/updating .vsix |
Workflow when you change the extension source:
cd C:\Users\opticore-slm\opticore-slm\vscode-extension
npm run compile
vsce package
dir *.vsix
code --install-extension opticore-slm-0.1.0.vsix --force
Then reload VS Code (Ctrl+Shift+P β Developer: Reload Window).
C. Verifying the server is up
Open a browser or run this in PowerShell:
http://127.0.0.1:8080
You should get a JSON response like:
{
"engine": "opticore-ai",
"model_loaded": false,
"service": "OptiCore SLM",
"status": "ok"
}
model_loaded: false means the server is in rule-based mode (no GGUF file). That is normal and fine for most use.
Troubleshooting
OptiCore: Could not reach the server. Is server.py running?
The extension sent a request but got no response. Fix: Start the server in a terminal and keep it running.
cd C:\Users\opticore-slm\opticore-slm\server
python server.py
Server crashes immediately on startup with a colorama/click error
The server already works around this with os.environ.setdefault("NO_COLOR", "1"). If you still see it, make sure you are running the latest server.py from the repo.
python -m pip install -r requirements.txt fails on llama-cpp-python
This package compiles C++ code. You need build tools installed:
- Download Visual Studio Build Tools.
- Select Desktop development with C++.
- Install, then restart your terminal.
- Retry
python -m pip install llama-cpp-python.
If you don't need the AI model and only want the rule-based mode, skip this package β flask and flask-cors are enough to run the server.
npm install fails: Could not find package.json
You are in the wrong folder. package.json is inside vscode-extension/, not the repo root:
cd C:\Users\opticore-slm\opticore-slm\vscode-extension
dir
Confirm package.json is listed, then run npm install.
vsce package is not recognized
Install vsce globally first:
npm install -g @vscode/vsce
Then retry vsce package from inside the vscode-extension/ folder.
The right-click menu item doesn't show up
Two conditions must both be true:
- The file must be a
.cppor.cfile (VS Code detects this automatically from the extension). - You must have text selected before right-clicking.
If both are true and the item is still missing: run code --install-extension opticore-slm-0.1.0.vsix --force and reload VS Code.
Extension shows an error but the server is running
The default server URL in the extension is http://127.0.0.1:8080. Confirm this in VS Code Settings:
Ctrl+, β search opticore β check opticore.serverUrl
If your server started on a different port (e.g., you used --port 9090), update this setting to match.
Model inference takes a long time or times out
The server waits up to 90 seconds for the model. On CPU-only machines, inference on longer functions can approach this limit. Options:
- Use a smaller/more quantized GGUF file.
- Trim the selection to just the function you want optimized.
- Use rule-based mode for instant results (
python server.pywithout--model).
Usage Examples
Bit-count optimization
Before:
int countBits(int n) {
int count = 0;
while (n) {
count += n & 1;
n >>= 1;
}
return count;
}
After:
int countBits(int n) {
return __builtin_popcount(n);
}
Power-of-2 check
Before:
bool isPowerOfTwo(int n) {
return (n > 0) && (n % 2 == 0);
}
After:
bool isPowerOfTwo(int n) {
return (n > 0) && !(n & (n - 1));
}
Sort 0s, 1s, 2s (Dutch National Flag)
Before (counting sort, two passes):
void sortZeroOneTwo(vector<int>& nums) {
int c0 = 0, c1 = 0, c2 = 0;
for (int x : nums) { if (x==0) c0++; else if (x==1) c1++; else c2++; }
int i = 0;
while (c0--) nums[i++] = 0;
while (c1--) nums[i++] = 1;
while (c2--) nums[i++] = 2;
}
After (single pass, O(N) time, O(1) space):
void sortZeroOneTwo(vector<int>& nums) {
// Dutch National Flag Algorithm (Dijkstra's 3-way partition)
int low = 0, mid = 0, high = (int)nums.size() - 1;
while (mid <= high) {
if (nums[mid] == 0) { swap(nums[low], nums[mid]); low++; mid++; }
else if (nums[mid] == 1) { mid++; }
else { swap(nums[mid], nums[high]); high--; }
}
}
Benchmarks
Measured manually at -O0 on x86-64 (GCC). Numbers are directional.
| Task | Original | Optimized | Approx. reduction |
|---|---|---|---|
| Bit count | while loop + shift |
__builtin_popcount |
~90% |
| Power-of-2 check | n % 2 |
!(n & (n-1)) |
~95% |
| Sort 0/1/2 | Counting sort (2 passes) | Dutch National Flag (1 pass) | ~50% |
Links
| Hugging Face model | Neo-3007/OptiCore_slm |
| Hugging Face dataset | [https://huggingface.co/datasets/Neo-3007/opticore_Slm/viewer/default/train?p=2] |
| GitHub | jetashjethi-ui/opticore-slm |
| Demo video | Watch on YouTube |
Acknowledgements
- Requestly β used to mock the
POST /optimizeHTTP calls during development so the extension UI could be built and tested beforeserver.pywas wired up. Cut integration time significantly. - Flask β lightweight Python web framework powering the inference server.
- llama-cpp-python β Python bindings for llama.cpp, used to run the GGUF model on CPU.
- Hugging Face β model and dataset hosting.
- Downloads last month
- 45
We're not able to determine the quantization variants.