Instructions to use nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- llama-cpp-python
How to use nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor", filename="SmolLM2-360M.Q4_K_M.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor:Q4_K_M # Run inference directly in the terminal: llama-cli -hf nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor:Q4_K_M # Run inference directly in the terminal: llama-cli -hf nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor:Q4_K_M
Use Docker
docker model run hf.co/nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor:Q4_K_M
- LM Studio
- Jan
- Ollama
How to use nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor with Ollama:
ollama run hf.co/nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor:Q4_K_M
- Unsloth Studio new
How to use nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor to start chatting
- Docker Model Runner
How to use nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor with Docker Model Runner:
docker model run hf.co/nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor:Q4_K_M
- Lemonade
How to use nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor:Q4_K_M
Run and chat with the model
lemonade run user.SmolLM2-360M-Assignment-Metadata-Extractor-Q4_K_M
List all available models
lemonade list
Update Readme.md
Browse files
README.md
CHANGED
|
@@ -3,18 +3,122 @@ tags:
|
|
| 3 |
- gguf
|
| 4 |
- llama.cpp
|
| 5 |
- unsloth
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
---
|
| 8 |
|
| 9 |
-
# SmolLM2-360M-Assignment-Metadata-Extractor
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
-
- For text only LLMs: `llama-cli -hf nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor --jinja`
|
| 15 |
-
- For multimodal models: `llama-mtmd-cli -hf nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor --jinja`
|
| 16 |
|
| 17 |
-
|
| 18 |
-
- `SmolLM2-360M.Q4_K_M.gguf`
|
| 19 |
-
This was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth)
|
| 20 |
-
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
|
|
|
| 3 |
- gguf
|
| 4 |
- llama.cpp
|
| 5 |
- unsloth
|
| 6 |
+
- smollm2
|
| 7 |
+
- json-extraction
|
| 8 |
+
- data-extraction
|
| 9 |
+
language:
|
| 10 |
+
- en
|
| 11 |
+
license: apache-2.0
|
| 12 |
+
base_model: HuggingFaceTB/SmolLM2-360M
|
| 13 |
---
|
| 14 |
|
| 15 |
+
# ๐ SmolLM2-360M-Assignment-Metadata-Extractor (GGUF)
|
| 16 |
+
|
| 17 |
+
This is a highly specialized, lightweight (360M parameter) model fine-tuned specifically to extract student metadata from chaotic, noisy assignment text and output it as strictly formatted JSON.
|
| 18 |
+
|
| 19 |
+
It was finetuned and converted to 4-bit GGUF format using [Unsloth](https://github.com/unslothai/unsloth) for maximum CPU/GPU efficiency and rapid deployment via Ollama or `llama.cpp`.
|
| 20 |
+
|
| 21 |
+
## ๐ Model Capabilities
|
| 22 |
+
|
| 23 |
+
Unlike generic LLMs, this model has been purposefully overfit on a highly mutated dataset to act as a **Zero-Shot Data Extractor**. It excels at:
|
| 24 |
+
- **Noise Filtering:** Completely ignoring conversational filler, apologies, word counts, formatting artifacts, and academic instructions.
|
| 25 |
+
- **Handling Chaos:** Robust against typos (e.g., "Stuednt No"), varied capitalization, and unpredictable line breaks.
|
| 26 |
+
- **Strict JSON Output:** Trained to output ONLY a valid JSON object with zero conversational preamble (no "Here is the JSON...").
|
| 27 |
+
|
| 28 |
+
### Expected Output Schema
|
| 29 |
+
The model will exclusively output data in the following JSON structure:
|
| 30 |
+
```json
|
| 31 |
+
{
|
| 32 |
+
"student_number": "...",
|
| 33 |
+
"student_name": "...",
|
| 34 |
+
"assignment_number": "..."
|
| 35 |
+
}
|
| 36 |
+
````
|
| 37 |
+
|
| 38 |
+
-----
|
| 39 |
+
|
| 40 |
+
## ๐ Deployment & Usage
|
| 41 |
+
|
| 42 |
+
Because this model was trained with a specific instruction template, it performs best when wrapped in an environment that enforces **Temperature 0** and matches the training prompt.
|
| 43 |
+
|
| 44 |
+
### Method 1: Using Ollama (Recommended for standard usage)
|
| 45 |
+
|
| 46 |
+
Create a `Modelfile` with the following configuration to enforce the correct prompt template and prevent creativity:
|
| 47 |
+
|
| 48 |
+
```text
|
| 49 |
+
FROM hf.co/nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor:Q4_K_M
|
| 50 |
+
|
| 51 |
+
TEMPLATE """### Instruction:
|
| 52 |
+
Extract student info as JSON from the following text.
|
| 53 |
+
|
| 54 |
+
### Input:
|
| 55 |
+
{{ .Prompt }}
|
| 56 |
+
|
| 57 |
+
### Response:
|
| 58 |
+
"""
|
| 59 |
+
|
| 60 |
+
SYSTEM """
|
| 61 |
+
You are a precise student assignment data extractor.
|
| 62 |
+
Output ONLY a valid JSON object. No explanation. No extra text. No markdown.
|
| 63 |
+
Always output exactly: {"student_number":"...","student_name":"...","assignment_number":"..."}
|
| 64 |
+
"""
|
| 65 |
|
| 66 |
+
PARAMETER temperature 0
|
| 67 |
+
PARAMETER stop "}"
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
**Build and Run:**
|
| 71 |
+
|
| 72 |
+
```bash
|
| 73 |
+
ollama create json-extractor -f Modelfile
|
| 74 |
+
ollama run json-extractor "Course: CS101 \n Stuednt No=20210088 \n Full Nme: Nimal Silva \n HW No.-03 \n Please grade fairly!"
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
### Method 2: Python using Outlines (For bulletproof JSON validation)
|
| 78 |
+
|
| 79 |
+
For production environments where `json.JSONDecodeError` is entirely unacceptable, use this model with `outlines` and `llama-cpp-python` to structurally constrain the output tokens.
|
| 80 |
+
|
| 81 |
+
```python
|
| 82 |
+
import outlines
|
| 83 |
+
from pydantic import BaseModel
|
| 84 |
+
|
| 85 |
+
class StudentExtraction(BaseModel):
|
| 86 |
+
student_number: str
|
| 87 |
+
student_name: str
|
| 88 |
+
assignment_number: str
|
| 89 |
+
|
| 90 |
+
# Load the GGUF model
|
| 91 |
+
model = outlines.models.llamacpp(
|
| 92 |
+
"hf.co/nimendraai/SmolLM2-360M-Assignment-Metadata-Extractor:Q4_K_M",
|
| 93 |
+
device="cpu" # or "cuda"
|
| 94 |
+
)
|
| 95 |
+
|
| 96 |
+
# Constrain the generator to the Pydantic schema
|
| 97 |
+
generator = outlines.generate.json(model, StudentExtraction)
|
| 98 |
+
|
| 99 |
+
# Format the prompt exactly as trained
|
| 100 |
+
prompt = (
|
| 101 |
+
"### Instruction:\nExtract student info as JSON from the following text.\n\n"
|
| 102 |
+
"### Input:\nStu. ID: 20210088 | Full Name: Nimal Silva | HW-3\n\n"
|
| 103 |
+
"### Response:\n"
|
| 104 |
+
)
|
| 105 |
+
|
| 106 |
+
result = generator(prompt)
|
| 107 |
+
print(result.model_dump_json())
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
-----
|
| 111 |
+
|
| 112 |
+
## ๐ง Training Details
|
| 113 |
+
|
| 114 |
+
- **Base Model:** `HuggingFaceTB/SmolLM2-360M`
|
| 115 |
+
- **Dataset:** 1,250 highly varied synthetic examples containing realistic human errors, markdown noise, and distractor text.
|
| 116 |
+
- **Epochs:** 5 (Optimized to achieve a loss \< \~0.40 to prevent hallucinations).
|
| 117 |
+
- **Framework:** Trained efficiently using LoRA (Low-Rank Adaptation) via Unsloth.
|
| 118 |
+
- **Quantization:** Exported to `Q4_K_M` GGUF format to reduce memory footprint to \~270MB.
|
| 119 |
+
|
| 120 |
+
---
|
| 121 |
|
| 122 |
+
This was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth)
|
|
|
|
|
|
|
| 123 |
|
| 124 |
+
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
|
|
|
|
|
|
|
|